-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Android native locale resolution algorithm #19266
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Locale preferredLocale = localeList.get(index); | ||
// Look for exact match. | ||
for (Locale locale : supportedLocales) { | ||
if (preferredLocale == locale) { |
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.
Is it safe to use ==
here instead of .equals
?
Locale preferredLocale = context.getResources().getConfiguration().locale; | ||
// Look for exact match. | ||
for (Locale locale : supportedLocales) { | ||
if (preferredLocale == locale) { |
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.
Also applies to use of ==
here
This pull request is not suitable for automatic merging in its current state.
|
LUCI failure is probably a flake. Landing. |
This implements Android's locale resolution algorithm as described in https://developer.android.com/guide/topics/resources/multilingual-support
Due to evolving API, there are 3 versions implemented:
This implementation attempts to exactly emulate what Android would have done given the same parameters.