Skip to content

Commit

Permalink
Fix the translations import script
Browse files Browse the repository at this point in the history
It would duplicate an existing translation instead of inserting a new translation if there were two new translations listed consecutively for an anchor.
  • Loading branch information
Ortham committed Jul 15, 2024
1 parent b2c572a commit eb25761
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions scripts/import-translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ def get_yaml_string(raw_message_text):
if expected_langs:
# Expected more languages than were found in the last anchor,
# need to go back and append the remaining expected languages.
print('Expected more languages', anchor, expected_langs)
print(f'Expected more languages for anchor {anchor}: {expected_langs}')
exit(1)

anchor = match.group(1)
expected_langs = get_expected_languages(messages[anchor])
print(f'Expecting the following languages for anchor {anchor}: {expected_langs}')
lang = None

index += 1
Expand All @@ -70,8 +69,9 @@ def get_yaml_string(raw_message_text):
expected_lang = expected_langs[0]
if lang == expected_lang:
expected_langs.pop(0)
index += 1
else:
print(f'Expected an entry for language {expected_lang}, found entry for language {lang}, inserting the expected language before it')
print(f'Expected an entry for language {expected_lang} in anchor {anchor}, found entry for language {lang}, inserting the expected language before it')
match = re.search(r'(\s+)- lang:', lines[index])
whitespace = match.group(1)

Expand All @@ -83,12 +83,10 @@ def get_yaml_string(raw_message_text):
lines.insert(index, new_text_line)
lines.insert(index, new_lang_line)

expected_langs.pop(0)
expected_langs.pop(0)

index += 2

index += 1
continue

match = re.search(r' text: \'(.+)\'', lines[index])
Expand Down

0 comments on commit eb25761

Please sign in to comment.