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_SELECTED_LOCALE, "");
|
||||||
prefs.set(PREF_ACCEPT_LANGUAGES, "");
|
prefs.set(PREF_ACCEPT_LANGUAGES, "");
|
||||||
|
|
||||||
let expectedLocale = Services.locale.getLocaleComponentForUserAgent().
|
let expectedLocale = Services.locale.getAppLocale().toLowerCase();
|
||||||
toLowerCase();
|
|
||||||
let expectedLocaleList = [expectedLocale];
|
let expectedLocaleList = [expectedLocale];
|
||||||
|
|
||||||
// Add default "en-us" fallback if the main language is not already en-us
|
// Add default "en-us" fallback if the main language is not already en-us
|
||||||
|
@ -194,7 +194,8 @@ var DirectoryLinksProvider = {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
if (matchOS) {
|
if (matchOS) {
|
||||||
return Services.locale.getLocaleComponentForUserAgent();
|
return Cc["@mozilla.org/intl/ospreferences;1"].
|
||||||
|
getService(Ci.mozIOSPreferences).getSystemLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -230,9 +230,7 @@ function enforceBoolean(aValue) {
|
|||||||
*/
|
*/
|
||||||
function getBrowserLocale() {
|
function getBrowserLocale() {
|
||||||
try {
|
try {
|
||||||
return Cc["@mozilla.org/chrome/chrome-registry;1"].
|
return Services.locale.getAppLocale();
|
||||||
getService(Ci.nsIXULChromeRegistry).
|
|
||||||
getSelectedLocale("global");
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -244,7 +242,9 @@ function getBrowserLocale() {
|
|||||||
*/
|
*/
|
||||||
function getSystemLocale() {
|
function getSystemLocale() {
|
||||||
try {
|
try {
|
||||||
return Services.locale.getLocaleComponentForUserAgent();
|
return Cc["@mozilla.org/intl/ospreferences;1"].
|
||||||
|
getService(Ci.mozIOSPreferences).
|
||||||
|
getSystemLocale();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ this.Locale = {
|
|||||||
* @return the selected locale or "en-US" if none is selected
|
* @return the selected locale or "en-US" if none is selected
|
||||||
*/
|
*/
|
||||||
getLocale() {
|
getLocale() {
|
||||||
if (Preferences.get(PREF_MATCH_OS_LOCALE, false))
|
if (Preferences.get(PREF_MATCH_OS_LOCALE, false)) {
|
||||||
return Services.locale.getLocaleComponentForUserAgent();
|
const osPrefs =
|
||||||
|
Cc["@mozilla.org/intl/ospreferences;1"].getService(Ci.mozIOSPreferences);
|
||||||
|
return osPrefs.getSystemLocale();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
let locale = Preferences.get(PREF_SELECTED_LOCALE, null, Ci.nsIPrefLocalizedString);
|
let locale = Preferences.get(PREF_SELECTED_LOCALE, null, Ci.nsIPrefLocalizedString);
|
||||||
if (locale)
|
if (locale)
|
||||||
|
@ -75,7 +75,7 @@ var initTable = [
|
|||||||
["els", "@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"],
|
["els", "@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"],
|
||||||
["eTLD", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService"],
|
["eTLD", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService"],
|
||||||
["io", "@mozilla.org/network/io-service;1", "nsIIOService2"],
|
["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"],
|
["logins", "@mozilla.org/login-manager;1", "nsILoginManager"],
|
||||||
["obs", "@mozilla.org/observer-service;1", "nsIObserverService"],
|
["obs", "@mozilla.org/observer-service;1", "nsIObserverService"],
|
||||||
["perms", "@mozilla.org/permissionmanager;1", "nsIPermissionManager"],
|
["perms", "@mozilla.org/permissionmanager;1", "nsIPermissionManager"],
|
||||||
|
@ -45,7 +45,7 @@ function run_test() {
|
|||||||
checkService("focus", Ci.nsIFocusManager);
|
checkService("focus", Ci.nsIFocusManager);
|
||||||
checkService("io", Ci.nsIIOService);
|
checkService("io", Ci.nsIIOService);
|
||||||
checkService("io", Ci.nsIIOService2);
|
checkService("io", Ci.nsIIOService2);
|
||||||
checkService("locale", Ci.nsILocaleService);
|
checkService("locale", Ci.mozILocaleService);
|
||||||
checkService("logins", Ci.nsILoginManager);
|
checkService("logins", Ci.nsILoginManager);
|
||||||
checkService("obs", Ci.nsIObserverService);
|
checkService("obs", Ci.nsIObserverService);
|
||||||
checkService("perms", Ci.nsIPermissionManager);
|
checkService("perms", Ci.nsIPermissionManager);
|
||||||
|
@ -329,8 +329,11 @@ function promiseCallProvider(aProvider, aMethod, ...aArgs) {
|
|||||||
*/
|
*/
|
||||||
function getLocale() {
|
function getLocale() {
|
||||||
try {
|
try {
|
||||||
if (Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE))
|
if (Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE)) {
|
||||||
return Services.locale.getLocaleComponentForUserAgent();
|
const osPrefs =
|
||||||
|
Cc["@mozilla.org/intl/ospreferences;1"].getService(Ci.mozIOSPreferences);
|
||||||
|
return osPrefs.getSystemLocale();
|
||||||
|
}
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user