diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/l10n_util.cc | 12 | ||||
-rw-r--r-- | app/l10n_util.h | 2 | ||||
-rw-r--r-- | app/l10n_util_unittest.cc | 66 | ||||
-rw-r--r-- | app/resource_bundle.cc | 4 | ||||
-rw-r--r-- | app/resource_bundle.h | 6 | ||||
-rw-r--r-- | app/resource_bundle_dummy.cc | 2 | ||||
-rw-r--r-- | app/resource_bundle_posix.cc | 2 | ||||
-rw-r--r-- | app/resource_bundle_win.cc | 2 | ||||
-rw-r--r-- | app/test_suite.h | 2 |
9 files changed, 48 insertions, 50 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc index 0837c02..7b8ceb3 100644 --- a/app/l10n_util.cc +++ b/app/l10n_util.cc @@ -366,9 +366,8 @@ void SplitAndNormalizeLanguageList(const std::string& env_language, namespace l10n_util { -std::string GetApplicationLocale(const std::wstring& pref_locale) { +std::string GetApplicationLocale(const std::string& pref_locale) { #if !defined(OS_MACOSX) - FilePath locale_path; PathService::Get(app::DIR_LOCALES, &locale_path); std::string resolved_locale; @@ -382,7 +381,7 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) { #if defined(OS_WIN) // First, try the preference value. if (!pref_locale.empty()) - candidates.push_back(WideToASCII(pref_locale)); + candidates.push_back(pref_locale); // Next, try the system locale. candidates.push_back(system_locale); @@ -390,7 +389,7 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) { #elif defined(OS_CHROMEOS) // On ChromeOS, use the application locale preference. if (!pref_locale.empty()) - candidates.push_back(WideToASCII(pref_locale)); + candidates.push_back(pref_locale); #elif defined(OS_POSIX) // On POSIX, we also check LANGUAGE environment variable, which is supported @@ -432,9 +431,8 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) { // Use any override (Cocoa for the browser), otherwise use the preference // passed to the function. std::string app_locale = l10n_util::GetLocaleOverride(); - if (app_locale.empty()) { - app_locale = WideToASCII(pref_locale); - } + if (app_locale.empty()) + app_locale = pref_locale; // The above should handle all of the cases Chrome normally hits, but for some // unit tests, we need something to fall back too. diff --git a/app/l10n_util.h b/app/l10n_util.h index 7f7b18a..62789a9 100644 --- a/app/l10n_util.h +++ b/app/l10n_util.h @@ -39,7 +39,7 @@ namespace l10n_util { // as |pref_locale|), finally, we fall back on the system locale. We only return // a value if there's a corresponding resource DLL for the locale. Otherwise, // we fall back to en-us. -std::string GetApplicationLocale(const std::wstring& pref_locale); +std::string GetApplicationLocale(const std::string& pref_locale); // Given a locale code, return true if the OS is capable of supporting it. // For instance, Oriya is not well supported on Windows XP and we return diff --git a/app/l10n_util_unittest.cc b/app/l10n_util_unittest.cc index 0625154..9106ee2 100644 --- a/app/l10n_util_unittest.cc +++ b/app/l10n_util_unittest.cc @@ -145,23 +145,23 @@ TEST_F(L10nUtilTest, GetAppLocale) { // Test the support of LANGUAGE environment variable. SetICUDefaultLocale("en-US"); env->SetEnv("LANGUAGE", "xx:fr_CA"); - EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("fr", l10n_util::GetApplicationLocale("")); env->SetEnv("LANGUAGE", "xx:yy:en_gb.utf-8@quot"); - EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("")); env->SetEnv("LANGUAGE", "xx:zh-hk"); - EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale("")); // We emulate gettext's behavior here, which ignores LANG/LC_MESSAGES/LC_ALL // when LANGUAGE is specified. If no language specified in LANGUAGE is valid, // then just fallback to the default language, which is en-US for us. SetICUDefaultLocale("fr-FR"); env->SetEnv("LANGUAGE", "xx:yy"); - EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); env->SetEnv("LANGUAGE", "/fr:zh_CN"); - EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale("")); // Make sure the follow tests won't be affected by LANGUAGE environment // variable. @@ -169,86 +169,86 @@ TEST_F(L10nUtilTest, GetAppLocale) { #endif // defined(OS_POSIX) && !defined(OS_CHROMEOS) SetICUDefaultLocale("en-US"); - EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("xx"); - EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); #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"")); + EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("en-US"); - EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"en-GB")); + EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("en-GB")); #else // defined(OS_CHROMEOS) SetICUDefaultLocale("en-GB"); - EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("fr-CA"); - EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("fr", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("es-MX"); - EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("es-419", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("es-AR"); - EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("es-419", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("es-ES"); - EXPECT_EQ("es", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("es", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("es"); - EXPECT_EQ("es", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("es", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("zh-HK"); - EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("zh-MK"); - EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("zh-SG"); - EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale("")); #endif // defined (OS_CHROMEOS) #if defined(OS_WIN) // We don't allow user prefs for locale on linux/mac. SetICUDefaultLocale("en-US"); - EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"fr")); - EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"fr-CA")); + EXPECT_EQ("fr", l10n_util::GetApplicationLocale("fr")); + EXPECT_EQ("fr", l10n_util::GetApplicationLocale("fr-CA")); SetICUDefaultLocale("en-US"); // Aliases iw, no, tl to he, nb, fil. - EXPECT_EQ("he", l10n_util::GetApplicationLocale(L"iw")); - EXPECT_EQ("nb", l10n_util::GetApplicationLocale(L"no")); - EXPECT_EQ("fil", l10n_util::GetApplicationLocale(L"tl")); + EXPECT_EQ("he", l10n_util::GetApplicationLocale("iw")); + EXPECT_EQ("nb", l10n_util::GetApplicationLocale("no")); + EXPECT_EQ("fil", l10n_util::GetApplicationLocale("tl")); // es-419 and es-XX (where XX is not Spain) should be // mapped to es-419 (Latin American Spanish). - EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L"es-419")); - EXPECT_EQ("es", l10n_util::GetApplicationLocale(L"es-ES")); - EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L"es-AR")); + EXPECT_EQ("es-419", l10n_util::GetApplicationLocale("es-419")); + EXPECT_EQ("es", l10n_util::GetApplicationLocale("es-ES")); + EXPECT_EQ("es-419", l10n_util::GetApplicationLocale("es-AR")); SetICUDefaultLocale("es-AR"); - EXPECT_EQ("es", l10n_util::GetApplicationLocale(L"es")); + EXPECT_EQ("es", l10n_util::GetApplicationLocale("es")); SetICUDefaultLocale("zh-HK"); - EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L"zh-CN")); + EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale("zh-CN")); SetICUDefaultLocale("he"); - EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"en")); + EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("en")); // Amharic should be blocked unless OS is Vista or newer. if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { SetICUDefaultLocale("am"); - EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("en-GB"); - EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"am")); + EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("am")); } else { SetICUDefaultLocale("am"); - EXPECT_EQ("am", l10n_util::GetApplicationLocale(L"")); + EXPECT_EQ("am", l10n_util::GetApplicationLocale("")); SetICUDefaultLocale("en-GB"); - EXPECT_EQ("am", l10n_util::GetApplicationLocale(L"am")); + EXPECT_EQ("am", l10n_util::GetApplicationLocale("am")); } #endif // defined(OS_WIN) diff --git a/app/resource_bundle.cc b/app/resource_bundle.cc index c125907..25b0d81 100644 --- a/app/resource_bundle.cc +++ b/app/resource_bundle.cc @@ -37,7 +37,7 @@ const SkColor ResourceBundle::toolbar_separator_color = /* static */ std::string ResourceBundle::InitSharedInstance( - const std::wstring& pref_locale) { + const std::string& pref_locale) { DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; g_shared_instance_ = new ResourceBundle(); @@ -47,7 +47,7 @@ std::string ResourceBundle::InitSharedInstance( /* static */ std::string ResourceBundle::ReloadSharedInstance( - const std::wstring& pref_locale) { + const std::string& pref_locale) { DCHECK(g_shared_instance_ != NULL) << "ResourceBundle not initialized"; g_shared_instance_->UnloadLocaleResources(); diff --git a/app/resource_bundle.h b/app/resource_bundle.h index c6bc5c3..49ca359 100644 --- a/app/resource_bundle.h +++ b/app/resource_bundle.h @@ -68,7 +68,7 @@ class ResourceBundle { // selected. // NOTE: Mac ignores this and always loads up resources for the language // defined by the Cocoa UI (ie-NSBundle does the langange work). - static std::string InitSharedInstance(const std::wstring& pref_locale); + static std::string InitSharedInstance(const std::string& pref_locale); // Changes the locale for an already-initialized ResourceBundle. Future // calls to get strings will return the strings for this new locale. This @@ -76,7 +76,7 @@ class ResourceBundle { // on existing or future image resources, and thus does not use the lock to // guarantee thread-safety, since all string access is expected to happen on // the UI thread. - static std::string ReloadSharedInstance(const std::wstring& pref_locale); + static std::string ReloadSharedInstance(const std::string& pref_locale); // Registers additional data pack files with the global ResourceBundle. When // looking for a DataResource, we will search these files after searching the @@ -200,7 +200,7 @@ class ResourceBundle { // Try to load the locale specific strings from an external data module. // Returns the locale that is loaded. - std::string LoadLocaleResources(const std::wstring& pref_locale); + std::string LoadLocaleResources(const std::string& pref_locale); // Unload the locale specific strings and prepares to load new ones. See // comments for ReloadSharedInstance(). diff --git a/app/resource_bundle_dummy.cc b/app/resource_bundle_dummy.cc index f5db317..53a1435 100644 --- a/app/resource_bundle_dummy.cc +++ b/app/resource_bundle_dummy.cc @@ -25,7 +25,7 @@ namespace gfx { /* static */ std::string ResourceBundle::InitSharedInstance( - const std::wstring& pref_locale) { + const std::string& pref_locale) { DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; g_shared_instance_ = new ResourceBundle(); return std::string(); diff --git a/app/resource_bundle_posix.cc b/app/resource_bundle_posix.cc index 1ee5fd1..9944280 100644 --- a/app/resource_bundle_posix.cc +++ b/app/resource_bundle_posix.cc @@ -102,7 +102,7 @@ void ResourceBundle::LoadCommonResources() { } std::string ResourceBundle::LoadLocaleResources( - const std::wstring& pref_locale) { + const std::string& pref_locale) { DCHECK(!locale_resources_data_) << "locale.pak already loaded"; std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); FilePath locale_file_path = GetLocaleFilePath(app_locale); diff --git a/app/resource_bundle_win.cc b/app/resource_bundle_win.cc index f143193..6676dc6 100644 --- a/app/resource_bundle_win.cc +++ b/app/resource_bundle_win.cc @@ -55,7 +55,7 @@ void ResourceBundle::LoadCommonResources() { } std::string ResourceBundle::LoadLocaleResources( - const std::wstring& pref_locale) { + const std::string& pref_locale) { DCHECK(NULL == locale_resources_data_) << "locale dll already loaded"; const std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); const FilePath& locale_path = GetLocaleFilePath(app_locale); diff --git a/app/test_suite.h b/app/test_suite.h index 37e2322..eeea436 100644 --- a/app/test_suite.h +++ b/app/test_suite.h @@ -60,7 +60,7 @@ class AppTestSuite : public TestSuite { // Force unittests to run using en-US so if we test against string // output, it'll pass regardless of the system language. - ResourceBundle::InitSharedInstance(L"en-US"); + ResourceBundle::InitSharedInstance("en-US"); } virtual void Shutdown() { |