fix(internal): append CHAR_LIMIT to translation descriptions in export script#2417
Open
just1and0 wants to merge 2 commits into
Open
fix(internal): append CHAR_LIMIT to translation descriptions in export script#2417just1and0 wants to merge 2 commits into
just1and0 wants to merge 2 commits into
Conversation
…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.
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export_translations.pyto automatically append[CHAR_LIMIT=xxx]to eachtranslation_descriptionthat doesn't already have one<item>tags individually (each item gets its own limit)&→&) and Android escape sequences (\',\n,) before calculating visible text length[CHAR_LIMIT=...]valuesprintstatement for Python 3 compatibilityFixes #1613
Test plan
python3 scripts/translations/export_translations.pyand verify CHAR_LIMIT is appended to all descriptions with visible text[CHAR_LIMIT=...]are not modifiedfui_error_invalid_credentials) are correctly skipped