Skip to content

Commit

Permalink
fix(translate_apps): the path to check if files existed was in the wr…
Browse files Browse the repository at this point in the history
…ong PWD
  • Loading branch information
Psycojoker committed Mar 31, 2024
1 parent 96c7c3c commit 2b0735e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/translate_apps/push_or_update_apps_on_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
continue

# if the translation file doesn't exist yet, dump it
if not (translations_path / f"{language}.json").exists():
if not translations_repository.file_exists(translations_path / f"{language}.json"):
translations_repository.write_file(
translations_path / f"{language}.json",
json.dumps(translated_strings, indent=4, sort_keys=True, ensure_ascii=False) + "\n",
)

else: # if it exists, only add keys that aren't already present
language_file = json.load((translations_path / f"{language}.json").open())
language_file = json.loads(translations_repository.read_file(translations_path / f"{language}.json"))

for key, translated_string in translated_strings.items():
if key not in language_file:
language_file[key] = translated_string
Expand Down

0 comments on commit 2b0735e

Please sign in to comment.