Repository navigation
Conversation
|
Warning The target branch has been automatically set to Please Edit this PR if this wasn't your intention. |
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is straightforward, with only a non-blocking test-coverage improvement remaining.
1 open issue
What changed in this PR
Simplifies Android Components’ String.toLocale() helper by delegating language-tag parsing to the platform, supporting complex BCP-47 tags without custom splitting.
Changes:
- Normalizes underscores to hyphens and uses
Locale.forLanguageTag(). - Explicitly returns
Locale.ROOTfor blank input and documents supported formats. - Adds tests for language, region, script, Unicode-extension, and blank-input cases.
| File | Description |
|---|---|
| mobile/android/android-components/components/support/locale/src/test/java/mozilla/components/support/locale/ExtensionsTest.kt | Adds locale-conversion tests. |
| mobile/android/android-components/components/support/locale/src/main/java/mozilla/components/support/locale/Extensions.kt | Simplifies parsing and documents locale handling. |
Review effort: Balanced
…language tags Replaces custom string-splitting in `String.toLocale()` by normalizing underscores to hyphens and delegating to `Locale.forLanguageTag()`. This ensures language tags containing scripts, variants, or Unicode extensions are properly parsed, and returns `Locale.ROOT` for blank input strings.
|
No new issues detected. This pull request is 🆗 |
pollym
left a comment
There was a problem hiding this comment.
seems reasonable!
i can't reproduce the crash but looking at the code it seems like this is safer to try and normalise invalid locales rather than crashing. the unit tests fail without the new change. thanks for the fix!
…language tags r=pollymce Replaces custom string-splitting in `String.toLocale()` by normalizing underscores to hyphens and delegating to `Locale.forLanguageTag()`. This ensures language tags containing scripts, variants, or Unicode extensions are properly parsed, and returns `Locale.ROOT` for blank input strings. Pull request: #411
|
Pull request closed by commit f1d204e |
…language tags a=dmeehan Replaces custom string-splitting in `String.toLocale()` by normalizing underscores to hyphens and delegating to `Locale.forLanguageTag()`. This ensures language tags containing scripts, variants, or Unicode extensions are properly parsed, and returns `Locale.ROOT` for blank input strings. Pull request: #411 Differential Revision: https://phabricator.services.mozilla.com/D337099

Replaces custom string-splitting in
String.toLocale()by normalizing underscores to hyphens and delegating toLocale.forLanguageTag(). This ensures language tags containing scripts, variants, or Unicode extensions are properly parsed, and returnsLocale.ROOTfor blank input strings.Lando: link
Bugzilla: bug 2085210
🚫 This pull request has 1 blocker.