Index: app/l10n_util.cc |
=================================================================== |
--- app/l10n_util.cc (revision 24676) |
+++ app/l10n_util.cc (working copy) |
@@ -121,6 +121,31 @@ |
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 |
+// fully populated locales to which Chrome is localized. |
+bool IsLocalePartiallyPopulated(const std::string& locale_name) { |
+ // For partially populated locales, even the translation for "English" |
+ // 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); |
+} |
+ |
bool IsLocaleAvailable(const std::string& locale, |
const FilePath& locale_path) { |
// If locale has any illegal characters in it, we don't want to try to |
@@ -718,6 +743,10 @@ |
// Filter out the names that have aliases. |
if (IsDuplicateName(locale_name)) |
continue; |
+ // Filter out locales for which we have only partially populated data |
+ // and to which Chrome is not localized. |
+ if (IsLocalePartiallyPopulated(locale_name)) |
+ continue; |
if (!IsLocaleSupportedByOS(locale_name)) |
continue; |
// Normalize underscores to hyphens because that's what our locale files |