Skip to content

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

Merged
russellwheatley merged 4 commits into
version-10.0.0-beta04from
fix/1613-translation-char-limit
Jul 27, 2026
Merged

fix(internal): append CHAR_LIMIT to translation descriptions in export script#2417
russellwheatley merged 4 commits into
version-10.0.0-beta04from
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

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

Copy link
Copy Markdown
Contributor

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 Outdated
Comment thread scripts/translations/export_translations.py
…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.
@just1and0
just1and0 changed the base branch from master to version-10.0.0-beta04 July 24, 2026 09:45
@demolaf

demolaf commented Jul 24, 2026

Copy link
Copy Markdown
Member

Did a second pass with an agent, maybe worth checking?

Comment:

_extract_visible_text only trims the outer edges, so internal newlines/indentation from wrapped multi-line <string> tags get counted as visible characters — e.g. fui_welcome_back_idp_prompt comes out to CHAR_LIMIT=100 when the actual rendered text is ~56 chars (limit should be ~85). Worth collapsing internal whitespace (e.g. re.sub(r'\s+', ' ', text).strip()) before measuring length, since inflated limits defeat the purpose of this PR for exactly the long/wrapped strings where an accurate limit matters most.

@just1and0
just1and0 force-pushed the fix/1613-translation-char-limit branch from e510af5 to 466f2b7 Compare July 24, 2026 10:14

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple of bits of feedback on the char limit calc

Comment thread scripts/translations/export_translations.py
Comment thread scripts/translations/export_translations.py Outdated
Comment thread scripts/translations/export_translations.py Outdated
- Collapse whitespace runs to single space before measuring visible text
  length, matching Android's rendering behavior
- Scope CHAR_LIMIT existence check to translation_description attribute
  only, preventing false matches in nested xliff:g descriptions
- Use single-pass regex for XML entity decoding to avoid mangling
  double-encoded entities like &amp;lt;

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All review feedback has been addressed. CI is green across the board. LGTM.

@russellwheatley
russellwheatley merged commit d7be7ea into version-10.0.0-beta04 Jul 27, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in studio-2394994192-60a69 Jul 27, 2026
@russellwheatley
russellwheatley deleted the fix/1613-translation-char-limit branch July 27, 2026 10:43
demolaf added a commit that referenced this pull request Jul 29, 2026
…2404)

* fix(auth): validate display name only when required in sign-up form (#2383)

* fix(auth): validate display name only when required in sign-up form

* fix(auth): use locale-safe matcher for sign-up button in test

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

Fixes #1613

* fix(auth): mitigate tapjacking on the auth activity window (#2416)

Fixes #2041

* sample(app): add Firestore, Database & Storage demos to sample app (#2406)

* fix(auth): allow customizing top app bar colors via AuthUITheme (#2391)

* fix(auth): handle edge-to-edge insets in MFA challenge and auth screens (#2413)

* fix(auth): use fixed padding for method picker provider buttons (#2424) (#2426)

* fix(firestore): catch InterruptedException in FirestorePagingSource

* fix(firestore): drop load error logging and restore rx error handler in test

* fix(firestore): return LoadResult.Error for every load failure instead of throwing

* fix(firestore): fix PageKey.equals NPE on null snapshots and add hashCode

* test(firestore): run paging source test in CI via robolectric and replace sleeps with latches

* fix(firestore): log genuine load failures while keeping cancellations silent

---------

Co-authored-by: Oluwatobi Shokunbi <ayoshokz@gmail.com>
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

3 participants