Android: Android/WebView should use system locale priority as accept language. |
||||||||||
Issue descriptionVersion: all OS: Android N Preview (NPC56P) or later. What steps will reproduce the problem? 1. Go Settings -> Language & input -> Language 2. Set "English (United States)" as the primary language, and "Japanese (Japan)" as the secondary language. 3. Go some web page and see the accept language header. What is the expected output? What do you see instead? Expected: The accept language should contains Japanese. Actual: Only en-US,en is listed. Please use labels and text to provide additional information.
,
Mar 10 2016
There are two APIs to get the whole list of locales (there may be more than two). LocaleList.getDefault() would give you the locale list in the order the user prefers them. LocaleList.getAdjustedDefault() would give you the same locale list, with the locale the system chose for the app (based on the locales the app supports) moved to the front of the list. So for Accept-Language, I believe you should use LocaleList.getDefault().
,
Mar 11 2016
I have a similar issue. I have chosen "Chinese (Hong Kong)" as my system language on Android. However, when I visit a site using Traditional Chinese (which is what Hong Kong use), it will ask if I want to translate from "Traditional Chinese" to "English" using a Chinese message.
,
Mar 23 2016
Back to assigned since new APIs are available from Android N so I need to wait SDK release.
,
Jun 16 2016
Just as a heads up, the Android N final SDK is now available. http://android-developers.blogspot.com/2016/06/android-n-apis-are-now-final.html
,
Jun 16 2016
Yup, once the new SDK is checked in upstream, we can upstream the N changes for WebView, and then we can look at working on/landing these features.
,
Jul 11 2016
,
Aug 26 2016
Issue 616965 has been merged into this issue.
,
Aug 26 2016
Thanks, nona@ Is there a bug filed about selecting the best-match UI language given the list of UI languages supported by Chrome AND the OS-level ordered-list of preferred languages (new feature in N)? I"m pretty sure that I've seen one filed, but couldn't find it.
,
Aug 26 2016
BTW, why does this bug (http accept-lang) block bug 593511 (about font-fallback)?
,
Aug 29 2016
>9 I'm sorry I don't have any idea now. If my understanding is correct, the locale-list based UI resources fallback is done by Android framework, so I think there is nothing to do in Chrome. Page language detection could be improved by using locale list but I also don't have any information for this at this moment, sorry. >10 The multi-locale based font fallback uses the same source of the Accept-Language header. By fixing this issue, there is nothing to do for the bug 593511 , but just in case I tracked the issue separately. Once this issue is fixed, I'm going to verify the locale based fallback issue too.
,
Aug 29 2016
> I'm sorry I don't have any idea now. If my understanding is correct, the > locale-list based UI resources fallback is done by Android framework, so > I think there is nothing to do in Chrome. You're absolutely right ! In the past, it was not the case (afaik), but it is the case now, which is very nice ! I played with it and it works fine except for bug 641852 (zh-Hant cannot be selected at all. It falls back to English UI.) > The multi-locale based font fallback uses the same source of the Accept-Language > header. By fixing this issue, Thanks for the explanation ! (I didn't realize that A-L is already taken into account in Blink's font fallback).
,
Aug 29 2016
re: comment 11 > Page language detection could be improved by using locale list but I also don't > have any information for this at this moment, sorry. CLD can take a 'hint' (but I don't think it can take a 'hint' in the form of preferred language list). CED for encoding detection can also benefit from this, but again it does not take a ordered list of languages as a 'hint', either. Anyway, that should be a separate issue (enhancement).
,
Sep 26 2016
I'd like to pass this issue to yirui@ as a part of intern project. For the timeline, we are still waiting for SDK roll. There are lots of progress on the SDK roll but looks like it is bit late to fix this issue in the current miilestone. We are going to target this in the next milestone.
,
Sep 27 2016
,
Sep 27 2016
,
Oct 11 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6cc907c7b494642fe93ee850439ad816998e21e3 commit 6cc907c7b494642fe93ee850439ad816998e21e3 Author: yirui <yirui@google.com> Date: Tue Oct 11 05:03:44 2016 Support multiple locales string for accept language list This patch enables PrependToAcceptLanuagesIfNecessary to take multi-locale string. This is a preparation for supporting multi-locale feature from Android N. This patch does not break any existing behaviors. BUG= 593515 Review-Url: https://codereview.chromium.org/2393673003 Cr-Commit-Position: refs/heads/master@{#424372} [modify] https://crrev.com/6cc907c7b494642fe93ee850439ad816998e21e3/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsClientImpl.java [modify] https://crrev.com/6cc907c7b494642fe93ee850439ad816998e21e3/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/PwsClientImplTest.java [modify] https://crrev.com/6cc907c7b494642fe93ee850439ad816998e21e3/chrome/browser/android/preferences/pref_service_bridge.cc [modify] https://crrev.com/6cc907c7b494642fe93ee850439ad816998e21e3/chrome/browser/android/preferences/pref_service_bridge_unittest.cc
,
Oct 28 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9174164b690d246b72273cb4df448224ed8c4f7e commit 9174164b690d246b72273cb4df448224ed8c4f7e Author: yirui <yirui@google.com> Date: Fri Oct 28 04:29:59 2016 Use BCP47 compliant format for locale representation. Locale.toString() is not a interchangeable representation. Locale.toLanguageTag should be used for obtaining a value in IETF BCP47 language tag representation. However, toLanguageTag does not work on Android M and before. Thereofore, we use a self-implementation for converting Locale object to BCP47 compliant format string in that situation. Similarly, Locale.forLanguageTag should be used for constructing Locale object from BCP47 String representation of locales. However, this is not available on Android L and before. Thus, we introduce self-implementation for backward compatibility. This CL also includes: - Renaming getDefaultLocale to getDefaultLocaleString. This leads to function name changes in related files. - Adding methods for switching language code between Chrome and Android. - Adding methods for returning a locale with updated language code for Chrome or Android. BUG= 593515 Review-Url: https://codereview.chromium.org/2406203002 Cr-Commit-Position: refs/heads/master@{#428281} [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/android_webview/browser/aw_browser_main_parts.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/android_webview/browser/aw_content_browser_client.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/android_webview/java/src/org/chromium/android_webview/AwContents.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/android_webview/javatests/src/org/chromium/android_webview/test/AcceptLanguageTest.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/android_webview/native/aw_contents.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/base/BUILD.gn [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/base/android/java/src/org/chromium/base/LocaleUtils.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/base/android/java/src/org/chromium/base/ResourceExtractor.java [add] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/base/android/junit/src/org/chromium/base/LocaleUtilsTest.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/base/android/locale_utils.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/base/android/locale_utils.h [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivitySessionTracker.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsClientImpl.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/PwsClientImplTest.java [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/chrome/browser/android/preferences/pref_service_bridge.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/chrome/browser/android/preferences/pref_service_bridge_unittest.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/chromecast/browser/cast_http_user_agent_settings.cc [modify] https://crrev.com/9174164b690d246b72273cb4df448224ed8c4f7e/ui/base/l10n/l10n_util.cc
,
Nov 10 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9112d68d3d59f500ecd45e128337576aedaf5e64 commit 9112d68d3d59f500ecd45e128337576aedaf5e64 Author: yirui <yirui@google.com> Date: Thu Nov 10 01:13:33 2016 Use LocaleList in Android/Webview locale representation From Android N, uses are able to select multiple languages in system Settings. This CL provides supports for multi-locales features for Chrome and System WebView. This does not breaking behaviours on Andriod M and before. Since toLanguageTags in LocaleList does not convert Android language "tl"(Tagalog) to Chromium language "fil"(Filipino), an update for toLanguageTags is added. BUG= 593515 Review-Url: https://codereview.chromium.org/2481293004 Cr-Commit-Position: refs/heads/master@{#431128} [modify] https://crrev.com/9112d68d3d59f500ecd45e128337576aedaf5e64/android_webview/java/src/org/chromium/android_webview/AwContents.java [modify] https://crrev.com/9112d68d3d59f500ecd45e128337576aedaf5e64/base/BUILD.gn [modify] https://crrev.com/9112d68d3d59f500ecd45e128337576aedaf5e64/base/android/java/src/org/chromium/base/LocaleUtils.java [add] https://crrev.com/9112d68d3d59f500ecd45e128337576aedaf5e64/base/android/javatests/src/org/chromium/base/LocaleUtilsTest.java [delete] https://crrev.com/7d2b4d912a075113130dda064f1f4fd52f54d2f3/base/android/junit/src/org/chromium/base/LocaleUtilsTest.java
,
Nov 10 2016
Multiple languages are available on both Chrome and Webview in Android N now :)
,
Nov 10 2016
Yay, thank you for the great work!
,
Nov 11 2016
It turns out Webview is not ready for taking a comma separated string. Need more work on this.
,
Nov 11 2016
If WebView's code path is different here, can you add an integration test for this in WebView (using the test webserver, or whatever else is appropriate) when you come to reland.
,
Nov 12 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/ebbf8296f0b098a9f7aee2245d38170795821bbd commit ebbf8296f0b098a9f7aee2245d38170795821bbd Author: yirui <yirui@google.com> Date: Sat Nov 12 04:31:37 2016 Stop passing unsupported locale string to Android Webview It turns out that AwContents.setLocale is not fully ready to accept a comma separate locale string. Locale propagation is different between Android Webview and Android Chrome Browser. This is a partial revert of https://crrev.com/9112d68d3d59f500ecd45e128337576aedaf5e64 since a comma separated locale string works fine on Chrome browser. BUG= 593515 Review-Url: https://codereview.chromium.org/2488343003 Cr-Commit-Position: refs/heads/master@{#431768} [modify] https://crrev.com/ebbf8296f0b098a9f7aee2245d38170795821bbd/android_webview/java/src/org/chromium/android_webview/AwContents.java
,
Nov 18 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc commit 12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc Author: yirui <yirui@google.com> Date: Fri Nov 18 02:59:45 2016 Use GetDefaultLocaleListString for returning LocaleList Reverted GetDefaultLocaleString for returning a single default locale. Added GetDefaultLocaleString for getting a default LocaleList when it is Android N or after and a single default locale otherwise. By doing so, existing behaviors will be maintained. Accept languages in both Chrome and Webview are able to take a locale list. However, detailed changes in Webview are required, such as GetApplicationLocale in aw_content_browser_client.cc, so that Webview will be fully ready to take a locale list. BUG= 593515 Review-Url: https://codereview.chromium.org/2496183002 Cr-Commit-Position: refs/heads/master@{#433037} [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/browser/aw_content_browser_client.cc [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/browser/aw_locale_manager.h [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/java/src/org/chromium/android_webview/AwContents.java [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/javatests/src/org/chromium/android_webview/test/AcceptLanguageTest.java [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/native/aw_contents.cc [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/native/aw_contents.h [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/native/aw_locale_manager_impl.cc [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/android_webview/native/aw_locale_manager_impl.h [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/base/android/java/src/org/chromium/base/LocaleUtils.java [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivitySessionTracker.java [modify] https://crrev.com/12d0a4bb3cc3ab1f715c06f11421f24d3c2bc9fc/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsClientImpl.java
,
Nov 18 2016
,
Nov 18 2016
Great work, thank you.
,
Nov 18 2016
|
||||||||||
►
Sign in to add a comment |
||||||||||
Comment 1 by hush@chromium.org
, Mar 10 2016