Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes merge translations step #72

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/scripts/merge_files_post_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
import sys
from pathlib import Path

import shutil

def main():
config_path = Path(sys.argv[1])
Expand All @@ -15,6 +15,11 @@ def main():
post_translation_jsons = data['PostTranslationJSONs']
final_dictionaries = data['FinalDictionaries']

# Check if the post_translation_jsons folder exists and delete its contents if it does
if os.path.exists(post_translation_jsons):
shutil.rmtree(post_translation_jsons)
os.makedirs(post_translation_jsons)

# Loop through files where the translations are stored
for folderpath in post_translation:

Expand All @@ -23,10 +28,6 @@ def main():
full_lang_path = os.path.join(folderpath, folder)
lang_name = os.path.basename(folder)

# check we have a folder ready to store a converted JSON version
if not os.path.exists(post_translation_jsons):
os.makedirs(post_translation_jsons)

# For all the non-english files, create a destination folder to store a converted JSON version
if lang_name != "en":
dest_lang_path = os.path.join(post_translation_jsons, lang_name)
Expand All @@ -39,7 +40,7 @@ def main():
json_file = os.path.join(dest_lang_path, file_name_without_ext + ".json")
subprocess.run(["node", "./common_tools/index.js", "convert", os.path.join(full_lang_path, file), json_file], check=True)

# check we have a folder ready to store the dictionaries
# Check we have a folder ready to store the dictionaries
if not os.path.exists(final_dictionaries):
os.makedirs(final_dictionaries)

Expand Down
Loading