summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 21:16:46 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 21:16:46 +0000
commit3117306367ccfee1595e668ffc1101979c4823e8 (patch)
tree58374e93e2281b3797c2cbb38955c6ccf3107964 /chrome
parentec3625e3d6de06cbb2bf79531af92eaf61c14bf8 (diff)
downloadchromium_src-3117306367ccfee1595e668ffc1101979c4823e8.zip
chromium_src-3117306367ccfee1595e668ffc1101979c4823e8.tar.gz
chromium_src-3117306367ccfee1595e668ffc1101979c4823e8.tar.bz2
Maps our internal Chinese locale codes to those expected by the ICU API for
the display name of a locale and expected by Google (in case of 'nb vs no'). 1. Map zh-CN and zh-TW to zh-Hans and zh-Hant in GetDisplay 2. Map nb to no before adding 'hl' param for Google services. This will be removed once Google begins to honor 'nb'. 3. While doing so, I found that language_combox_model.cc has the exactly the same code as in l10n_util.cc and refactored it. BUG=34531 TEST=1. app_unittest: L10nUt*.LocaleDispla* 2. See the bug 34531 3. On Windows, the language menu in Options | Under the hood | Fonts & Language Menu | Language tab lists 'Chinese (Simplified Han)' and 'Chinese (Traditional Han)' for Simplified Chinese and Traditional Chinese in English Chrome along with Chinese names for those two languages. This is the behavior without this CL and it should't change with the refactoring. Review URL: http://codereview.chromium.org/596033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/google_util.cc8
-rw-r--r--chrome/browser/language_combobox_model.cc36
2 files changed, 16 insertions, 28 deletions
diff --git a/chrome/browser/google_util.cc b/chrome/browser/google_util.cc
index 9cb5e22..e8553e9 100644
--- a/chrome/browser/google_util.cc
+++ b/chrome/browser/google_util.cc
@@ -35,8 +35,12 @@ const char kLinkDoctorBaseURL[] =
"http://linkhelp.clients.google.com/tbproxy/lh/fixurl";
GURL AppendGoogleLocaleParam(const GURL& url) {
- return AppendParam(url, "hl",
- g_browser_process->GetApplicationLocale());
+ // Google does not yet recognize 'nb' for Norwegian Bokmal, but it uses
+ // 'no' for that.
+ std::string locale = g_browser_process->GetApplicationLocale();
+ if (locale == "nb")
+ locale = "no";
+ return AppendParam(url, "hl", locale);
}
GURL AppendGoogleTLDParam(const GURL& url) {
diff --git a/chrome/browser/language_combobox_model.cc b/chrome/browser/language_combobox_model.cc
index 97efadd..6114573 100644
--- a/chrome/browser/language_combobox_model.cc
+++ b/chrome/browser/language_combobox_model.cc
@@ -38,32 +38,16 @@ void LanguageComboboxModel::InitNativeNames(
std::string locale_code_str = locale_codes[i];
const char* locale_code = locale_codes[i].c_str();
- // Internally, we use the language code of zh-CN and zh-TW, but we want the
- // display names to be Chinese (Simplified) and Chinese (Traditional). To
- // do that, we use zh-hans and zh-hant when using ICU's
- // uloc_getDisplayName.
- if (locale_code_str == "zh-CN") {
- locale_code = "zh-hans";
- } else if (locale_code_str == "zh-TW") {
- locale_code = "zh-hant";
- }
-
- UErrorCode error = U_ZERO_ERROR;
- const int buffer_size = 1024;
- string16 name_local;
- int actual_size = uloc_getDisplayName(locale_code, app_locale.c_str(),
- WriteInto(&name_local, buffer_size + 1), buffer_size, &error);
- DCHECK(U_SUCCESS(error));
- name_local.resize(actual_size);
-
- string16 name_native;
- actual_size = uloc_getDisplayName(locale_code, locale_code,
- WriteInto(&name_native, buffer_size + 1), buffer_size, &error);
- DCHECK(U_SUCCESS(error));
- name_native.resize(actual_size);
-
- locale_names_.push_back(UTF16ToWideHack(name_local));
- native_names_[UTF16ToWideHack(name_local)] = LocaleData(
+ // TODO(jungshik): Even though these strings are used for the UI,
+ // the old code does not add an RTL mark for RTL locales. Make sure
+ // that it's ok without that.
+ string16 name_in_current_ui =
+ l10n_util::GetDisplayNameForLocale(locale_code, app_locale, false);
+ string16 name_native =
+ l10n_util::GetDisplayNameForLocale(locale_code, locale_code, false);
+
+ locale_names_.push_back(UTF16ToWideHack(name_in_current_ui));
+ native_names_[UTF16ToWideHack(name_in_current_ui)] = LocaleData(
UTF16ToWideHack(name_native), locale_codes[i]);
}