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

Unified Diff: app/l10n_util.cc

Issue 192029: UI language list fix for the branch. (the trunk patch - essentially identical... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 3 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 | « no previous file | chrome/browser/views/options/languages_page_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/browser/views/options/languages_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698