Skip to content

Commit

Permalink
translation script fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Manrique committed Nov 28, 2024
1 parent 181ee05 commit 134c3a8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_android_directories(dir_language):
languages_supporting_formality = ["DE", "FR", "IT", "ES", "NL", "PL", "PT-BR", "PT-PT", "JA", "RU"]


def translate_ios_infoplist_strings():
def translate_infoplist_strings():
with open(INPUT_FILE, 'r', encoding='utf-8') as file:
strings = file.readlines()

Expand All @@ -97,9 +97,10 @@ def translate_ios_infoplist_strings():

with open(translated_file_path, 'w', encoding='utf-8') as translated_file:
for line in strings:
if '="' in line:
key, value = line.split('="', 1)
value = value.strip().rstrip('";')
if '=' in line:
key, value = line.split('=', 1)
key = key.strip()
value = value.strip().strip('"').strip(';')

params = {
'auth_key': API_KEY,
Expand All @@ -115,7 +116,7 @@ def translate_ios_infoplist_strings():
result = response.json()

translated_text = result.get("translations", [{}])[0].get("text", "").strip()
translated_line = f'{key}="{translated_text}";'
translated_line = f'{key} = "{translated_text}";'
translated_file.write(translated_line)
print(f"{value} --> {translated_text}")
else:
Expand Down

0 comments on commit 134c3a8

Please sign in to comment.