mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-08 10:27:41 +00:00
Crowdin integration full (#13171)
* Create crowdin-daily.yml * Update crowdin.yaml * Update crowdin_sync.py * Update fetch_progress.py
This commit is contained in:
parent
cbfbd14268
commit
6ad91b2b37
32
.github/workflows/crowdin-daily.yml
vendored
Normal file
32
.github/workflows/crowdin-daily.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
# Download translations from Crowdin and push to GitHub
|
||||
|
||||
name: Crowdin Daily Workflow
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # every day at midnight
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
- 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 "$CROWDIN_API_KEY"
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git add .
|
||||
git commit -m "Fetch translations from Crowdin"
|
||||
git push
|
@ -1,5 +1,6 @@
|
||||
"project_identifier": "retroarch"
|
||||
"api_key": "_secret_"
|
||||
"project_id": "380544"
|
||||
"api_token": "_secret_"
|
||||
"base_url": "https://api.crowdin.com"
|
||||
"preserve_hierarchy": true
|
||||
|
||||
"files":
|
||||
|
@ -32,7 +32,7 @@ jar_name = 'crowdin-cli.jar'
|
||||
if not os.path.isfile(jar_name):
|
||||
print('download crowdin-cli.jar')
|
||||
crowdin_cli_file = 'crowdin-cli.zip'
|
||||
crowdin_cli_url = 'https://downloads.crowdin.com/cli/v2/' + crowdin_cli_file
|
||||
crowdin_cli_url = 'https://downloads.crowdin.com/cli/v3/' + crowdin_cli_file
|
||||
urllib.request.urlretrieve(crowdin_cli_url, crowdin_cli_file)
|
||||
with zipfile.ZipFile(crowdin_cli_file, 'r') as zip_ref:
|
||||
jar_dir = zip_ref.namelist()[0]
|
||||
@ -56,7 +56,7 @@ print('wait for crowdin server to process data')
|
||||
time.sleep(10)
|
||||
|
||||
print('download translation *.json')
|
||||
subprocess.run(['java', '-jar', 'crowdin-cli.jar', 'download', 'translations'])
|
||||
subprocess.run(['java', '-jar', 'crowdin-cli.jar', 'download'])
|
||||
|
||||
print('convert *.json to *.h')
|
||||
for file in os.listdir(dir_path):
|
||||
|
@ -6,12 +6,20 @@ import yaml
|
||||
|
||||
with open("crowdin.yaml", 'r') as config_file:
|
||||
config = yaml.safe_load(config_file)
|
||||
r = requests.get('https://api.crowdin.com/api/project/' + config['project_identifier'] + '/status?key=' + config['api_key'] + '&json')
|
||||
headers = { 'Authorization': 'Bearer ' + config['api_token']}
|
||||
|
||||
url1 = 'https://api.crowdin.com/api/v2/projects/' + config['project_id'] + '/languages/progress?limit=100'
|
||||
res1 = requests.get(url1, headers=headers)
|
||||
output = ''
|
||||
for lang in r.json():
|
||||
output += '/* ' + lang['name'] + ' */\n'
|
||||
escaped_name = lang['name'].replace(', ', '_').replace(' ', '_').upper()
|
||||
output += '#define LANGUAGE_PROGRESS_' + escaped_name + '_TRANSLATED ' + str(lang['translated_progress']) + '\n'
|
||||
output += '#define LANGUAGE_PROGRESS_' + escaped_name + '_APPROVED ' + str(lang['approved_progress']) + '\n\n'
|
||||
for lang in res1.json()['data']:
|
||||
lang_id = lang['data']['languageId']
|
||||
url2 = 'https://api.crowdin.com/api/v2/languages/' + lang_id
|
||||
res2 = requests.get(url2, headers=headers)
|
||||
lang_name = res2.json()['data']['name']
|
||||
|
||||
output += '/* ' + lang_name + ' */\n'
|
||||
escaped_name = lang_name.replace(', ', '_').replace(' ', '_').upper()
|
||||
output += '#define LANGUAGE_PROGRESS_' + escaped_name + '_TRANSLATED ' + str(lang['data']['translationProgress']) + '\n'
|
||||
output += '#define LANGUAGE_PROGRESS_' + escaped_name + '_APPROVED ' + str(lang['data']['approvalProgress']) + '\n\n'
|
||||
with open("progress.h", 'w') as output_file:
|
||||
output_file.write(output)
|
||||
|
Loading…
x
Reference in New Issue
Block a user