diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index cd8cc2c70b..9f168ba68b 100644 --- a/.github/workflows/crowdin.yml +++ b/.github/workflows/crowdin.yml @@ -23,6 +23,9 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Crowdin Sync + shell: bash + env: + CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} run: | cd intl - python3 crowdin_sync.py + python3 crowdin_sync.py "$CROWDIN_API_KEY" diff --git a/intl/crowdin.yaml b/intl/crowdin.yaml index 0ea0f37ece..e6f926afc6 100644 --- a/intl/crowdin.yaml +++ b/intl/crowdin.yaml @@ -1,5 +1,5 @@ "project_identifier": "retroarch" -"api_key": "07c53d49b32e30803060b1acec1623ab" +"api_key": "_secret_" "preserve_hierarchy": true "files": @@ -15,5 +15,5 @@ { "source": "/googleplay_us.json", "translation": "/googleplay_%two_letters_code%.json", - }, + }, ] diff --git a/intl/crowdin_sync.py b/intl/crowdin_sync.py index 57eea9c9fe..dded263448 100755 --- a/intl/crowdin_sync.py +++ b/intl/crowdin_sync.py @@ -3,10 +3,28 @@ import os import shutil import subprocess +import sys import time import urllib.request import zipfile +# Check Crowdin API Key +if len(sys.argv) < 1: + print('Please Provides Crowdin API Key!') + exit() + +api_key = sys.argv[1] + +# Apply Crowdin API Key +crowdin_config_file = open('crowdin.yaml', 'r') +crowdin_config = crowdin_config_file.read() +crowdin_config_file.close() +crowdin_config = crowdin_config.replace('_secret_', api_key) +crowdin_config_file = open('crowdin.yaml', 'w') +crowdin_config_file.write(crowdin_config) +crowdin_config_file.close() + +# Download Crowdin CLI dir_path = os.path.dirname(os.path.realpath(__file__)) jar_name = 'crowdin-cli.jar' @@ -48,3 +66,12 @@ for file in os.listdir(dir_path): print('fetch translation progress') subprocess.run(['python3', 'fetch_progress.py']) + +# Reset Crowdin API Key +crowdin_config_file = open('crowdin.yaml', 'r') +crowdin_config = crowdin_config_file.read() +crowdin_config_file.close() +crowdin_config = crowdin_config.replace(api_key, '_secret_') +crowdin_config_file = open('crowdin.yaml', 'w') +crowdin_config_file.write(crowdin_config) +crowdin_config_file.close()