diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 06:00:35 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 06:00:35 +0000 |
commit | 1ff649cf021d50c365c0a8487a340f7c37aaab1b (patch) | |
tree | 95b4b5213837bb62fc874163efed1d2cedcdbb71 /chrome | |
parent | 9731edec74129f5c96c150e38a36671d6c08636f (diff) | |
download | chromium_src-1ff649cf021d50c365c0a8487a340f7c37aaab1b.zip chromium_src-1ff649cf021d50c365c0a8487a340f7c37aaab1b.tar.gz chromium_src-1ff649cf021d50c365c0a8487a340f7c37aaab1b.tar.bz2 |
Use "CN" for simplified Chinese and "TW" for traditonal Chinese, rather than "ZH".
BUG=chromium-os:4696
TEST=checked manually
Review URL: http://codereview.chromium.org/2979008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/status/language_menu_button.cc | 19 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/language_menu_button_unittest.cc | 20 |
2 files changed, 36 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/status/language_menu_button.cc b/chrome/browser/chromeos/status/language_menu_button.cc index ead28ac..a8bc7d0 100644 --- a/chrome/browser/chromeos/status/language_menu_button.cc +++ b/chrome/browser/chromeos/status/language_menu_button.cc @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/string_util.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" @@ -606,9 +607,21 @@ std::wstring LanguageMenuButton::GetTextForIndicator( if (text.empty()) { const size_t kMaxLanguageNameLen = 2; - const std::wstring language_code = UTF8ToWide( - input_method::GetLanguageCodeFromDescriptor(input_method)); - text = StringToUpperASCII(language_code).substr(0, kMaxLanguageNameLen); + std::string language_code = + input_method::GetLanguageCodeFromDescriptor(input_method); + + // Use "CN" for simplified Chinese and "TW" for traditonal Chinese, + // rather than "ZH". + if (StartsWithASCII(language_code, "zh-", false)) { + std::vector<std::string> portions; + SplitString(language_code, '-', &portions); + if (portions.size() >= 2 && !portions[1].empty()) { + language_code = portions[1]; + } + } + + text = StringToUpperASCII(UTF8ToWide(language_code)).substr( + 0, kMaxLanguageNameLen); } DCHECK(!text.empty()); return text; diff --git a/chrome/browser/chromeos/status/language_menu_button_unittest.cc b/chrome/browser/chromeos/status/language_menu_button_unittest.cc index 3f3372c..a5094ca 100644 --- a/chrome/browser/chromeos/status/language_menu_button_unittest.cc +++ b/chrome/browser/chromeos/status/language_menu_button_unittest.cc @@ -44,6 +44,26 @@ TEST(LanguageMenuButtonTest, GetTextForIndicatorTest) { LanguageMenuButton::GetTextForIndicator(desc)); } { + InputMethodDescriptor desc("pinyin", "Pinyin", "us", "zh-CN"); + EXPECT_EQ(UTF8ToWide("CN"), + LanguageMenuButton::GetTextForIndicator(desc)); + } + { + InputMethodDescriptor desc("chewing", "Chewing", "us", "zh-TW"); + EXPECT_EQ(UTF8ToWide("TW"), + LanguageMenuButton::GetTextForIndicator(desc)); + } + { + InputMethodDescriptor desc("m17n:zh:cangjie", "Cangjie", "us", "zh-TW"); + EXPECT_EQ(UTF8ToWide("TW"), + LanguageMenuButton::GetTextForIndicator(desc)); + } + { + InputMethodDescriptor desc("m17n:zh:quick", "Quick", "us", "zh-TW"); + EXPECT_EQ(UTF8ToWide("TW"), + LanguageMenuButton::GetTextForIndicator(desc)); + } + { InputMethodDescriptor desc("m17n:t:latn-pre", "latn-pre", "us", "t"); EXPECT_EQ(L"LAT", LanguageMenuButton::GetTextForIndicator(desc)); |