Index: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc |
diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc |
index fec16e0b2c8758335b75adcad7b839dc020f6a4c..93607283d5cb7d81b8923286ba74d37dce409d5c 100644 |
--- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc |
+++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc |
@@ -233,7 +233,52 @@ base::ListValue* CrosLanguageOptionsHandler::GetLanguageListInternal( |
configured_locales.size()); |
size_t configured_locales_count = 0; |
+ |
// Build the list of display names, and build the language map. |
+ |
+ // The list of configured locales might have entries not in |
+ // base_language_codes. If there are unsipported language variants, |
+ // replace them with base language from base_language_codes if supported. |
+ for (std::map<std::string, int>::const_iterator iter = language_index.begin(); |
+ iter != language_index.end(); |
+ ++iter) { |
+ const std::string& language_id = iter->first; |
+ const int language_idx = iter->second; |
+ |
+ const size_t dash_pos = language_id.find_first_of('-'); |
+ |
+ // Ignore non-specific codes. |
+ if (dash_pos == std::string::npos || dash_pos == 0) |
+ continue; |
+ |
+ if (std::find(base_language_codes.begin(), |
+ base_language_codes.end(), |
+ language_id) != base_language_codes.end()) { |
+ // Language is supported. No need to replace |
+ continue; |
+ } |
+ const std::string base_language_code = language_id.substr(0, dash_pos); |
+ if (std::find(base_language_codes.begin(), |
+ base_language_codes.end(), |
+ base_language_code) == base_language_codes.end()) { |
+ // Base language is not supported. |
+ continue; |
+ } |
+ |
+ const base::string16 display_name = |
+ l10n_util::GetDisplayNameForLocale(language_id, app_locale, true); |
+ const base::string16 native_display_name = |
+ l10n_util::GetDisplayNameForLocale( |
+ language_id, base_language_code, true); |
jungshik at Google
2014/04/04 08:27:08
You can just use |language_id| instead of |base_la
Alexander Alekseev
2014/04/05 01:18:32
Done.
|
+ |
+ language_map[display_name] = |
+ std::make_pair(language_id, native_display_name); |
+ |
+ configured_locales_display_names[language_idx] = display_name; |
+ ++configured_locales_count; |
+ } |
+ |
+ // Translate language codes, generated from input methods. |
for (std::set<std::string>::const_iterator iter = language_codes.begin(); |
iter != language_codes.end(); ++iter) { |
// Exclude the language which is not in |base_langauge_codes| even it has |
@@ -255,8 +300,12 @@ base::ListValue* CrosLanguageOptionsHandler::GetLanguageListInternal( |
const std::map<std::string, int>::const_iterator index_pos = |
language_index.find(*iter); |
if (index_pos != language_index.end()) { |
- configured_locales_display_names[index_pos->second] = display_name; |
- ++configured_locales_count; |
+ base::string16& stored_display_name = |
+ configured_locales_display_names[index_pos->second]; |
+ if (stored_display_name.empty()) { |
+ stored_display_name = display_name; |
+ ++configured_locales_count; |
+ } |
} else { |
display_names.push_back(display_name); |
} |