mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1337551: Migrate Services.jsm to use LocaleService. r=mossop
MozReview-Commit-ID: G0HFXfg4r6Y --HG-- extra : rebase_source : 2217abbb1371132b82574be690f9fab5c1b64fb7
This commit is contained in:
parent
78a1fe605c
commit
c286b2ef87
@ -110,8 +110,7 @@ exports.testPreferedOsLocale = function(assert) {
|
||||
prefs.set(PREF_SELECTED_LOCALE, "");
|
||||
prefs.set(PREF_ACCEPT_LANGUAGES, "");
|
||||
|
||||
let expectedLocale = Services.locale.getLocaleComponentForUserAgent().
|
||||
toLowerCase();
|
||||
let expectedLocale = Services.locale.getAppLocale().toLowerCase();
|
||||
let expectedLocaleList = [expectedLocale];
|
||||
|
||||
// Add default "en-us" fallback if the main language is not already en-us
|
||||
|
@ -194,7 +194,8 @@ var DirectoryLinksProvider = {
|
||||
} catch (e) {}
|
||||
|
||||
if (matchOS) {
|
||||
return Services.locale.getLocaleComponentForUserAgent();
|
||||
return Cc["@mozilla.org/intl/ospreferences;1"].
|
||||
getService(Ci.mozIOSPreferences).getSystemLocale();
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -230,9 +230,7 @@ function enforceBoolean(aValue) {
|
||||
*/
|
||||
function getBrowserLocale() {
|
||||
try {
|
||||
return Cc["@mozilla.org/chrome/chrome-registry;1"].
|
||||
getService(Ci.nsIXULChromeRegistry).
|
||||
getSelectedLocale("global");
|
||||
return Services.locale.getAppLocale();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@ -244,7 +242,9 @@ function getBrowserLocale() {
|
||||
*/
|
||||
function getSystemLocale() {
|
||||
try {
|
||||
return Services.locale.getLocaleComponentForUserAgent();
|
||||
return Cc["@mozilla.org/intl/ospreferences;1"].
|
||||
getService(Ci.mozIOSPreferences).
|
||||
getSystemLocale();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -18,8 +18,11 @@ this.Locale = {
|
||||
* @return the selected locale or "en-US" if none is selected
|
||||
*/
|
||||
getLocale() {
|
||||
if (Preferences.get(PREF_MATCH_OS_LOCALE, false))
|
||||
return Services.locale.getLocaleComponentForUserAgent();
|
||||
if (Preferences.get(PREF_MATCH_OS_LOCALE, false)) {
|
||||
const osPrefs =
|
||||
Cc["@mozilla.org/intl/ospreferences;1"].getService(Ci.mozIOSPreferences);
|
||||
return osPrefs.getSystemLocale();
|
||||
}
|
||||
try {
|
||||
let locale = Preferences.get(PREF_SELECTED_LOCALE, null, Ci.nsIPrefLocalizedString);
|
||||
if (locale)
|
||||
|
@ -75,7 +75,7 @@ var initTable = [
|
||||
["els", "@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"],
|
||||
["eTLD", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService"],
|
||||
["io", "@mozilla.org/network/io-service;1", "nsIIOService2"],
|
||||
["locale", "@mozilla.org/intl/nslocaleservice;1", "nsILocaleService"],
|
||||
["locale", "@mozilla.org/intl/localeservice;1", "mozILocaleService"],
|
||||
["logins", "@mozilla.org/login-manager;1", "nsILoginManager"],
|
||||
["obs", "@mozilla.org/observer-service;1", "nsIObserverService"],
|
||||
["perms", "@mozilla.org/permissionmanager;1", "nsIPermissionManager"],
|
||||
|
@ -45,7 +45,7 @@ function run_test() {
|
||||
checkService("focus", Ci.nsIFocusManager);
|
||||
checkService("io", Ci.nsIIOService);
|
||||
checkService("io", Ci.nsIIOService2);
|
||||
checkService("locale", Ci.nsILocaleService);
|
||||
checkService("locale", Ci.mozILocaleService);
|
||||
checkService("logins", Ci.nsILoginManager);
|
||||
checkService("obs", Ci.nsIObserverService);
|
||||
checkService("perms", Ci.nsIPermissionManager);
|
||||
|
@ -329,8 +329,11 @@ function promiseCallProvider(aProvider, aMethod, ...aArgs) {
|
||||
*/
|
||||
function getLocale() {
|
||||
try {
|
||||
if (Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE))
|
||||
return Services.locale.getLocaleComponentForUserAgent();
|
||||
if (Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE)) {
|
||||
const osPrefs =
|
||||
Cc["@mozilla.org/intl/ospreferences;1"].getService(Ci.mozIOSPreferences);
|
||||
return osPrefs.getSystemLocale();
|
||||
}
|
||||
} catch (e) { }
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user