Skip to content

Commit

Permalink
ci: fix locize placeholder check on empty strings
Browse files Browse the repository at this point in the history
If a translation is left empty, it falls back to English. In this case
we should not check that the placeholders match, it would be a false positive.
  • Loading branch information
benma committed Feb 27, 2025
1 parent 6c4c6ba commit adfc5c4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/check-locize-placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def check_nested_keys(en_data, lang_data, path=''):
else:
issues.extend(check_nested_keys(en_data[key], lang_data[key], current_path))
elif isinstance(en_data[key], str):
en_placeholders = find_placeholders(en_data[key])
lang_placeholders = find_placeholders(lang_data[key])
if not check_placeholders(en_placeholders, lang_placeholders):
issues.append(f"Placeholder mismatch at '{current_path}': '{lang_data[key]}' - found {lang_placeholders}; expected {en_placeholders}")
if lang_data[key] != "":
en_placeholders = find_placeholders(en_data[key])
lang_placeholders = find_placeholders(lang_data[key])
if not check_placeholders(en_placeholders, lang_placeholders):
issues.append(f"Placeholder mismatch at '{current_path}': '{lang_data[key]}' - found {lang_placeholders}; expected {en_placeholders}")
return issues

def main():
Expand Down

0 comments on commit adfc5c4

Please sign in to comment.