Skip to content

Handle malformed language tags and ensure fallback to en-001#3241

Merged
Oleksandr Karpovich (eymar) merged 1 commit into
jb-mainfrom
ok/fix_locale_current_web
Jul 21, 2026
Merged

Handle malformed language tags and ensure fallback to en-001#3241
Oleksandr Karpovich (eymar) merged 1 commit into
jb-mainfrom
ok/fix_locale_current_web

Conversation

@eymar

Copy link
Copy Markdown
Member

Fixes https://youtrack.jetbrains.com/issue/CMP-10359

Testing

  • Added new tests
  • This should be tested by QA

Release Notes

Fixes - Web

  • Introduce a fallback locale and handle malformed language tags

// Used when the browser reports no usable preferred language, so that Locale.current always
// returns at least one locale as required by PlatformLocaleDelegate's contract.
// The locale code en-001 denotes the English language spoken in the World.
private const val FALLBACK_LANGUAGE_TAG = "en-001"

Choose a reason for hiding this comment

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

This is going to be a stupid question but I have to ask - is it per spec? Can we be sure that this fallback value won't throw Exception in some browser?

@eymar Oleksandr Karpovich (eymar) Jul 21, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes. en-001 conforms the BCP-47 spec. 001 means "World", not country-specific.
https://www.localeplanet.com/icu/en-001/index.html

@eymar
Oleksandr Karpovich (eymar) merged commit 4602af0 into jb-main Jul 21, 2026
23 checks passed
@eymar
Oleksandr Karpovich (eymar) deleted the ok/fix_locale_current_web branch July 21, 2026 11:53
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.

2 participants