Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: ui/base/l10n/l10n_util.cc

Issue 15987004: Translate: Filter and record languages whose names Chrome doesn't show (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified the test Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util.cc
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 9d806d5227c0963b47f6992fb3ff783c95aff9fa..995a277f9eaa090300534dffdf941ada17a2a6f9 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -208,19 +208,6 @@ bool IsDuplicateName(const std::string& locale_name) {
return false;
}
-bool IsLocaleNameTranslated(const char* locale,
- const std::string& display_locale) {
- string16 display_name =
- l10n_util::GetDisplayNameForLocale(locale, display_locale, false);
- // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not
- // uloc_getDisplayName returns the actual translation or the default
- // value (locale code), we have to rely on this hack to tell whether
- // the translation is available or not. If ICU doesn't have a translated
- // name for this locale, GetDisplayNameForLocale will just return the
- // locale code.
- return !IsStringASCII(display_name) || UTF16ToASCII(display_name) != locale;
-}
-
// We added 30+ minimally populated locales with only a few entries
// (exemplar character set, script, writing direction and its own
// lanaguage name). These locales have to be distinguished from the
@@ -230,7 +217,7 @@ bool IsLocalePartiallyPopulated(const std::string& locale_name) {
// is not available. A more robust/elegant way to check is to add a special
// field (say, 'isPartial' to our version of ICU locale files) and
// check its value, but this hack seems to work well.
- return !IsLocaleNameTranslated("en", locale_name);
+ return !l10n_util::IsLocaleNameTranslated("en", locale_name);
}
#if !defined(OS_MACOSX)
@@ -505,6 +492,19 @@ std::string GetApplicationLocale(const std::string& pref_locale) {
#endif
}
+bool IsLocaleNameTranslated(const char* locale,
+ const std::string& display_locale) {
+ string16 display_name =
+ l10n_util::GetDisplayNameForLocale(locale, display_locale, false);
+ // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not
+ // uloc_getDisplayName returns the actual translation or the default
+ // value (locale code), we have to rely on this hack to tell whether
+ // the translation is available or not. If ICU doesn't have a translated
+ // name for this locale, GetDisplayNameForLocale will just return the
+ // locale code.
+ return !IsStringASCII(display_name) || UTF16ToASCII(display_name) != locale;
+}
+
string16 GetDisplayNameForLocale(const std::string& locale,
const std::string& display_locale,
bool is_for_ui) {
@@ -843,7 +843,8 @@ const std::vector<std::string>& GetAvailableLocales() {
void GetAcceptLanguagesForLocale(const std::string& display_locale,
std::vector<std::string>* locale_codes) {
for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) {
- if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale))
+ if (!l10n_util::IsLocaleNameTranslated(kAcceptLanguageList[i],
+ display_locale))
// TODO(jungshik) : Put them at the of the list with language codes
// enclosed by brackets instead of skipping.
continue;
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698