i18n: support reusing the same placeholder for ICU#16159
Merged
connorjclark merged 2 commits intomainfrom Aug 23, 2024
Merged
Conversation
adamraine
approved these changes
Aug 22, 2024
copybara-service bot
pushed a commit
to ChromeDevTools/devtools-frontend
that referenced
this pull request
Aug 23, 2024
This patches in a change from upstream: GoogleChrome/lighthouse#16159 See the above PR for details. Bug: None Change-Id: Id73070ec4c2b4ed5ff227d0a5d486416b67eb5a5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5807627 Commit-Queue: Simon Zünd <szuend@chromium.org> Reviewed-by: Adam Raine <asraine@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
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.
It can be useful to reuse the same ICU variable names in a i18n string. For example:
source
The above currently ends up with this in our ctc file:
"message": "Your local $ICU_0$ $ICU_1$ needs improvement and is rated the same as $ICU_3$ of real-user {PH1} experiences. However, the field data 75th percentile {PH1} $ICU_2$ is good."(this is wrong).We already support replacing multiple instances of a ICU variable: https://github.com/GoogleChrome/lighthouse/blob/c79628af9bdaa537a2abd1b34da922e28b81bd98/core/test/scripts/i18n/bake-ctc-to-lhl-test.js#L43C50-L60
But our collect strings step does not currently ever produce a ICU message string that reuses the same variable. For direct ICU (like the above example), it would just leave the
{PH1}literal as-is for subsequent instances. For the custom format one, it would create a new variable. This PR fixes both of those cases.internal links:
https://localizer.google.com/query/13584722