| 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/login/language_list.h" | 5 #include "chrome/browser/chromeos/login/language_list.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 DCHECK(locale_data != native_names_.end()); | 29 DCHECK(locale_data != native_names_.end()); |
| 30 | 30 |
| 31 // If the name is the same in the native language and local language, | 31 // If the name is the same in the native language and local language, |
| 32 // don't show it twice. | 32 // don't show it twice. |
| 33 if (locale_data->second.native_name == locale_names_[index]) | 33 if (locale_data->second.native_name == locale_names_[index]) |
| 34 return locale_data->second.native_name; | 34 return locale_data->second.native_name; |
| 35 | 35 |
| 36 // We must add directionality formatting to both the native name and the | 36 // We must add directionality formatting to both the native name and the |
| 37 // locale name in order to avoid text rendering problems such as misplaced | 37 // locale name in order to avoid text rendering problems such as misplaced |
| 38 // parentheses or languages appearing in the wrong order. | 38 // parentheses or languages appearing in the wrong order. |
| 39 string16 locale_name = locale_names_[index]; | 39 base::string16 locale_name = locale_names_[index]; |
| 40 base::i18n::AdjustStringForLocaleDirection(&locale_name); | 40 base::i18n::AdjustStringForLocaleDirection(&locale_name); |
| 41 | 41 |
| 42 string16 native_name = locale_data->second.native_name; | 42 base::string16 native_name = locale_data->second.native_name; |
| 43 base::i18n::AdjustStringForLocaleDirection(&native_name); | 43 base::i18n::AdjustStringForLocaleDirection(&native_name); |
| 44 | 44 |
| 45 // We used to have a localizable template here, but none of translators | 45 // We used to have a localizable template here, but none of translators |
| 46 // changed the format. We also want to switch the order of locale_name | 46 // changed the format. We also want to switch the order of locale_name |
| 47 // and native_name without going back to translators. | 47 // and native_name without going back to translators. |
| 48 std::string formatted_item; | 48 std::string formatted_item; |
| 49 base::SStringPrintf(&formatted_item, "%s - %s", | 49 base::SStringPrintf(&formatted_item, "%s - %s", |
| 50 UTF16ToUTF8(locale_name).c_str(), | 50 UTF16ToUTF8(locale_name).c_str(), |
| 51 UTF16ToUTF8(native_name).c_str()); | 51 UTF16ToUTF8(native_name).c_str()); |
| 52 if (base::i18n::IsRTL()) | 52 if (base::i18n::IsRTL()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 void LanguageList::InitNativeNames( | 90 void LanguageList::InitNativeNames( |
| 91 const std::vector<std::string>& locale_codes) { | 91 const std::vector<std::string>& locale_codes) { |
| 92 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 92 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 93 for (size_t i = 0; i < locale_codes.size(); ++i) { | 93 for (size_t i = 0; i < locale_codes.size(); ++i) { |
| 94 const char* locale_code = locale_codes[i].c_str(); | 94 const char* locale_code = locale_codes[i].c_str(); |
| 95 | 95 |
| 96 // TODO(jungshik): Even though these strings are used for the UI, | 96 // TODO(jungshik): Even though these strings are used for the UI, |
| 97 // the old code does not add an RTL mark for RTL locales. Make sure | 97 // the old code does not add an RTL mark for RTL locales. Make sure |
| 98 // that it's ok without that. | 98 // that it's ok without that. |
| 99 string16 name_in_current_ui = | 99 base::string16 name_in_current_ui = |
| 100 l10n_util::GetDisplayNameForLocale(locale_code, app_locale, false); | 100 l10n_util::GetDisplayNameForLocale(locale_code, app_locale, false); |
| 101 string16 name_native = | 101 base::string16 name_native = |
| 102 l10n_util::GetDisplayNameForLocale(locale_code, locale_code, false); | 102 l10n_util::GetDisplayNameForLocale(locale_code, locale_code, false); |
| 103 | 103 |
| 104 locale_names_.push_back(name_in_current_ui); | 104 locale_names_.push_back(name_in_current_ui); |
| 105 native_names_[name_in_current_ui] = | 105 native_names_[name_in_current_ui] = |
| 106 LocaleData(name_native, locale_codes[i]); | 106 LocaleData(name_native, locale_codes[i]); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Sort using locale specific sorter. | 109 // Sort using locale specific sorter. |
| 110 l10n_util::SortStrings16(g_browser_process->GetApplicationLocale(), | 110 l10n_util::SortStrings16(g_browser_process->GetApplicationLocale(), |
| 111 &locale_names_); | 111 &locale_names_); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace chromeos | 114 } // namespace chromeos |
| OLD | NEW |