| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/chromeos/login/l10n_util.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Translate language codes, generated from input methods. | 162 // Translate language codes, generated from input methods. |
| 163 for (std::set<std::string>::const_iterator it = language_codes.begin(); | 163 for (std::set<std::string>::const_iterator it = language_codes.begin(); |
| 164 it != language_codes.end(); ++it) { | 164 it != language_codes.end(); ++it) { |
| 165 // Exclude the language which is not in |base_langauge_codes| even it has | 165 // Exclude the language which is not in |base_langauge_codes| even it has |
| 166 // input methods. | 166 // input methods. |
| 167 if (std::find(base_language_codes.begin(), | 167 if (std::find(base_language_codes.begin(), |
| 168 base_language_codes.end(), | 168 base_language_codes.end(), |
| 169 *it) == base_language_codes.end()) { | 169 *it) == base_language_codes.end()) { |
| 170 // Try to translate language code and look up again. | 170 continue; |
| 171 std::string resolved_locale; | |
| 172 | |
| 173 if (!l10n_util::CheckAndResolveLocale(*it, &resolved_locale)) | |
| 174 continue; | |
| 175 | |
| 176 if (std::find(base_language_codes.begin(), | |
| 177 base_language_codes.end(), | |
| 178 resolved_locale) == base_language_codes.end()) { | |
| 179 continue; | |
| 180 } | |
| 181 // Translated language was successfully found. | |
| 182 } | 171 } |
| 183 | 172 |
| 184 const base::string16 display_name = | 173 const base::string16 display_name = |
| 185 l10n_util::GetDisplayNameForLocale(*it, app_locale, true); | 174 l10n_util::GetDisplayNameForLocale(*it, app_locale, true); |
| 186 const base::string16 native_display_name = | 175 const base::string16 native_display_name = |
| 187 l10n_util::GetDisplayNameForLocale(*it, *it, true); | 176 l10n_util::GetDisplayNameForLocale(*it, *it, true); |
| 188 | 177 |
| 189 language_map[display_name] = | 178 language_map[display_name] = |
| 190 std::make_pair(*it, native_display_name); | 179 std::make_pair(*it, native_display_name); |
| 191 | 180 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 492 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
| 504 const input_method::InputMethodDescriptor current_input_method = | 493 const input_method::InputMethodDescriptor current_input_method = |
| 505 input_method::InputMethodManager::Get() | 494 input_method::InputMethodManager::Get() |
| 506 ->GetActiveIMEState() | 495 ->GetActiveIMEState() |
| 507 ->GetCurrentInputMethod(); | 496 ->GetCurrentInputMethod(); |
| 508 return CreateInputMethodsEntry(current_input_method, | 497 return CreateInputMethodsEntry(current_input_method, |
| 509 current_input_method.id()); | 498 current_input_method.id()); |
| 510 } | 499 } |
| 511 | 500 |
| 512 } // namespace chromeos | 501 } // namespace chromeos |
| OLD | NEW |