Bug 1045053 - Part 0: add descriptive comments for locale handling. r=me
authorRichard Newman <rnewman@mozilla.com>
Wed, 01 Oct 2014 18:09:42 -0700
changeset 210313 5eb5877d73667148f3a56de978d758a647e5f9cb
parent 210312 1ecb840280ed29f4751c6ed837f109289ec69c39
child 210314 641e305c19fe2869133c2dc713dc71571af1fd09
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersme
bugs1045053
milestone36.0a1
Bug 1045053 - Part 0: add descriptive comments for locale handling. r=me
mobile/android/base/BrowserLocaleManager.java
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/BrowserLocaleManager.java
+++ b/mobile/android/base/BrowserLocaleManager.java
@@ -325,16 +325,19 @@ public class BrowserLocaleManager implem
         config.locale = locale;
         res.updateConfiguration(config, null);
     }
 
     private SharedPreferences getSharedPreferences(Context context) {
         return GeckoSharedPrefs.forApp(context);
     }
 
+    /**
+     * @return the persisted locale in Java format: "en_US".
+     */
     private String getPersistedLocale(Context context) {
         final SharedPreferences settings = getSharedPreferences(context);
         final String locale = settings.getString(PREF_LOCALE, "");
 
         if ("".equals(locale)) {
             return null;
         }
         return locale;
@@ -359,29 +362,35 @@ public class BrowserLocaleManager implem
     }
 
     /**
      * Updates the Java locale and the Android configuration.
      *
      * Returns the persisted locale if it differed.
      *
      * Does not notify Gecko.
+     *
+     * @param localeCode a locale string in Java format: "en_US".
+     * @return if it differed, a locale string in Java format: "en_US".
      */
     private String updateLocale(Context context, String localeCode) {
         // Fast path.
         final Locale defaultLocale = Locale.getDefault();
         if (defaultLocale.toString().equals(localeCode)) {
             return null;
         }
 
         final Locale locale = parseLocaleCode(localeCode);
 
         return updateLocale(context, locale);
     }
 
+    /**
+     * @return the Java locale string: e.g., "en_US".
+     */
     private String updateLocale(Context context, final Locale locale) {
         // Fast path.
         if (Locale.getDefault().equals(locale)) {
             return null;
         }
 
         Locale.setDefault(locale);
         currentLocale = locale;
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1319,16 +1319,17 @@ public abstract class GeckoApp
                 editor.apply();
 
                 // The lifecycle of mHealthRecorder is "shortly after onCreate"
                 // through "onDestroy" -- essentially the same as the lifecycle
                 // of the activity itself.
                 final String profilePath = getProfile().getDir().getAbsolutePath();
                 final EventDispatcher dispatcher = EventDispatcher.getInstance();
 
+                // Both of these are Java-format locale strings: "en_US", not "en-US".
                 final String osLocale = Locale.getDefault().toString();
                 String appLocale = localeManager.getAndApplyPersistedLocale(GeckoApp.this);
                 Log.d(LOGTAG, "OS locale is " + osLocale + ", app locale is " + appLocale);
 
                 if (appLocale == null) {
                     appLocale = osLocale;
                 }