diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 05:49:44 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 05:49:44 +0000 |
commit | 1d322f90a05be438299ce879ab47d8b94ecfb60e (patch) | |
tree | 11a9ece3eede78ecbcd01ecc3e12d35348da1e12 /chrome/browser | |
parent | 0dc29cde34e490141440282d942df73fb14d687a (diff) | |
download | chromium_src-1d322f90a05be438299ce879ab47d8b94ecfb60e.zip chromium_src-1d322f90a05be438299ce879ab47d8b94ecfb60e.tar.gz chromium_src-1d322f90a05be438299ce879ab47d8b94ecfb60e.tar.bz2 |
Clean up latin-pre/post special handling in input method code.
This is a follow-up CL of
http://codereview.chromium.org/3041054
which removed m17n:t:* (latin-pre/post) from input method ID whitelist.
We had some special cases here and there for these IDs and I removed them.
Patch from kochi@chromium.org.
BUG=chromium-os:5439
TEST=run unittest (LanguageMenuButtonTest, InputMethodUtilTest)
Review URL: http://codereview.chromium.org/3122005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
8 files changed, 17 insertions, 82 deletions
diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.cc b/chrome/browser/chromeos/dom_ui/language_options_handler.cc index f5f1b24..31df924 100644 --- a/chrome/browser/chromeos/dom_ui/language_options_handler.cc +++ b/chrome/browser/chromeos/dom_ui/language_options_handler.cc @@ -44,8 +44,6 @@ void LanguageOptionsHandler::GetLocalizedValues( l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES)); localized_strings->SetString(L"remove_button", l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON)); - localized_strings->SetString(L"others", - l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS)); localized_strings->SetString(L"is_displayed_in_this_language", l10n_util::GetStringF( IDS_OPTIONS_SETTINGS_LANGUAGES_IS_DISPLAYED_IN_THIS_LANGUAGE, diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index e424338..1b4d6ac 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -153,10 +153,6 @@ const struct EnglishToResouceId { IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_VIQR_INPUT_METHOD }, { "vni (m17n)", IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_VNI_INPUT_METHOD }, - { "latn-post (m17n)", - IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_LATIN_POST_INPUT_METHOD }, - { "latn-pre (m17n)", - IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_LATIN_PRE_INPUT_METHOD }, { "Bopomofo", IDS_OPTIONS_SETTINGS_LANGUAGES_BOPOMOFO_INPUT_METHOD }, { "Chewing", IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_INPUT_METHOD }, { "Pinyin", IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_INPUT_METHOD }, @@ -435,16 +431,6 @@ std::string GetLanguageCodeFromDescriptor( return language_code; } -std::wstring MaybeRewriteLanguageName(const std::wstring& language_name) { - // "t" is used as the language code for input methods that don't fall - // under any other languages. - if (language_name == L"t") { - return l10n_util::GetString( - IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS); - } - return language_name; -} - std::string GetLanguageCodeFromInputMethodId( const std::string& input_method_id) { // The code should be compatible with one of codes used for UI languages, @@ -481,17 +467,14 @@ std::wstring GetLanguageDisplayNameFromCode(const std::string& language_code) { if (!g_browser_process) { return L""; } - return MaybeRewriteLanguageName(UTF16ToWide( - l10n_util::GetDisplayNameForLocale( - language_code, g_browser_process->GetApplicationLocale(), - true))); + return UTF16ToWide(l10n_util::GetDisplayNameForLocale( + language_code, g_browser_process->GetApplicationLocale(), true)); } std::wstring GetLanguageNativeDisplayNameFromCode( const std::string& language_code) { - return MaybeRewriteLanguageName(UTF16ToWide( - l10n_util::GetDisplayNameForLocale( - language_code, language_code, true))); + return UTF16ToWide(l10n_util::GetDisplayNameForLocale( + language_code, language_code, true)); } void SortLanguageCodesByNames(std::vector<std::string>* language_codes) { diff --git a/chrome/browser/chromeos/input_method/input_method_util.h b/chrome/browser/chromeos/input_method/input_method_util.h index 22327967..58999db 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.h +++ b/chrome/browser/chromeos/input_method/input_method_util.h @@ -75,12 +75,6 @@ std::string GetLanguageCodeFromDescriptor( // "pinyin" => "" std::string GetKeyboardLayoutName(const std::string& input_method_id); -// Rewrites the language name and returns the modified version if -// necessary. Otherwise, returns the given language name as is. -// In particular, this rewrites the special language name used for input -// methods that don't fall under any other languages. -std::wstring MaybeRewriteLanguageName(const std::wstring& language_name); - // Converts an input method ID to a language code of the IME. Returns "Eng" // when |input_method_id| is unknown. // Example: "hangul" => "ko" diff --git a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc index c0b021a..f228d11 100644 --- a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc @@ -34,6 +34,9 @@ TEST(InputMethodUtilTest, NormalizeLanguageCode) { // TODO(yusukes): test all language codes that IBus provides. EXPECT_EQ("ja", NormalizeLanguageCode("ja")); EXPECT_EQ("ja", NormalizeLanguageCode("jpn")); + // In the past "t" had a meaning of "other language" for some m17n latin + // input methods for testing purpose, but it is no longer used. We test "t" + // here as just an "unknown" language. EXPECT_EQ("t", NormalizeLanguageCode("t")); EXPECT_EQ("zh-CN", NormalizeLanguageCode("zh-CN")); EXPECT_EQ("zh-CN", NormalizeLanguageCode("zh_CN")); @@ -74,12 +77,6 @@ TEST(InputMethodUtilTest, GetLanguageCodeFromDescriptor) { InputMethodDescriptor("xkb:uk::eng", "United Kingdom", "us", "eng"))); } -TEST(InputMethodUtilTest, MaybeRewriteLanguageName) { - EXPECT_EQ(L"English", MaybeRewriteLanguageName(L"English")); - EXPECT_EQ(l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS), - MaybeRewriteLanguageName(L"t")); -} - TEST(InputMethodUtilTest, GetKeyboardLayoutName) { // Unsupported cases EXPECT_EQ("", GetKeyboardLayoutName("UNSUPPORTED_ID")); @@ -88,8 +85,6 @@ TEST(InputMethodUtilTest, GetKeyboardLayoutName) { EXPECT_EQ("", GetKeyboardLayoutName("mozc")); EXPECT_EQ("", GetKeyboardLayoutName("mozc-jp")); EXPECT_EQ("", GetKeyboardLayoutName("pinyin")); - EXPECT_EQ("", GetKeyboardLayoutName("m17n:t:latn-pre")); - EXPECT_EQ("", GetKeyboardLayoutName("m17n:t:latn-post")); EXPECT_EQ("", GetKeyboardLayoutName("m17n:ar:kbd")); EXPECT_EQ("", GetKeyboardLayoutName("m17n:he:kbd")); EXPECT_EQ("", GetKeyboardLayoutName("m17n:hi:itrans")); @@ -143,16 +138,10 @@ TEST(InputMethodUtilTest, GetKeyboardLayoutName) { TEST(InputMethodUtilTest, GetLanguageDisplayNameFromCode) { EXPECT_EQ(L"Finnish", GetLanguageDisplayNameFromCode("fi")); - // MaybeRewriteLanguageName() should be applied. - EXPECT_EQ(l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS), - GetLanguageDisplayNameFromCode("t")); } TEST(InputMethodUtilTest, GetLanguageNativeDisplayNameFromCode) { EXPECT_EQ(L"suomi", GetLanguageNativeDisplayNameFromCode("fi")); - // MaybeRewriteLanguageName() should be applied. - EXPECT_EQ(l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS), - GetLanguageNativeDisplayNameFromCode("t")); } TEST(InputMethodUtilTest, SortLanguageCodesByNames) { @@ -162,6 +151,7 @@ TEST(InputMethodUtilTest, SortLanguageCodesByNames) { language_codes.push_back("ja"); language_codes.push_back("fr"); + // For "t", see the comment in NormalizeLanguageCode test. language_codes.push_back("t"); SortLanguageCodesByNames(&language_codes); ASSERT_EQ(3U, language_codes.size()); @@ -185,7 +175,6 @@ TEST(LanguageConfigModelTest, SortInputMethodIdsByNamesInternal) { id_to_language_code_map.insert(std::make_pair("mozc-jp", "ja")); id_to_language_code_map.insert(std::make_pair("xkb:jp::jpn", "ja")); id_to_language_code_map.insert(std::make_pair("xkb:fr::fra", "fr")); - id_to_language_code_map.insert(std::make_pair("m17n:latn-pre", "t")); std::vector<std::string> input_method_ids; // Check if this function can handle an empty list. @@ -194,34 +183,30 @@ TEST(LanguageConfigModelTest, SortInputMethodIdsByNamesInternal) { input_method_ids.push_back("mozc"); // Japanese input_method_ids.push_back("xkb:fr::fra"); // French - input_method_ids.push_back("m17n:latn-pre"); // Others SortInputMethodIdsByNamesInternal(id_to_language_code_map, &input_method_ids); - ASSERT_EQ(3U, input_method_ids.size()); + ASSERT_EQ(2U, input_method_ids.size()); ASSERT_EQ("xkb:fr::fra", input_method_ids[0]); // French ASSERT_EQ("mozc", input_method_ids[1]); // Japanese - ASSERT_EQ("m17n:latn-pre", input_method_ids[2]); // Others // Add a duplicate entry and see if it works. // Note that SortInputMethodIdsByNamesInternal uses std::stable_sort. input_method_ids.push_back("xkb:jp::jpn"); // also Japanese SortInputMethodIdsByNamesInternal(id_to_language_code_map, &input_method_ids); - ASSERT_EQ(4U, input_method_ids.size()); + ASSERT_EQ(3U, input_method_ids.size()); ASSERT_EQ("xkb:fr::fra", input_method_ids[0]); // French ASSERT_EQ("mozc", input_method_ids[1]); // Japanese ASSERT_EQ("xkb:jp::jpn", input_method_ids[2]); // Japanese - ASSERT_EQ("m17n:latn-pre", input_method_ids[3]); // Others input_method_ids.push_back("mozc-jp"); // also Japanese SortInputMethodIdsByNamesInternal(id_to_language_code_map, &input_method_ids); - ASSERT_EQ(5U, input_method_ids.size()); + ASSERT_EQ(4U, input_method_ids.size()); ASSERT_EQ("xkb:fr::fra", input_method_ids[0]); // French ASSERT_EQ("mozc", input_method_ids[1]); // Japanese ASSERT_EQ("xkb:jp::jpn", input_method_ids[2]); // Japanese ASSERT_EQ("mozc-jp", input_method_ids[3]); // Japanese - ASSERT_EQ("m17n:latn-pre", input_method_ids[4]); // Others } TEST(LanguageConfigModelTest, GetInputMethodIdsForLanguageCode) { diff --git a/chrome/browser/chromeos/options/language_config_model.cc b/chrome/browser/chromeos/options/language_config_model.cc index e045506..c0d3cfd 100644 --- a/chrome/browser/chromeos/options/language_config_model.cc +++ b/chrome/browser/chromeos/options/language_config_model.cc @@ -36,8 +36,7 @@ std::wstring AddLanguageComboboxModel::GetItemAt(int index) { return l10n_util::GetString( IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_COMBOBOX); } - return input_method::MaybeRewriteLanguageName( - GetLanguageNameAt(GetLanguageIndex(index))); + return GetLanguageNameAt(GetLanguageIndex(index)); } int AddLanguageComboboxModel::GetLanguageIndex(int index) const { diff --git a/chrome/browser/chromeos/options/language_config_view.cc b/chrome/browser/chromeos/options/language_config_view.cc index d9f482e..8de7688 100644 --- a/chrome/browser/chromeos/options/language_config_view.cc +++ b/chrome/browser/chromeos/options/language_config_view.cc @@ -515,8 +515,7 @@ void LanguageConfigView::AddUiLanguageSection(const std::string& language_code, g_browser_process->GetApplicationLocale(); const string16 language_name16 = l10n_util::GetDisplayNameForLocale( language_code, application_locale, true); - const std::wstring language_name - = input_method::MaybeRewriteLanguageName(UTF16ToWide(language_name16)); + const std::wstring language_name = UTF16ToWide(language_name16); views::Label* language_name_label = new views::Label(language_name); language_name_label->SetFont( language_name_label->font().DeriveFont(0, gfx::Font::BOLD)); diff --git a/chrome/browser/chromeos/status/language_menu_button.cc b/chrome/browser/chromeos/status/language_menu_button.cc index 7fa7e12..c31e8b5 100644 --- a/chrome/browser/chromeos/status/language_menu_button.cc +++ b/chrome/browser/chromeos/status/language_menu_button.cc @@ -92,12 +92,6 @@ const struct { { "chewing", "\xe9\x85\xb7" }, // U+9177 { "m17n:zh:cangjie", "\xe5\x80\x89" }, // U+5009 // TODO(yusukes): Add m17n:zh:quick if there's a good Hanzi character for it. - - // Handle "m17n:t" input methods here since ICU is not able to handle the - // language code "t". Note: most users use either latn-pre or latn-post - // methods, not both. The same is true for mozc/mozc-jp. - { "m17n:t:latn-pre", "LAT" }, - { "m17n:t:latn-post", "LAT" }, }; const size_t kMappingFromIdToIndicatorTextLen = ARRAYSIZE_UNSAFE(kMappingFromIdToIndicatorText); @@ -638,20 +632,13 @@ std::wstring LanguageMenuButton::GetTextForMenu( const std::string language_code = input_method::GetLanguageCodeFromDescriptor(input_method); - std::wstring text; - if (language_code == "t") { - text = UTF8ToWide(input_method.display_name); - } - // For the drop-down menu and tooltip, we'll show language names like // "Chinese (Simplified)" and "Japanese", instead of input method names // like "Pinyin" and "Mozc". - if (text.empty()) { - text = GetLanguageName(language_code); - if (add_method_name) { - text += L" - "; - text += input_method::GetString(input_method.display_name); - } + std::wstring text = GetLanguageName(language_code); + if (add_method_name) { + text += L" - "; + text += input_method::GetString(input_method.display_name); } 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 2f4044a..b769ad7 100644 --- a/chrome/browser/chromeos/status/language_menu_button_unittest.cc +++ b/chrome/browser/chromeos/status/language_menu_button_unittest.cc @@ -63,11 +63,6 @@ TEST(LanguageMenuButtonTest, GetTextForIndicatorTest) { EXPECT_EQ(UTF8ToWide("TW"), LanguageMenuButton::GetTextForIndicator(desc)); } - { - InputMethodDescriptor desc("m17n:t:latn-pre", "latn-pre", "us", "t"); - EXPECT_EQ(L"LAT", - LanguageMenuButton::GetTextForIndicator(desc)); - } } TEST(LanguageMenuButtonTest, GetTextForTooltipTest) { @@ -89,11 +84,6 @@ TEST(LanguageMenuButtonTest, GetTextForTooltipTest) { EXPECT_EQ(L"xx - unregistered string", LanguageMenuButton::GetTextForMenu(desc, kAddMethodName)); } - { - InputMethodDescriptor desc("m17n:t:latn-pre", "latn-pre", "us", "t"); - EXPECT_EQ(L"latn-pre", - LanguageMenuButton::GetTextForMenu(desc, kAddMethodName)); - } } } // namespace chromeos |