Skip to content

fix(internal): append CHAR_LIMIT to translation descriptions in export script#2417

Open
just1and0 wants to merge 2 commits into
masterfrom
fix/1613-translation-char-limit
Open

fix(internal): append CHAR_LIMIT to translation descriptions in export script#2417
just1and0 wants to merge 2 commits into
masterfrom
fix/1613-translation-char-limit

Conversation

@just1and0

Copy link
Copy Markdown
Contributor

Summary

  • Updates export_translations.py to automatically append [CHAR_LIMIT=xxx] to each translation_description that doesn't already have one
  • Limit defaults to ~1.5x the English string length, rounded up to the nearest 5
  • Handles plurals <item> tags individually (each item gets its own limit)
  • Decodes XML entities (&amp;&) and Android escape sequences (\', \n,  ) before calculating visible text length
  • Preserves existing manually-set [CHAR_LIMIT=...] values
  • Fixes Python 2 print statement for Python 3 compatibility

Fixes #1613

Test plan

  • Run python3 scripts/translations/export_translations.py and verify CHAR_LIMIT is appended to all descriptions with visible text
  • Verify strings with existing [CHAR_LIMIT=...] are not modified
  • Verify empty override strings (e.g. fui_error_invalid_credentials) are correctly skipped
  • Verify plurals items each get their own CHAR_LIMIT

…t script

Fixes #1613 by updating the export_translations script to automatically
calculate and append [CHAR_LIMIT=xxx] to each translation_description
that doesn't already have one. The limit defaults to ~1.5x the English
string length, rounded up to the nearest 5. Also fixes Python 2 print
statement for Python 3 compatibility.
…t script

Fixes #1613 by updating the export_translations script to automatically
calculate and append [CHAR_LIMIT=xxx] to each translation_description
that doesn't already have one. The limit defaults to ~1.5x the English
string length, rounded up to the nearest 5. Handles plurals items
individually, decodes XML entities and Android escape sequences for
accurate length calculation, and preserves existing manual limits.
Also fixes Python 2 print statement for Python 3 compatibility.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the translation export script to automatically calculate and append character limits ([CHAR_LIMIT=xxx]) to translation descriptions. It introduces utility functions to strip XML tags, decode entities, and calculate the character limit based on the English text length. Feedback on these changes highlights opportunities to make the regular expressions more robust. Specifically, simplifying the string and item value patterns using re.DOTALL will prevent failures on other formatting tags, and using re.sub for plurals will correctly handle multi-line <item> tags.

Comment thread scripts/translations/export_translations.py
Comment thread scripts/translations/export_translations.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translation script needs to be updated

1 participant