1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00
RetroArch/intl/fetch_progress.py
Guo Yunhe 6ad91b2b37
Crowdin integration full (#13171)
* Create crowdin-daily.yml

* Update crowdin.yaml

* Update crowdin_sync.py

* Update fetch_progress.py
2021-11-03 18:44:08 +01:00

26 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import requests
import yaml
with open("crowdin.yaml", 'r') as config_file:
config = yaml.safe_load(config_file)
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 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)