-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) O3-4339: Frontend should properly support locales with region specifiers #1264
Merged
Conversation
This file contains 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
Size Change: -93.6 kB (-1.49%) Total Size: 6.19 MB
ℹ️ View Unchanged
|
denniskigen
approved these changes
Jan 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks, @ibacher.
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.
Requirements
feat
,fix
, orchore
, among others). See existing PR titles for inspiration.For changes to apps
If applicable
Summary
This attempts to fix a couple of different issues bound up with how specifiers for locales with regions work. Per BCP 47, locales are expressed in the form
<ISO 639 Language Tag>[-<ISO 639 Region Tag>]
(the full spec is slightly more complicated; this is the part we care about), so, e.g.,en
represents "English" anden-GB
represents "British English".However, some tooling supports something like BCP 47 with underscores instead of hyphens as separators, representing "English" as
en
and "British English" asen_GB
. Because both formats agree on the representation of "English" (and the like) we hadn't really noticed until we actually got some translations that were sensitive to regional changes.It turns out that the stuff we have that deals with locales wasn't adapted for this change. Specifically:
en.json
anden_GB.json
, but when loading the translations, we use the "correct" BCP 47 tags, and so try to loaden-GB.json
. Since this doesn't resolve correctly, the frontend could never find region-specific translations.locale
property into the correct BCP 47 tag, but this doesn't work with the "defaultLocale" user property, which appears to get set to the the incorrect BCP 47 tag. Since the code tosetUserLanguage()
didn't correctly handle locales with underscores instead of hyphens, the user's locale would not be updated when configured to use a "defaultLocale" with a region specifierThis PR addresses both of those issues.
Screenshots
Related Issue
Other