| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 language_code_to_ids->insert( | 70 language_code_to_ids->insert( |
| 71 std::make_pair(language_code, input_method.id())); | 71 std::make_pair(language_code, input_method.id())); |
| 72 // Remember the pairs. | 72 // Remember the pairs. |
| 73 id_to_language_code->insert( | 73 id_to_language_code->insert( |
| 74 std::make_pair(input_method.id(), language_code)); | 74 std::make_pair(input_method.id(), language_code)); |
| 75 id_to_descriptor->insert( | 75 id_to_descriptor->insert( |
| 76 std::make_pair(input_method.id(), input_method)); | 76 std::make_pair(input_method.id(), input_method)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Go through the languages listed in kExtraLanguages. | 79 // Go through the languages listed in kExtraLanguages. |
| 80 for (size_t i = 0; i < arraysize(kExtraLanguages); ++i) { | 80 for (size_t i = 0; i < kExtraLanguagesLength; ++i) { |
| 81 const char* language_code = kExtraLanguages[i].language_code; | 81 const char* language_code = kExtraLanguages[i].language_code; |
| 82 const char* input_method_id = kExtraLanguages[i].input_method_id; | 82 const char* input_method_id = kExtraLanguages[i].input_method_id; |
| 83 InputMethodIdToDescriptorMap::const_iterator iter = | 83 InputMethodIdToDescriptorMap::const_iterator iter = |
| 84 id_to_descriptor->find(input_method_id); | 84 id_to_descriptor->find(input_method_id); |
| 85 // If the associated input method descriptor is found, add the | 85 // If the associated input method descriptor is found, add the |
| 86 // language code and the input method. | 86 // language code and the input method. |
| 87 if (iter != id_to_descriptor->end()) { | 87 if (iter != id_to_descriptor->end()) { |
| 88 const InputMethodDescriptor& input_method = iter->second; | 88 const InputMethodDescriptor& input_method = iter->second; |
| 89 language_code_to_ids->insert( | 89 language_code_to_ids->insert( |
| 90 std::make_pair(language_code, input_method.id())); | 90 std::make_pair(language_code, input_method.id())); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 351 } |
| 352 *out_string = l10n_util::GetStringUTF16(iter2->second); | 352 *out_string = l10n_util::GetStringUTF16(iter2->second); |
| 353 } else { | 353 } else { |
| 354 *out_string = l10n_util::GetStringUTF16(iter->second); | 354 *out_string = l10n_util::GetStringUTF16(iter->second); |
| 355 } | 355 } |
| 356 return true; | 356 return true; |
| 357 }; | 357 }; |
| 358 | 358 |
| 359 } // namespace | 359 } // namespace |
| 360 | 360 |
| 361 const ExtraLanguage kExtraLanguages[] = { |
| 362 // Language Code Input Method ID |
| 363 { "en-AU", "xkb:us::eng" }, // For Austrailia, use US keyboard layout. |
| 364 { "id", "xkb:us::eng" }, // For Indonesian, use US keyboard layout. |
| 365 // The code "fil" comes from app/l10_util.cc. |
| 366 { "fil", "xkb:us::eng" }, // For Filipino, use US keyboard layout. |
| 367 // For Netherlands, use US international keyboard layout. |
| 368 { "nl", "xkb:us:intl:eng" }, |
| 369 // The code "es-419" comes from app/l10_util.cc. |
| 370 // For Spanish in Latin America, use Latin American keyboard layout. |
| 371 { "es-419", "xkb:latam::spa" }, |
| 372 }; |
| 373 const size_t kExtraLanguagesLength = arraysize(kExtraLanguages); |
| 374 |
| 361 std::wstring GetString(const std::string& english_string, | 375 std::wstring GetString(const std::string& english_string, |
| 362 const std::string& input_method_id) { | 376 const std::string& input_method_id) { |
| 363 string16 localized_string; | 377 string16 localized_string; |
| 364 if (GetLocalizedString(english_string, input_method_id, &localized_string)) { | 378 if (GetLocalizedString(english_string, input_method_id, &localized_string)) { |
| 365 return UTF16ToWide(localized_string); | 379 return UTF16ToWide(localized_string); |
| 366 } | 380 } |
| 367 return UTF8ToWide(english_string); | 381 return UTF8ToWide(english_string); |
| 368 } | 382 } |
| 369 | 383 |
| 370 std::string GetStringUTF8(const std::string& english_string, | 384 std::string GetStringUTF8(const std::string& english_string, |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 void ReloadInternalMaps() { | 749 void ReloadInternalMaps() { |
| 736 IdMaps::GetInstance()->ReloadMaps(); | 750 IdMaps::GetInstance()->ReloadMaps(); |
| 737 } | 751 } |
| 738 | 752 |
| 739 void OnLocaleChanged() { | 753 void OnLocaleChanged() { |
| 740 ReloadInternalMaps(); | 754 ReloadInternalMaps(); |
| 741 } | 755 } |
| 742 | 756 |
| 743 } // namespace input_method | 757 } // namespace input_method |
| 744 } // namespace chromeos | 758 } // namespace chromeos |
| OLD | NEW |