From da8210934c5658bfc608343a1a6d49e1d85c0902 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Wed, 23 Aug 2023 06:31:20 +0300 Subject: [PATCH] fixup! chore: refactor translations sync tool --- scripts/sync_translations.py | 39 ++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/scripts/sync_translations.py b/scripts/sync_translations.py index a3a2f98b00b..e0f7392f29c 100644 --- a/scripts/sync_translations.py +++ b/scripts/sync_translations.py @@ -63,17 +63,34 @@ def get_resources_pair(): def sync_language(language, old_resource, new_resource): try: - language_obj = tx_api.Language.get(code=language) - url = tx_api.ResourceTranslationsAsyncDownload. \ - download(resource=old_resource, language=language_obj) - translated_content = requests.get(url).text - print(translated_content) - - tx_api.ResourceTranslationsAsyncUpload.upload( - resource=new_resource, - language=f'l:{language}', - content=translated_content, - ) + # language_obj = tx_api.Language.get(code=language) + # url = tx_api.ResourceTranslationsAsyncDownload. \ + # download(resource=old_resource, language=language_obj) + # translated_content = requests.get(url).text + + language = transifex_api.Language.get(code=language) + translations = transifex_api.ResourceTranslation. \ + filter(resource=new_resource, language=language). \ + include('resource_string') + + for translation in translations: + if not translation.reviewed: + translation.reviewed = True + translation.save('reviewed') + print(translation.strings) + + import pdb; pdb.set_trace() + + # print(translated_content) + + # tx_api.ResourceTranslationsAsyncUpload.upload( + # resource=new_resource, + # language=f'l:{language}', + # content=translated_content, + # attributes=dict( + # reviewed = False, # TODO: Test + # ), + # ) except Exception as e: if debug: print(e)