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 continue; | 170 // Try to translate language code and look up again. |
| 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. |
171 } | 182 } |
172 | 183 |
173 const base::string16 display_name = | 184 const base::string16 display_name = |
174 l10n_util::GetDisplayNameForLocale(*it, app_locale, true); | 185 l10n_util::GetDisplayNameForLocale(*it, app_locale, true); |
175 const base::string16 native_display_name = | 186 const base::string16 native_display_name = |
176 l10n_util::GetDisplayNameForLocale(*it, *it, true); | 187 l10n_util::GetDisplayNameForLocale(*it, *it, true); |
177 | 188 |
178 language_map[display_name] = | 189 language_map[display_name] = |
179 std::make_pair(*it, native_display_name); | 190 std::make_pair(*it, native_display_name); |
180 | 191 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 503 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
493 const input_method::InputMethodDescriptor current_input_method = | 504 const input_method::InputMethodDescriptor current_input_method = |
494 input_method::InputMethodManager::Get() | 505 input_method::InputMethodManager::Get() |
495 ->GetActiveIMEState() | 506 ->GetActiveIMEState() |
496 ->GetCurrentInputMethod(); | 507 ->GetCurrentInputMethod(); |
497 return CreateInputMethodsEntry(current_input_method, | 508 return CreateInputMethodsEntry(current_input_method, |
498 current_input_method.id()); | 509 current_input_method.id()); |
499 } | 510 } |
500 | 511 |
501 } // namespace chromeos | 512 } // namespace chromeos |
OLD | NEW |