Commit 2e6955cc authored by Fei Ling's avatar Fei Ling Committed by Commit Bot

Fix issue 1038319: Unable to change chrome language via...

Fix issue 1038319: Unable to change chrome language via chrome://settings/languages on Windows-Hebrew machine.

The problem is that the chrome installer uses the old language code for Hebrew, "iw",
instead of the new code "he". This value is saved in the user's local state. The
language model in langauges.js does not recognize this language code, thus the bug.

Fixed: 1038319
Change-Id: Ib227b2972989c2fa87fdc2d4be408040ad137c55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1990476Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Fei Ling <feiling@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732550}
parent 0a64a7ba
...@@ -1001,6 +1001,17 @@ Polymer({ ...@@ -1001,6 +1001,17 @@ Polymer({
return 'no'; return 'no';
} }
// The installer still uses the old language code "iw", instead of "he",
// for Hebrew. It needs to be converted to "he", otherwise it will not be
// found in supportedLanguageMap_.
//
// Note that this value is saved in the user's local state. Even
// if the installer is changed to use "he", because the installer does not
// overwrite this value, the conversion is still needed for old users.
if (languageCode == 'iw') {
return 'he';
}
// Match the characters before the hyphen. // Match the characters before the hyphen.
const result = languageCode.match(/^([^-]+)-?/); const result = languageCode.match(/^([^-]+)-?/);
assert(result.length == 2); assert(result.length == 2);
......
...@@ -114,7 +114,15 @@ cr.define('settings', function() { ...@@ -114,7 +114,15 @@ cr.define('settings', function() {
// ui/base/ime/chromeos/extension_ime_util.cc. // ui/base/ime/chromeos/extension_ime_util.cc.
code: '_arc_ime_language_', code: '_arc_ime_language_',
displayName: 'Keyboard apps', displayName: 'Keyboard apps',
} },
{
// Hebrew. This is used to test that the old language code "iw"
// still works.
code: 'he',
displayName: 'Hebrew',
nativeDisplayName: 'Hebrew',
supportsUI: true,
},
]; ];
/** @type {!Array<!chrome.languageSettingsPrivate.InputMethod>} */ /** @type {!Array<!chrome.languageSettingsPrivate.InputMethod>} */
......
...@@ -66,6 +66,20 @@ cr.define('settings-languages', function() { ...@@ -66,6 +66,20 @@ cr.define('settings-languages', function() {
// TODO(michaelpg): Test other aspects of the model. // TODO(michaelpg): Test other aspects of the model.
}); });
test('get language', function() {
// If a language code is not found, try language without location.
lang = languageHelper.getLanguage('en-CN');
assertEquals('en', lang.code);
// The old language code for Hebriew is supported.
lang = languageHelper.getLanguage('iw');
assertEquals('he', lang.code);
// The 'no' macrolanguage is returned for Norsk Nynorsk.
lang = languageHelper.getLanguage('nn');
assertEquals('no', lang.code);
});
test('modifying languages', function() { test('modifying languages', function() {
assertTrue(languageHelper.isLanguageEnabled('en-US')); assertTrue(languageHelper.isLanguageEnabled('en-US'));
assertTrue(languageHelper.isLanguageEnabled('sw')); assertTrue(languageHelper.isLanguageEnabled('sw'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment