Repository navigation
fix(core): check every i18n attribute translation for ICUs - #71389
Merged
Merged
Conversation
`ICU_REGEXP` is only used with `.test()` but carried the `g` flag, so a match left `lastIndex` past the ICU. The check is followed by a throw, so the regex was never reset, and the next attribute message was searched from that offset. A shorter translation containing an ICU then passed the check and rendered instead of throwing. Dropping the `g` flag makes each check start at index 0.
JeanMeche
approved these changes
Oct 22, 2026
Member
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.
PR Checklist
PR Type
What is the current behavior?
i18nAttributesFirstPassrejects attribute translations that contain an ICU:Because of the
gflag, a successfultest()leaveslastIndexat the end of the match. That success is always followed by the throw, so nothing resets it. The next attribute message is then searched from that offset. If it is shorter, the ICU is skipped,test()returnsfalse, and the translation renders instead of throwing.ICU_REGEXPhas no other use in the file, so nothing depends on thegflag.What is the new behavior?
The
gflag is dropped, so every check starts at index 0 and every attribute ICU is rejected.Tests
Added a case under
invalid translations handlinginacceptance/i18n_spec.ts. It renders a long title whose translation has an ICU, then a short one.I couldn't run Bazel locally, so I reproduced the same scenario against the published
@angular/[email protected]bundle with the realloadTranslations+ TestBed:/gi)/iDoes this PR introduce a breaking change?