Bug 1065523 - Part 1: locale picker screen displays short locale display name, not capitalized region-decorated name. r=nalexander, a=sledru
authorRichard Newman <rnewman@mozilla.com>
Wed, 10 Sep 2014 12:01:35 -0700
changeset 217882 cea1db6ec4ac4c1b761cb5c27100e8a1fba0dfad
parent 217881 60aecc9d11ab2cddf1e263f02224dbe3607ee9e4
child 217883 bd8bbb683257442d62d85772026db7578837379a
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, sledru
bugs1065523
milestone33.0
Bug 1065523 - Part 1: locale picker screen displays short locale display name, not capitalized region-decorated name. r=nalexander, a=sledru What I think was happening here: we were taking a locale *tag* ("en-US") and giving it to the Java Locale constructor to parse. It parsed that as "en" (because it expects _ not -), so we'd get "English". And because it was the display string from the locale, in e.g., French we'd get "fran├žais", lowercase. The fix is to just use the same code path that we use for the list picker itself -- make a descriptor from the tag, and ask it for its display string.
mobile/android/base/preferences/LocaleListPreference.java
--- a/mobile/android/base/preferences/LocaleListPreference.java
+++ b/mobile/android/base/preferences/LocaleListPreference.java
@@ -266,18 +266,17 @@ public class LocaleListPreference extend
         final String value = getValue();
 
         if (TextUtils.isEmpty(value)) {
             return getContext().getString(R.string.locale_system_default);
         }
 
         // We can't trust super.getSummary() across locale changes,
         // apparently, so let's do the same work.
-        final Locale loc = new Locale(value);
-        return loc.getDisplayName(loc);
+        return new LocaleDescriptor(value).getDisplayName();
     }
 
     private void buildList() {
         final Locale currentLocale = Locale.getDefault();
         Log.d(LOG_TAG, "Building locales list. Current locale: " + currentLocale);
 
         if (currentLocale.equals(this.entriesLocale) &&
             getEntries() != null) {