New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593515 link

Starred by 8 users

Issue metadata

Status: Fixed
Owner:
Email to this user bounced
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug

Blocked on:
issue 623989

Blocking:
issue 593511



Sign in to add a comment

Android: Android/WebView should use system locale priority as accept language.

Project Member Reported by nona@chromium.org, Mar 9 2016

Issue description

Version: 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.
 

Comment 1 by hush@chromium.org, Mar 10 2016

Cc: hush@chromium.org
See WebView implementation in AwContentBrowserClient::GetAcceptLangsImpl and 
AwContents::GetLocale
WebView as of now, only cares about the current locale, so Japanese is ignored. Not sure how you can get the secondary locale though. (Is there an API for that?)

Comment 2 by roozbeh@google.com, 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().

Comment 3 by hoil@google.com, 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.
device-2016-03-11-164731.png
941 KB View Download

Comment 4 by nona@chromium.org, Mar 23 2016

Status: Assigned (was: Started)
Back to assigned since new APIs are available from Android N so I need to wait SDK release.

Comment 5 by yukawa@chromium.org, 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

Comment 6 by torne@chromium.org, 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.

Comment 7 by yukawa@chromium.org, Jul 11 2016

Blockedon: 623989

Comment 8 by nona@chromium.org, Aug 26 2016

Cc: mihai@chromium.org groby@chromium.org tinazh@chromium.org ftang@chromium.org talo@chromium.org jrp@chromium.org egm@chromium.org lswartz@google.com
 Issue 616965  has been merged into this issue.

Comment 9 by js...@chromium.org, 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. 




Comment 10 by js...@chromium.org, Aug 26 2016

BTW, why does this bug (http accept-lang)  block  bug 593511  (about font-fallback)? 

Comment 11 by nona@chromium.org, 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.

Comment 12 by js...@chromium.org, 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). 

Comment 13 by js...@chromium.org, 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). 

Comment 14 by nona@chromium.org, 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.

Comment 15 by nona@chromium.org, Sep 27 2016

Cc: yirui@google.com

Comment 16 by nona@chromium.org, Sep 27 2016

Owner: yirui@google.com
Project Member

Comment 17 by bugdroid1@chromium.org, Oct 11 2016

Project Member

Comment 18 by bugdroid1@chromium.org, 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

Project Member

Comment 19 by bugdroid1@chromium.org, 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

Comment 20 by yirui@google.com, Nov 10 2016

Status: Fixed (was: Assigned)
Multiple languages are available on both Chrome and Webview in Android N now :) 

Comment 21 by kojii@chromium.org, Nov 10 2016

Yay, thank you for the great work!

Comment 22 by yirui@google.com, Nov 11 2016

Status: Started (was: Fixed)
It turns out Webview is not ready for taking a comma separated string.
Need more work on this. 

Comment 23 by torne@chromium.org, 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.
Project Member

Comment 24 by bugdroid1@chromium.org, 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

Project Member

Comment 25 by bugdroid1@chromium.org, 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

Comment 26 by yirui@google.com, Nov 18 2016

Status: Fixed (was: Started)

Comment 27 by kojii@chromium.org, Nov 18 2016

Great work, thank you.

Comment 28 by nona@chromium.org, Nov 18 2016

Cc: -jrp@chromium.org -mihai@chromium.org jrp@google.com mihai@google.com

Sign in to add a comment