import zipfile import json lang_crowdin = { 'ar': 'ar_ar', 'de': 'de_de', 'el': 'el_gr', 'es-ES': 'es_es', 'fa': 'fa_ir', 'fil': 'fil_ph', 'fr': 'fr_fr', 'he': 'he_il', 'hr': 'hr_hr', 'id': 'id_id', 'it': 'it_id', 'ko': 'ko_ko', 'pt-BR': 'pt_br', 'ro': 'ro_ro', 'ru': 'ru_ru', 'tr': 'tr_tr', 'pl': 'pl_pl', 'uk': 'uk_ua', 'hu': 'hu_hu', 'ur-PK': 'ur_pk', 'hi': 'hi_in' } def generate_dart(): out = {} with zipfile.ZipFile('translations.zip') as zip: for file in zip.namelist(): if 'freezer.json' in file: data = zip.open(file).read() lang = file.split('/')[0] out[lang_crowdin[lang]] = json.loads(data) with open('../lib/languages/crowdin.dart', 'w') as f: data = json.dumps(out, ensure_ascii=False).replace('$', '\\$') out = f'const crowdin = {data};' f.write(out) if __name__ == '__main__': generate_dart()