From 134c3a87f0bd90eb1ec3d12d05ab8115034cd439 Mon Sep 17 00:00:00 2001 From: Javier Manrique <> Date: Thu, 28 Nov 2024 18:00:20 +0100 Subject: [PATCH] translation script fix --- translator.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/translator.py b/translator.py index 19f1653..2d7789a 100644 --- a/translator.py +++ b/translator.py @@ -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() @@ -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, @@ -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: