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 216760 cea1db6ec4ac
parent 216759 60aecc9d11ab
child 216761 bd8bbb683257
push id3904
push userryanvm@gmail.com
push date2014-09-16 12:09 +0000
treeherdermozilla-beta@cea1db6ec4ac [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) {