mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1378501 - Tell Gecko when the OS locale changes, even when backgrounded. r=mcomella
This ensures that `intl.locale.os` is always set, even if the system locale changes while Fennec is in the background. This commit also restores `Strings.flush()` calls that are necessary to have Fennec's non-Java UI reflect locale changes. With this commit, the geolocation popup still doesn't behave correctly: when the locale system is set to match OS locale, although the pref is set the locale doesn't change. This applies in two scenarios: on first run (the popup is always English) and when the locale changes at runtime (the popup uses an earlier OS locale). Bug 1397925 should complete the fix. MozReview-Commit-ID: 8zeZuYXFYdy --HG-- extra : rebase_source : 9da9aae7ed8420faa7567c9db29b1110b3289d9f
This commit is contained in:
parent
fe57261f21
commit
f31d98a272
@ -106,6 +106,10 @@ public class BrowserLocaleManager implements LocaleManager {
|
||||
systemLocaleDidChange = true;
|
||||
|
||||
Log.d(LOG_TAG, "System locale changed from " + current + " to " + systemLocale);
|
||||
|
||||
// If the OS locale changed, we need to tell Gecko.
|
||||
final SharedPreferences prefs = GeckoSharedPrefs.forProfile(context);
|
||||
BrowserLocaleManager.storeAndNotifyOSLocale(prefs, systemLocale);
|
||||
}
|
||||
};
|
||||
context.registerReceiver(receiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
|
||||
@ -208,6 +212,7 @@ public class BrowserLocaleManager implements LocaleManager {
|
||||
final String osLocaleString = osLocale.toString();
|
||||
|
||||
if (osLocaleString.equals(lastOSLocale)) {
|
||||
Log.d(LOG_TAG, "Previous locale " + lastOSLocale + " same as new. Doing nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -218,6 +223,7 @@ public class BrowserLocaleManager implements LocaleManager {
|
||||
// a Java locale string.
|
||||
final GeckoBundle data = new GeckoBundle(1);
|
||||
data.putString("languageTag", Locales.getLanguageTag(osLocale));
|
||||
|
||||
EventDispatcher.getInstance().dispatch("Locale:OS", data);
|
||||
}
|
||||
|
||||
@ -304,6 +310,10 @@ public class BrowserLocaleManager implements LocaleManager {
|
||||
}
|
||||
|
||||
private SharedPreferences getSharedPreferences(Context context) {
|
||||
// We should be using per-profile prefs here, because we're tracking against
|
||||
// a Gecko pref. The same applies to the locale switcher!
|
||||
// Bug 940575, Bug 873166 are relevant, and see Bug 1378501 for the commit
|
||||
// that added this comment.
|
||||
return GeckoSharedPrefs.forApp(context);
|
||||
}
|
||||
|
||||
|
@ -1742,6 +1742,9 @@ var BrowserApp = {
|
||||
let appLocale = this.getUALocalePref();
|
||||
|
||||
this.computeAcceptLanguages(languageTag, appLocale);
|
||||
|
||||
// Rebuild strings, in case we're mirroring OS locale.
|
||||
Strings.flush();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1752,6 +1755,11 @@ var BrowserApp = {
|
||||
Services.locale.setRequestedLocales([]);
|
||||
}
|
||||
|
||||
console.log("Gecko display locale: " + this.getUALocalePref());
|
||||
|
||||
// Rebuild strings to reflect the new locale.
|
||||
Strings.flush();
|
||||
|
||||
// Make sure we use the right Accept-Language header.
|
||||
let osLocale;
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user