Skip to content
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

Merged
merged 26 commits into from
Jun 26, 2020
Merged

Conversation

GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Jun 24, 2020

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:

  • API 26+: Modern algorithm using LanguageRange
  • API 24-25: Modern algorithm using manual/custom comparison
  • API < 24: Legacy algorithm

This implementation attempts to exactly emulate what Android would have done given the same parameters.

@fluttergithubbot
Copy link
Contributor

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) {
Copy link
Member

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) {
Copy link
Member

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

@GaryQian GaryQian added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jun 25, 2020
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite build_and_test_linux_release has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jun 26, 2020
@GaryQian GaryQian added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jun 26, 2020
@GaryQian
Copy link
Contributor Author

LUCI failure is probably a flake. Landing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes platform-android waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
4 participants