summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:17:06 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:17:06 +0000
commitd70539de3df8f214397881727229a7786da9be35 (patch)
treed10df8d461702c8de9b6df045955ee2226edc046 /app
parent16792a730c621ed32aa53b57d57e6c88e232ea02 (diff)
downloadchromium_src-d70539de3df8f214397881727229a7786da9be35.zip
chromium_src-d70539de3df8f214397881727229a7786da9be35.tar.gz
chromium_src-d70539de3df8f214397881727229a7786da9be35.tar.bz2
Replace std:;wstring with std::string and string16 in locale-name related APIs.
1. Change the locale param to be std::string because they're always ASCII and change call-sites accordingly. 2. Add GetStringFUTF16 to l10n_util. On Windows, they're inline helpers calling the correspondingGetStringF returning wstring while on Mac/Linux, they just return the result of |string16 GetStringF|without converting to wstring. This is part 1 of the fix for issue 8647. Some of newly introduced conversions are temporary and will be removed later (e.g. ASCIIToWide applied to the result of GetApplicationLocale in a few places). Note : this CL will be landed after http://codereview.chromium.org/147038 is landed. BUG=8647 (http://crbug.com/8647) TEST=Pass l10n_util_unittest and other unit tests Review URL: http://codereview.chromium.org/126223 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/l10n_util.cc149
-rw-r--r--app/l10n_util.h69
-rw-r--r--app/l10n_util_posix.cc2
-rw-r--r--app/l10n_util_unittest.cc92
-rw-r--r--app/l10n_util_win.cc2
-rw-r--r--app/resource_bundle_linux.cc4
-rw-r--r--app/resource_bundle_win.cc4
7 files changed, 189 insertions, 133 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc
index d51b113..f163584 100644
--- a/app/l10n_util.cc
+++ b/app/l10n_util.cc
@@ -51,10 +51,10 @@ void GetLanguageAndRegionFromOS(std::string* lang, std::string* region) {
}
// Convert Chrome locale name to ICU locale name
-std::string ICULocaleName(const std::wstring& locale_string) {
+std::string ICULocaleName(const std::string& locale_string) {
// If not Spanish, just return it.
- if (locale_string.substr(0, 2) != L"es")
- return WideToASCII(locale_string);
+ if (locale_string.substr(0, 2) != "es")
+ return locale_string;
// Expand es to es-ES.
if (LowerCaseEqualsASCII(locale_string, "es"))
return "es-ES";
@@ -74,7 +74,7 @@ std::string ICULocaleName(const std::wstring& locale_string) {
}
// Currently, Chrome has only "es" and "es-419", but later we may have
// more specific "es-RR".
- return WideToASCII(locale_string);
+ return locale_string;
}
// Sets the default locale of ICU.
@@ -85,7 +85,7 @@ std::string ICULocaleName(const std::wstring& locale_string) {
// This is handy in that we don't have to call GetApplicationLocale()
// everytime we call locale-dependent ICU APIs as long as we make sure
// that this is called before any locale-dependent API is called.
-UBool SetICUDefaultLocale(const std::wstring& locale_string) {
+UBool SetICUDefaultLocale(const std::string& locale_string) {
Locale locale(ICULocaleName(locale_string).c_str());
UErrorCode error_code = U_ZERO_ERROR;
Locale::setDefault(locale, error_code);
@@ -118,27 +118,24 @@ bool IsDuplicateName(const std::string& locale_name) {
return false;
}
-bool IsLocaleAvailable(const std::wstring& locale,
- const std::wstring& locale_path) {
- std::wstring test_locale = locale;
+bool IsLocaleAvailable(const std::string& locale,
+ const FilePath& locale_path) {
// If locale has any illegal characters in it, we don't want to try to
// load it because it may be pointing outside the locale data file directory.
- file_util::ReplaceIllegalCharacters(&test_locale, ' ');
- if (test_locale != locale)
+ if (!file_util::IsFilenameLegal(ASCIIToUTF16(locale)))
return false;
if (!l10n_util::IsLocaleSupportedByOS(locale))
return false;
- FilePath test_path = FilePath::FromWStringHack(locale_path)
- .Append(FilePath::FromWStringHack(locale))
- .ReplaceExtension(kLocaleFileExtension);
+ FilePath test_path = locale_path;
+ test_path.AppendASCII(locale).ReplaceExtension(kLocaleFileExtension);
return file_util::PathExists(test_path) && SetICUDefaultLocale(locale);
}
-bool CheckAndResolveLocale(const std::wstring& locale,
- const std::wstring& locale_path,
- std::wstring* resolved_locale) {
+bool CheckAndResolveLocale(const std::string& locale,
+ const FilePath& locale_path,
+ std::string* resolved_locale) {
if (IsLocaleAvailable(locale, locale_path)) {
*resolved_locale = locale;
return true;
@@ -148,22 +145,22 @@ bool CheckAndResolveLocale(const std::wstring& locale,
// does not support but available on Windows. We fall
// back to en-US in GetApplicationLocale so that it's a not critical,
// but we can do better.
- std::wstring::size_type hyphen_pos = locale.find(L'-');
- if (hyphen_pos != std::wstring::npos && hyphen_pos > 0) {
- std::wstring lang(locale, 0, hyphen_pos);
- std::wstring region(locale, hyphen_pos + 1);
- std::wstring tmp_locale(lang);
+ std::string::size_type hyphen_pos = locale.find(L'-');
+ if (hyphen_pos != std::string::npos && hyphen_pos > 0) {
+ std::string lang(locale, 0, hyphen_pos);
+ std::string region(locale, hyphen_pos + 1);
+ std::string tmp_locale(lang);
// Map es-RR other than es-ES to es-419 (Chrome's Latin American
// Spanish locale).
if (LowerCaseEqualsASCII(lang, "es") && !LowerCaseEqualsASCII(region, "es"))
- tmp_locale.append(L"-419");
+ tmp_locale.append("-419");
else if (LowerCaseEqualsASCII(lang, "zh")) {
// Map zh-HK and zh-MK to zh-TW. Otherwise, zh-FOO is mapped to zh-CN.
if (LowerCaseEqualsASCII(region, "hk") ||
LowerCaseEqualsASCII(region, "mk")) {
- tmp_locale.append(L"-TW");
+ tmp_locale.append("-TW");
} else {
- tmp_locale.append(L"-CN");
+ tmp_locale.append("-CN");
}
}
if (IsLocaleAvailable(tmp_locale, locale_path)) {
@@ -176,16 +173,16 @@ bool CheckAndResolveLocale(const std::wstring& locale,
// We need to map them to our codes.
struct {
const char* source;
- const wchar_t* dest;} alias_map[] = {
- {"no", L"nb"},
- {"tl", L"fil"},
- {"iw", L"he"},
- {"en", L"en-US"},
+ const char* dest;} alias_map[] = {
+ {"no", "nb"},
+ {"tl", "fil"},
+ {"iw", "he"},
+ {"en", "en-US"},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(alias_map); ++i) {
if (LowerCaseEqualsASCII(locale, alias_map[i].source)) {
- std::wstring tmp_locale(alias_map[i].dest);
+ std::string tmp_locale(alias_map[i].dest);
if (IsLocaleAvailable(tmp_locale, locale_path)) {
resolved_locale->swap(tmp_locale);
return true;
@@ -199,7 +196,7 @@ bool CheckAndResolveLocale(const std::wstring& locale,
// Get the locale of the operating system. The return value is of the form
// language[-country] (e.g., en-US) where the language is the 2 letter code from
// ISO-639.
-std::wstring GetSystemLocale() {
+std::string GetSystemLocale() {
std::string language, region;
GetLanguageAndRegionFromOS(&language, &region);
std::string ret;
@@ -209,7 +206,7 @@ std::wstring GetSystemLocale() {
ret.append("-");
ret.append(region);
}
- return ASCIIToWide(ret);
+ return ret;
}
} // namespace
@@ -219,79 +216,69 @@ namespace l10n_util {
// Represents the locale-specific text direction.
static TextDirection g_text_direction = UNKNOWN_DIRECTION;
-std::wstring GetApplicationLocale(const std::wstring& pref_locale) {
+std::string GetApplicationLocale(const std::wstring& pref_locale) {
#if defined(OS_MACOSX)
// On the mac, we don't want to test preferences or ICU for the language,
// we want to use whatever Cocoa is using when it loaded the main nib file.
// It handles all the mapping and fallbacks for us, we just need to ask
// Cocoa.
// TODO(pinkerton): break this out into a .mm and ask Cocoa.
- return L"en";
+ return "en";
#else
FilePath locale_path;
PathService::Get(app::DIR_LOCALES, &locale_path);
- std::wstring resolved_locale;
+ std::string resolved_locale;
// First, check to see if there's a --lang flag.
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
- const std::wstring& lang_arg =
- parsed_command_line.GetSwitchValue(switches::kLang);
+ const std::string& lang_arg = WideToASCII(
+ parsed_command_line.GetSwitchValue(switches::kLang));
if (!lang_arg.empty()) {
- if (CheckAndResolveLocale(lang_arg, locale_path.ToWStringHack(),
- &resolved_locale))
+ if (CheckAndResolveLocale(lang_arg, locale_path, &resolved_locale))
return resolved_locale;
}
// Second, try user prefs.
if (!pref_locale.empty()) {
- if (CheckAndResolveLocale(pref_locale, locale_path.ToWStringHack(),
- &resolved_locale))
+ if (CheckAndResolveLocale(WideToASCII(pref_locale),
+ locale_path, &resolved_locale))
return resolved_locale;
}
// Next, try the system locale.
- const std::wstring system_locale = GetSystemLocale();
- if (CheckAndResolveLocale(system_locale, locale_path.ToWStringHack(),
- &resolved_locale))
+ const std::string system_locale = GetSystemLocale();
+ if (CheckAndResolveLocale(system_locale, locale_path, &resolved_locale))
return resolved_locale;
// Fallback on en-US.
- const std::wstring fallback_locale(L"en-US");
- if (IsLocaleAvailable(fallback_locale, locale_path.ToWStringHack()))
+ const std::string fallback_locale("en-US");
+ if (IsLocaleAvailable(fallback_locale, locale_path))
return fallback_locale;
// No locale data file was found; we shouldn't get here.
NOTREACHED();
- return std::wstring();
+ return std::string();
#endif
}
-std::wstring GetLocalName(const std::string& locale_code_str,
- const std::wstring& app_locale_wstr,
- bool is_for_ui) {
- const std::string app_locale = WideToASCII(app_locale_wstr);
- const char* locale_code = locale_code_str.c_str();
+string16 GetDisplayNameForLocale(const std::string& locale_code,
+ const std::string& display_locale,
+ bool is_for_ui) {
UErrorCode error = U_ZERO_ERROR;
const int buffer_size = 1024;
-#if defined(WCHAR_T_IS_UTF32)
- string16 name_local_utf16;
- int actual_size = uloc_getDisplayName(locale_code, app_locale.c_str(),
- WriteInto(&name_local_utf16, buffer_size + 1), buffer_size, &error);
- std::wstring name_local = UTF16ToWide(name_local_utf16);
-#else
- std::wstring name_local;
- int actual_size = uloc_getDisplayName(locale_code, app_locale.c_str(),
- WriteInto(&name_local, buffer_size + 1), buffer_size, &error);
-#endif
+ string16 display_name;
+ int actual_size = uloc_getDisplayName(locale_code.c_str(),
+ display_locale.c_str(),
+ WriteInto(&display_name, buffer_size + 1), buffer_size, &error);
DCHECK(U_SUCCESS(error));
- name_local.resize(actual_size);
+ display_name.resize(actual_size);
// Add an RTL mark so parentheses are properly placed.
if (is_for_ui && GetTextDirection() == RIGHT_TO_LEFT) {
- name_local.push_back(static_cast<wchar_t>(kRightToLeftMark));
+ display_name.push_back(static_cast<char16>(kRightToLeftMark));
}
- return name_local;
+ return display_name;
}
std::wstring GetString(int message_id) {
@@ -327,6 +314,7 @@ static string16 GetStringF(int message_id,
return formatted;
}
+#if !defined(WCHAR_T_IS_UTF16)
std::wstring GetStringF(int message_id, const std::wstring& a) {
return UTF16ToWide(GetStringF(message_id, WideToUTF16(a), string16(),
string16(), string16(), NULL));
@@ -355,6 +343,7 @@ std::wstring GetStringF(int message_id,
return UTF16ToWide(GetStringF(message_id, WideToUTF16(a), WideToUTF16(b),
WideToUTF16(c), WideToUTF16(d), NULL));
}
+#endif
std::string GetStringFUTF8(int message_id,
const string16& a) {
@@ -384,6 +373,32 @@ std::string GetStringFUTF8(int message_id,
return UTF16ToUTF8(GetStringF(message_id, a, b, c, d, NULL));
}
+string16 GetStringFUTF16(int message_id,
+ const string16& a) {
+ return GetStringF(message_id, a, string16(), string16(), string16(), NULL);
+}
+
+string16 GetStringFUTF16(int message_id,
+ const string16& a,
+ const string16& b) {
+ return GetStringF(message_id, a, b, string16(), string16(), NULL);
+}
+
+string16 GetStringFUTF16(int message_id,
+ const string16& a,
+ const string16& b,
+ const string16& c) {
+ return GetStringF(message_id, a, b, c, string16(), NULL);
+}
+
+string16 GetStringFUTF16(int message_id,
+ const string16& a,
+ const string16& b,
+ const string16& c,
+ const string16& d) {
+ return GetStringF(message_id, a, b, c, d, NULL);
+}
+
std::wstring GetStringF(int message_id, const std::wstring& a, size_t* offset) {
DCHECK(offset);
std::vector<size_t> offsets;
@@ -678,7 +693,7 @@ bool StringComparator<std::wstring>::operator()(const std::wstring& lhs,
return CompareStringWithCollator(collator_, lhs, rhs) == UCOL_LESS;
};
-void SortStrings(const std::wstring& locale,
+void SortStrings(const std::string& locale,
std::vector<std::wstring>* strings) {
SortVectorWithStringKey(locale, strings, false);
}
@@ -692,7 +707,7 @@ const std::vector<std::string>& GetAvailableLocales() {
// Filter out the names that have aliases.
if (IsDuplicateName(locale_name))
continue;
- if (!IsLocaleSupportedByOS(ASCIIToWide(locale_name)))
+ if (!IsLocaleSupportedByOS(locale_name))
continue;
// Normalize underscores to hyphens because that's what our locale files
// use.
diff --git a/app/l10n_util.h b/app/l10n_util.h
index c4c62e13..464c3b8 100644
--- a/app/l10n_util.h
+++ b/app/l10n_util.h
@@ -46,23 +46,25 @@ const char16 kPopDirectionalFormatting = 0x202C;
// 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::wstring GetApplicationLocale(const std::wstring& pref_locale);
+std::string GetApplicationLocale(const std::wstring& 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
// false for "or".
-bool IsLocaleSupportedByOS(const std::wstring& locale);
+bool IsLocaleSupportedByOS(const std::string& locale);
-// This method returns the Local Name of the Locale Code. For example, for
-// |local_code_wstr| = "en-US", it returns "English (United States)".
-// |app_locale_wstr| can be obtained in the UI thread - for example:
-// const std::wstring app_locale_wstr = g_browser_process->
-// GetApplicationLocale();
+// This method returns the display name of the locale code in |display_locale|.
+
+// For example, for |locale_code| = "en-US" and |display_locale| = "en",
+// it returns "English (United States)". To get the display name of
+// |locale_code| in the UI language of Chrome, |display_locale| can be
+// set to the return value of g_browser_process->GetApplicationLocale()
+// in the UI thread.
// If |is_for_ui| is true, U+200F is appended so that it can be
// rendered properly in a RTL Chrome.
-std::wstring GetLocalName(const std::string& locale_code_str,
- const std::wstring& app_locale_wstr,
- bool is_for_ui);
+string16 GetDisplayNameForLocale(const std::string& locale_code,
+ const std::string& display_locale,
+ bool is_for_ui);
// Pulls resource string from the string bundle and returns it.
std::wstring GetString(int message_id);
@@ -71,6 +73,44 @@ string16 GetStringUTF16(int message_id);
// Get a resource string and replace $1-$2-$3 with |a| and |b|
// respectively. Additionally, $$ is replaced by $.
+string16 GetStringFUTF16(int message_id,
+ const string16& a);
+string16 GetStringFUTF16(int message_id,
+ const string16& a,
+ const string16& b);
+string16 GetStringFUTF16(int message_id,
+ const string16& a,
+ const string16& b,
+ const string16& c);
+string16 GetStringFUTF16(int message_id,
+ const string16& a,
+ const string16& b,
+ const string16& c,
+ const string16& d);
+#if defined(WCHAR_T_IS_UTF16)
+inline std::wstring GetStringF(int message_id,
+ const std::wstring& a) {
+ return GetStringFUTF16(message_id, a);
+}
+inline std::wstring GetStringF(int message_id,
+ const std::wstring& a,
+ const std::wstring& b) {
+ return GetStringFUTF16(message_id, a, b);
+}
+inline std::wstring GetStringF(int message_id,
+ const std::wstring& a,
+ const std::wstring& b,
+ const std::wstring& c) {
+ return GetStringFUTF16(message_id, a, b, c);
+}
+inline std::wstring GetStringF(int message_id,
+ const std::wstring& a,
+ const std::wstring& b,
+ const std::wstring& c,
+ const std::wstring& d) {
+ return GetStringFUTF16(message_id, a, b, c, d);
+}
+#else
std::wstring GetStringF(int message_id,
const std::wstring& a);
std::wstring GetStringF(int message_id,
@@ -85,6 +125,7 @@ std::wstring GetStringF(int message_id,
const std::wstring& b,
const std::wstring& c,
const std::wstring& d);
+#endif
std::string GetStringFUTF8(int message_id,
const string16& a);
std::string GetStringFUTF8(int message_id,
@@ -314,7 +355,7 @@ bool StringComparator<std::wstring>::operator()(const std::wstring& lhs,
// want to be sorted. |end_index| points to the end position of elements in the
// vector which want to be sorted
template <class Element>
-void SortVectorWithStringKey(const std::wstring& locale,
+void SortVectorWithStringKey(const std::string& locale,
std::vector<Element>* elements,
unsigned int begin_index,
unsigned int end_index,
@@ -322,7 +363,7 @@ void SortVectorWithStringKey(const std::wstring& locale,
DCHECK(begin_index >= 0 && begin_index < end_index &&
end_index <= static_cast<unsigned int>(elements->size()));
UErrorCode error = U_ZERO_ERROR;
- Locale loc(WideToASCII(locale).c_str());
+ Locale loc(locale.c_str());
scoped_ptr<Collator> collator(Collator::createInstance(loc, error));
if (U_FAILURE(error))
collator.reset();
@@ -337,7 +378,7 @@ void SortVectorWithStringKey(const std::wstring& locale,
}
template <class Element>
-void SortVectorWithStringKey(const std::wstring& locale,
+void SortVectorWithStringKey(const std::string& locale,
std::vector<Element>* elements,
bool needs_stable_sort) {
SortVectorWithStringKey<Element>(locale, elements, 0, elements->size(),
@@ -346,7 +387,7 @@ void SortVectorWithStringKey(const std::wstring& locale,
// In place sorting of strings using collation rules for |locale|.
// TODO(port): this should take string16.
-void SortStrings(const std::wstring& locale,
+void SortStrings(const std::string& locale,
std::vector<std::wstring>* strings);
// Returns a vector of available locale codes. E.g., a vector containing
diff --git a/app/l10n_util_posix.cc b/app/l10n_util_posix.cc
index c6797c2..2f3d7e6e 100644
--- a/app/l10n_util_posix.cc
+++ b/app/l10n_util_posix.cc
@@ -7,7 +7,7 @@
namespace l10n_util {
// Return true blindly for now.
-bool IsLocaleSupportedByOS(const std::wstring& locale) {
+bool IsLocaleSupportedByOS(const std::string& locale) {
return true;
}
diff --git a/app/l10n_util_unittest.cc b/app/l10n_util_unittest.cc
index 48dc1f0..e1af33c 100644
--- a/app/l10n_util_unittest.cc
+++ b/app/l10n_util_unittest.cc
@@ -84,8 +84,8 @@ TEST_F(L10nUtilTest, TruncateString) {
EXPECT_EQ(L"\x2026", l10n_util::TruncateString(L" ", 2));
}
-void SetICUDefaultLocale(const std::wstring& locale_string) {
- Locale locale(WideToASCII(locale_string).c_str());
+void SetICUDefaultLocale(const std::string& locale_string) {
+ Locale locale(locale_string.c_str());
UErrorCode error_code = U_ZERO_ERROR;
Locale::setDefault(locale, error_code);
EXPECT_TRUE(U_SUCCESS(error_code));
@@ -136,71 +136,71 @@ TEST_F(L10nUtilTest, GetAppLocale) {
// Keep a copy of ICU's default locale before we overwrite it.
Locale locale = Locale::getDefault();
- SetICUDefaultLocale(L"en-US");
- EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("en-US");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"en-GB");
- EXPECT_EQ(L"en-GB", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("en-GB");
+ EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"fr-CA");
- EXPECT_EQ(L"fr", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("fr-CA");
+ EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"xx");
- EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("xx");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"en-US");
- EXPECT_EQ(L"fr", l10n_util::GetApplicationLocale(L"fr"));
- EXPECT_EQ(L"fr", l10n_util::GetApplicationLocale(L"fr-CA"));
+ SetICUDefaultLocale("en-US");
+ EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"fr"));
+ EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"fr-CA"));
- SetICUDefaultLocale(L"en-US");
+ SetICUDefaultLocale("en-US");
// Aliases iw, no, tl to he, nb, fil.
- EXPECT_EQ(L"he", l10n_util::GetApplicationLocale(L"iw"));
- EXPECT_EQ(L"nb", l10n_util::GetApplicationLocale(L"no"));
- EXPECT_EQ(L"fil", l10n_util::GetApplicationLocale(L"tl"));
+ EXPECT_EQ("he", l10n_util::GetApplicationLocale(L"iw"));
+ EXPECT_EQ("nb", l10n_util::GetApplicationLocale(L"no"));
+ EXPECT_EQ("fil", l10n_util::GetApplicationLocale(L"tl"));
// es-419 and es-XX (where XX is not Spain) should be
// mapped to es-419 (Latin American Spanish).
- EXPECT_EQ(L"es-419", l10n_util::GetApplicationLocale(L"es-419"));
- EXPECT_EQ(L"es", l10n_util::GetApplicationLocale(L"es-ES"));
- EXPECT_EQ(L"es-419", l10n_util::GetApplicationLocale(L"es-AR"));
+ 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"));
- SetICUDefaultLocale(L"es-MX");
- EXPECT_EQ(L"es-419", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("es-MX");
+ EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"es-AR");
- EXPECT_EQ(L"es-419", l10n_util::GetApplicationLocale(L""));
- EXPECT_EQ(L"es", l10n_util::GetApplicationLocale(L"es"));
+ SetICUDefaultLocale("es-AR");
+ EXPECT_EQ("es-419", l10n_util::GetApplicationLocale(L""));
+ EXPECT_EQ("es", l10n_util::GetApplicationLocale(L"es"));
- SetICUDefaultLocale(L"es-ES");
- EXPECT_EQ(L"es", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("es-ES");
+ EXPECT_EQ("es", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"es");
- EXPECT_EQ(L"es", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("es");
+ EXPECT_EQ("es", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"zh-HK");
- EXPECT_EQ(L"zh-TW", l10n_util::GetApplicationLocale(L""));
- EXPECT_EQ(L"zh-CN", l10n_util::GetApplicationLocale(L"zh-CN"));
+ SetICUDefaultLocale("zh-HK");
+ EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L""));
+ EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L"zh-CN"));
- SetICUDefaultLocale(L"zh-MK");
- EXPECT_EQ(L"zh-TW", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("zh-MK");
+ EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"zh-SG");
- EXPECT_EQ(L"zh-CN", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("zh-SG");
+ EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"he");
- EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en"));
+ SetICUDefaultLocale("he");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"en"));
#if defined(OS_WIN)
// Oriya should be blocked unless OS is Vista or newer.
if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
- SetICUDefaultLocale(L"or");
- EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"en-GB");
- EXPECT_EQ(L"en-GB", l10n_util::GetApplicationLocale(L"or"));
+ SetICUDefaultLocale("or");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("en-GB");
+ EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"or"));
} else {
- SetICUDefaultLocale(L"or");
- EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L""));
- SetICUDefaultLocale(L"en-GB");
- EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L"or"));
+ SetICUDefaultLocale("or");
+ EXPECT_EQ("or", l10n_util::GetApplicationLocale(L""));
+ SetICUDefaultLocale("en-GB");
+ EXPECT_EQ("or", l10n_util::GetApplicationLocale(L"or"));
}
#endif
diff --git a/app/l10n_util_win.cc b/app/l10n_util_win.cc
index 03415d1..b00ba44 100644
--- a/app/l10n_util_win.cc
+++ b/app/l10n_util_win.cc
@@ -62,7 +62,7 @@ void HWNDSetRTLLayout(HWND hwnd) {
}
}
-bool IsLocaleSupportedByOS(const std::wstring& locale) {
+bool IsLocaleSupportedByOS(const std::string& locale) {
// Block Oriya on Windows XP.
return !(LowerCaseEqualsASCII(locale, "or") &&
win_util::GetWinVersion() < win_util::WINVERSION_VISTA);
diff --git a/app/resource_bundle_linux.cc b/app/resource_bundle_linux.cc
index f886eca..9d46fb7 100644
--- a/app/resource_bundle_linux.cc
+++ b/app/resource_bundle_linux.cc
@@ -95,11 +95,11 @@ FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) {
FilePath locale_path;
PathService::Get(app::DIR_LOCALES, &locale_path);
- const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale);
+ const std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
if (app_locale.empty())
return FilePath();
- return locale_path.Append(WideToASCII(app_locale + L".pak"));
+ return locale_path.AppendASCII(app_locale + ".pak");
}
void ResourceBundle::LoadThemeResources() {
diff --git a/app/resource_bundle_win.cc b/app/resource_bundle_win.cc
index 82f34b0..30a9ff7 100644
--- a/app/resource_bundle_win.cc
+++ b/app/resource_bundle_win.cc
@@ -65,11 +65,11 @@ FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) {
FilePath locale_path;
PathService::Get(app::DIR_LOCALES, &locale_path);
- const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale);
+ const std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
if (app_locale.empty())
return FilePath();
- return locale_path.Append(app_locale + L".dll");
+ return locale_path.AppendASCII(app_locale + ".dll");
}
void ResourceBundle::LoadThemeResources() {