diff options
-rw-r--r-- | app/l10n_util.cc | 6 | ||||
-rw-r--r-- | chrome/browser/locale_tests_uitest.cc | 52 |
2 files changed, 52 insertions, 6 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc index 4cda0506..751a41c 100644 --- a/app/l10n_util.cc +++ b/app/l10n_util.cc @@ -233,6 +233,11 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) { PathService::Get(app::DIR_LOCALES, &locale_path); std::string resolved_locale; + // We only use --lang and the app pref on Windows. On Linux/Mac, we only + // look at the LC_*/LANG environment variables. We do, however, pass --lang + // to renderer and plugin processes so they know what language the parent + // process decided to use. +#if defined(OS_WIN) // First, check to see if there's a --lang flag. const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); const std::string& lang_arg = WideToASCII( @@ -248,6 +253,7 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) { locale_path, &resolved_locale)) return resolved_locale; } +#endif // Next, try the system locale. const std::string system_locale = GetSystemLocale(); diff --git a/chrome/browser/locale_tests_uitest.cc b/chrome/browser/locale_tests_uitest.cc index eaebe3c..808ecae 100644 --- a/chrome/browser/locale_tests_uitest.cc +++ b/chrome/browser/locale_tests_uitest.cc @@ -4,24 +4,61 @@ #include "chrome/test/ui/ui_test.h" -class LocaleTestsDa : public UITest { +#include "build/build_config.h" + +class LocaleTestsBase : public UITest { public: - LocaleTestsDa() : UITest() { + LocaleTestsBase() : UITest(), old_lc_all_(NULL) { + } + + protected: + void RestoreLcAllEnvironment() { +#if defined(OS_LINUX) + if (old_lc_all_) { + setenv("LC_ALL", old_lc_all_, 1); + } else { + unsetenv("LC_ALL"); + } +#endif + }; + + const char* old_lc_all_; +}; + + +class LocaleTestsDa : public LocaleTestsBase { + public: + LocaleTestsDa() : LocaleTestsBase() { launch_arguments_.AppendSwitchWithValue(L"lang", L"da"); + + // Linux doesn't use --lang, it only uses environment variables to set the + // language. +#if defined(OS_LINUX) + old_lc_all_ = getenv("LC_ALL"); + setenv("LC_ALL", "da_DK.UTF-8", 1); +#endif } }; -class LocaleTestsHe : public UITest { +class LocaleTestsHe : public LocaleTestsBase { public: - LocaleTestsHe() : UITest() { + LocaleTestsHe() : LocaleTestsBase() { launch_arguments_.AppendSwitchWithValue(L"lang", L"he"); +#if defined(OS_LINUX) + old_lc_all_ = getenv("LC_ALL"); + setenv("LC_ALL", "he_IL.UTF-8", 1); +#endif } }; -class LocaleTestsZhTw : public UITest { +class LocaleTestsZhTw : public LocaleTestsBase { public: - LocaleTestsZhTw() : UITest() { + LocaleTestsZhTw() : LocaleTestsBase() { launch_arguments_.AppendSwitchWithValue(L"lang", L"zh-TW"); +#if defined(OS_LINUX) + old_lc_all_ = getenv("LC_ALL"); + setenv("LC_ALL", "zh_TW.UTF-8", 1); +#endif } }; @@ -30,13 +67,16 @@ class LocaleTestsZhTw : public UITest { // See bug 9758. TEST_F(LocaleTestsDa, TestStart) { // Just making sure we can start/shutdown cleanly. + RestoreLcAllEnvironment(); } TEST_F(LocaleTestsHe, TestStart) { // Just making sure we can start/shutdown cleanly. + RestoreLcAllEnvironment(); } TEST_F(LocaleTestsZhTw, TestStart) { // Just making sure we can start/shutdown cleanly. + RestoreLcAllEnvironment(); } #endif |