summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 07:29:50 +0000
committerglotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 07:29:50 +0000
commitea477c25a06ac425257f1a94081aaca98929ab0f (patch)
treec0f1dcf6bbed9e88313e98c505001a09a4f7e1dd
parente49d15f77fda6244a958f37d8998bedc73295c3a (diff)
downloadchromium_src-ea477c25a06ac425257f1a94081aaca98929ab0f.zip
chromium_src-ea477c25a06ac425257f1a94081aaca98929ab0f.tar.gz
chromium_src-ea477c25a06ac425257f1a94081aaca98929ab0f.tar.bz2
Fix of the initial locale set.
(second try, now with unittest) BUG=35248 TEST=Switch the language used by the ChromiumOS using the top left corner menu of the Network selection wizard. Or you may use the following command on desktop using Chromium (built with GYP_DEFINES="chromeos=1"): out/Debug/chrome --login-manager --login-screen=network Check that the next time you start chromium, the selected language will be the default. Review URL: http://codereview.chromium.org/982005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41817 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/l10n_util.cc7
-rw-r--r--app/l10n_util_unittest.cc21
2 files changed, 23 insertions, 5 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc
index 727fe25..96659f8 100644
--- a/app/l10n_util.cc
+++ b/app/l10n_util.cc
@@ -464,6 +464,13 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) {
// Next, try the system locale.
candidates.push_back(system_locale);
+
+#elif defined(OS_CHROMEOS)
+ // On ChromeOS, try user prefs. This restores the locale used by the
+ // previous run of the OS.
+ if (!pref_locale.empty())
+ candidates.push_back(WideToASCII(pref_locale));
+
#elif defined(OS_POSIX)
// On POSIX, we also check LANGUAGE environment variable, which is supported
// by gettext to specify a priority list of prefered languages.
diff --git a/app/l10n_util_unittest.cc b/app/l10n_util_unittest.cc
index bd55ff9..cd299d1 100644
--- a/app/l10n_util_unittest.cc
+++ b/app/l10n_util_unittest.cc
@@ -141,7 +141,7 @@ TEST_F(L10nUtilTest, GetAppLocale) {
// Keep a copy of ICU's default locale before we overwrite it.
icu::Locale locale = icu::Locale::getDefault();
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) && !defined(OS_CHROMEOS)
// Test the support of LANGUAGE environment variable.
SetICUDefaultLocale("en-US");
::setenv("LANGUAGE", "xx:fr_CA", 1);
@@ -166,20 +166,30 @@ TEST_F(L10nUtilTest, GetAppLocale) {
// Make sure the follow tests won't be affected by LANGUAGE environment
// variable.
::unsetenv("LANGUAGE");
-#endif
+#endif // defined(OS_POSIX) && !defined(OS_CHROMEOS)
SetICUDefaultLocale("en-US");
EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("xx");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
+
+#if defined(OS_CHROMEOS)
+ // ChromeOS honors preferred locale first in GetApplicationLocale(),
+ // defaulting to en-US, while other targets first honor other signals.
+ SetICUDefaultLocale("en-GB");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
+
+ SetICUDefaultLocale("en-US");
+ EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"en-GB"));
+
+#else // defined(OS_CHROMEOS)
SetICUDefaultLocale("en-GB");
EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L""));
SetICUDefaultLocale("fr-CA");
EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale("xx");
- EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
-
SetICUDefaultLocale("es-MX");
EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L""));
@@ -200,6 +210,7 @@ TEST_F(L10nUtilTest, GetAppLocale) {
SetICUDefaultLocale("zh-SG");
EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L""));
+#endif // defined (OS_CHROMEOS)
#if defined(OS_WIN)
// We don't allow user prefs for locale on linux/mac.