diff options
author | jshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-11 21:16:46 +0000 |
---|---|---|
committer | jshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-11 21:16:46 +0000 |
commit | 3117306367ccfee1595e668ffc1101979c4823e8 (patch) | |
tree | 58374e93e2281b3797c2cbb38955c6ccf3107964 /app/l10n_util.cc | |
parent | ec3625e3d6de06cbb2bf79531af92eaf61c14bf8 (diff) | |
download | chromium_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 'app/l10n_util.cc')
-rw-r--r-- | app/l10n_util.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc index 9f28842..1feb09d 100644 --- a/app/l10n_util.cc +++ b/app/l10n_util.cc @@ -524,9 +524,31 @@ std::string GetApplicationLocale(const std::wstring& pref_locale) { #endif // !defined(OS_MACOSX) } -string16 GetDisplayNameForLocale(const std::string& locale_code, +string16 GetDisplayNameForLocale(const std::string& locale, const std::string& display_locale, bool is_for_ui) { + std::string locale_code = locale; + // 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) instead + // of Chinese (China) and Chinese (Taiwan). To do that, we pass zh-Hans + // and zh-Hant to ICU. Even with this mapping, we'd get + // 'Chinese (Simplified Han)' and 'Chinese (Traditional Han)' in English and + // even longer results in other languages. Arguably, they're better than + // the current results : Chinese (China) / Chinese (Taiwan). + // TODO(jungshik): Do one of the following: + // 1. Special-case Chinese by getting the custom-translation for them + // 2. Recycle IDS_ENCODING_{SIMP,TRAD}_CHINESE. + // 3. Get translations for two directly from the ICU resouce bundle + // because they're not accessible with other any API. + // 4. Patch ICU to special-case zh-Hans/zh-Hant for us. + // #1 and #2 wouldn't work if display_locale != current UI locale although + // we can think of additional hack to work around the problem. + // #3 can be potentially expensive. + if (locale_code == "zh-CN") + locale_code = "zh-Hans"; + else if (locale_code == "zh-TW") + locale_code = "zh-Hant"; + UErrorCode error = U_ZERO_ERROR; const int buffer_size = 1024; |