Skip to content

Commit

Permalink
fixup! chore: refactor translations sync tool
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi committed Aug 23, 2023
1 parent a38cccf commit da82109
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions scripts/sync_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit da82109

Please sign in to comment.