mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1491394 - Update callsites to use new mozILocaleService API. r=jfkthame
Depends on D5924 Differential Revision: https://phabricator.services.mozilla.com/D6339 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
8fdbb6d26b
commit
83ea94f5ba
@ -865,7 +865,7 @@ XPCOMUtils.defineConstant(this, "PanelUI", PanelUI);
|
||||
* @return the selected locale
|
||||
*/
|
||||
function getLocale() {
|
||||
return Services.locale.getAppLocaleAsLangTag();
|
||||
return Services.locale.appLocaleAsLangTag;
|
||||
}
|
||||
|
||||
function getNotificationFromElement(aElement) {
|
||||
|
@ -82,7 +82,7 @@ DistributionCustomizer.prototype = {
|
||||
},
|
||||
|
||||
get _locale() {
|
||||
const locale = Services.locale.getRequestedLocale() || "en-US";
|
||||
const locale = Services.locale.requestedLocale || "en-US";
|
||||
this.__defineGetter__("_locale", () => locale);
|
||||
return this._locale;
|
||||
},
|
||||
|
@ -13,11 +13,11 @@
|
||||
//
|
||||
// In the future, we should provide some way for tests to decouple their
|
||||
// language selection from that of Firefox.
|
||||
const avLocales = Services.locale.getAvailableLocales();
|
||||
const avLocales = Services.locale.availableLocales;
|
||||
|
||||
Services.locale.setAvailableLocales(["en-US", "es-ES"]);
|
||||
Services.locale.availableLocales = ["en-US", "es-ES"];
|
||||
registerCleanupFunction(() => {
|
||||
Services.locale.setAvailableLocales(avLocales);
|
||||
Services.locale.availableLocales = avLocales;
|
||||
});
|
||||
}
|
||||
|
||||
@ -152,8 +152,8 @@ async function runTests(options) {
|
||||
});
|
||||
});
|
||||
|
||||
let reqLoc = Services.locale.getRequestedLocales();
|
||||
Services.locale.setRequestedLocales(["es-ES"]);
|
||||
let reqLoc = Services.locale.requestedLocales;
|
||||
Services.locale.requestedLocales = ["es-ES"];
|
||||
|
||||
await extension.startup();
|
||||
|
||||
@ -161,7 +161,7 @@ async function runTests(options) {
|
||||
|
||||
await extension.unload();
|
||||
|
||||
Services.locale.setRequestedLocales(reqLoc);
|
||||
Services.locale.requestedLocales = reqLoc;
|
||||
|
||||
let node = document.getElementById(pageActionId);
|
||||
is(node, null, "pageAction image removed from document");
|
||||
|
@ -661,7 +661,7 @@ const AutoMigrate = {
|
||||
// lead to a an array with 1 empty string in it.
|
||||
surveyLocales = new Set(surveyLocales.filter(str => !!str));
|
||||
canDoSurveyInLocale =
|
||||
surveyLocales.has(Services.locale.getAppLocaleAsLangTag());
|
||||
surveyLocales.has(Services.locale.appLocaleAsLangTag);
|
||||
} catch (ex) {
|
||||
/* ignore exceptions and just don't do the survey. */
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ AboutNewTabService.prototype = {
|
||||
return Services.locale.negotiateLanguages(
|
||||
// Fix up incorrect BCP47 that are actually lang tags as a workaround for
|
||||
// bug 1479606 returning the wrong values in the content process
|
||||
Services.locale.getAppLocalesAsBCP47().map(l => l.replace(/^(ja-JP-mac)$/, "$1os")),
|
||||
Services.locale.appLocalesAsBCP47.map(l => l.replace(/^(ja-JP-mac)$/, "$1os")),
|
||||
ACTIVITY_STREAM_BCP47,
|
||||
// defaultLocale's strings aren't necessarily packaged, but en-US' are
|
||||
"en-US",
|
||||
|
@ -151,7 +151,7 @@ const MessageLoaderUtils = {
|
||||
},
|
||||
|
||||
_getRemoteSettingsMessages(bucket) {
|
||||
return RemoteSettings(bucket).get({filters: {locale: Services.locale.getAppLocaleAsLangTag()}});
|
||||
return RemoteSettings(bucket).get({filters: {locale: Services.locale.appLocaleAsLangTag}});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -441,7 +441,7 @@ this.ActivityStream = class ActivityStream {
|
||||
this.geo = "";
|
||||
}
|
||||
|
||||
this.locale = Services.locale.getAppLocaleAsLangTag();
|
||||
this.locale = Services.locale.appLocaleAsLangTag;
|
||||
|
||||
// Update the pref config of those with dynamic values
|
||||
for (const pref of PREFS_CONFIG.keys()) {
|
||||
|
@ -328,7 +328,7 @@ this.TelemetryFeed = class TelemetryFeed {
|
||||
createPing(portID) {
|
||||
const ping = {
|
||||
addon_version: Services.appinfo.appBuildID,
|
||||
locale: Services.locale.getAppLocaleAsLangTag(),
|
||||
locale: Services.locale.appLocaleAsLangTag,
|
||||
user_prefs: this.userPreferences,
|
||||
};
|
||||
|
||||
@ -412,7 +412,7 @@ this.TelemetryFeed = class TelemetryFeed {
|
||||
const ping = {
|
||||
client_id: "n/a",
|
||||
addon_version: Services.appinfo.appBuildID,
|
||||
locale: Services.locale.getAppLocaleAsLangTag(),
|
||||
locale: Services.locale.appLocaleAsLangTag,
|
||||
impression_id: this._impressionId,
|
||||
};
|
||||
if (action.data.includeClientID) {
|
||||
|
@ -10,16 +10,16 @@ const DEFAULT_URL = "resource://activity-stream/prerendered/en-US/activity-strea
|
||||
* Temporarily change the app locale to get the localized activity stream url
|
||||
*/
|
||||
async function getUrlForLocale(locale) {
|
||||
const origAvailable = Services.locale.getAvailableLocales();
|
||||
const origRequested = Services.locale.getRequestedLocales();
|
||||
const origAvailable = Services.locale.availableLocales;
|
||||
const origRequested = Services.locale.requestedLocales;
|
||||
try {
|
||||
Services.locale.setAvailableLocales([locale]);
|
||||
Services.locale.setRequestedLocales([locale]);
|
||||
Services.locale.availableLocales = [locale];
|
||||
Services.locale.requestedLocales = [locale];
|
||||
return aboutNewTabService.defaultURL;
|
||||
} finally {
|
||||
// Always clean up after returning the url
|
||||
Services.locale.setAvailableLocales(origAvailable);
|
||||
Services.locale.setRequestedLocales(origRequested);
|
||||
Services.locale.availableLocales = origAvailable;
|
||||
Services.locale.requestedLocales = origRequested;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ describe("ActivityStream", () => {
|
||||
it("should be false with expected geo and unexpected locale", () => {
|
||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("US");
|
||||
sandbox.stub(global.Services.locale, "getAppLocaleAsLangTag").returns("no-LOCALE");
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").returns("no-LOCALE");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
@ -264,7 +264,7 @@ describe("ActivityStream", () => {
|
||||
it("should be true with expected geo and locale", () => {
|
||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("US");
|
||||
sandbox.stub(global.Services.locale, "getAppLocaleAsLangTag").returns("en-US");
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").returns("en-US");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
@ -277,7 +277,7 @@ describe("ActivityStream", () => {
|
||||
.returns("US")
|
||||
.onSecondCall()
|
||||
.returns("NOGEO");
|
||||
sandbox.stub(global.Services.locale, "getAppLocaleAsLangTag").returns("en-US");
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").returns("en-US");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
as._updateDynamicPrefs();
|
||||
@ -308,7 +308,7 @@ describe("ActivityStream", () => {
|
||||
});
|
||||
it("should set true with expected geo and locale", () => {
|
||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("US");
|
||||
sandbox.stub(global.Services.locale, "getAppLocaleAsLangTag").returns("en-US");
|
||||
sandbox.stub(global.Services.locale, "appLocaleAsLangTag").returns("en-US");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
clock.tick(1);
|
||||
|
@ -106,8 +106,8 @@ const TEST_GLOBAL = {
|
||||
DownloadsViewUI: {DownloadElementShell},
|
||||
Services: {
|
||||
locale: {
|
||||
getAppLocaleAsLangTag() { return "en-US"; },
|
||||
getAppLocalesAsLangTags() {},
|
||||
appLocaleAsLangTag: "en-US",
|
||||
appLocalesAsLangtags: [],
|
||||
negotiateLanguages() {},
|
||||
},
|
||||
urlFormatter: {formatURL: str => str, formatURLPref: str => str},
|
||||
|
@ -1061,7 +1061,7 @@ BrowserGlue.prototype = {
|
||||
Normandy.init();
|
||||
|
||||
// Initialize the default l10n resource sources for L10nRegistry.
|
||||
let locales = Services.locale.getPackagedLocales();
|
||||
let locales = Services.locale.packagedLocales;
|
||||
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
|
||||
L10nRegistry.registerSource(greSource);
|
||||
|
||||
@ -2345,13 +2345,13 @@ BrowserGlue.prototype = {
|
||||
if (Services.prefs.prefHasUserValue(MATCHOS_LOCALE_PREF) ||
|
||||
Services.prefs.prefHasUserValue(SELECTED_LOCALE_PREF)) {
|
||||
if (Services.prefs.getBoolPref(MATCHOS_LOCALE_PREF, false)) {
|
||||
Services.locale.setRequestedLocales([]);
|
||||
Services.locale.requestedLocales = [];
|
||||
} else {
|
||||
let locale = Services.prefs.getComplexValue(SELECTED_LOCALE_PREF,
|
||||
Ci.nsIPrefLocalizedString);
|
||||
if (locale) {
|
||||
try {
|
||||
Services.locale.setRequestedLocales([locale.data]);
|
||||
Services.locale.requestedLocales = [locale.data];
|
||||
} catch (e) { /* Don't panic if the value is not a valid locale code. */ }
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ class SortedItemSelectList {
|
||||
}
|
||||
|
||||
function getLocaleDisplayInfo(localeCodes) {
|
||||
let packagedLocales = new Set(Services.locale.getPackagedLocales());
|
||||
let packagedLocales = new Set(Services.locale.packagedLocales);
|
||||
let localeNames = Services.intl.getLocaleDisplayNames(undefined, localeCodes);
|
||||
return localeCodes.map((code, i) => {
|
||||
return {
|
||||
@ -223,9 +223,9 @@ var gBrowserLanguagesDialog = {
|
||||
// Maintain the previously requested locales even if we cancel out.
|
||||
this.requestedLocales = window.arguments[0];
|
||||
|
||||
let requested = this.requestedLocales || Services.locale.getRequestedLocales();
|
||||
let requested = this.requestedLocales || Services.locale.requestedLocales;
|
||||
let requestedSet = new Set(requested);
|
||||
let available = Services.locale.getAvailableLocales()
|
||||
let available = Services.locale.availableLocales
|
||||
.filter(locale => !requestedSet.has(locale));
|
||||
|
||||
this.initRequestedLocales(requested);
|
||||
|
@ -238,7 +238,7 @@ var promiseLoadHandlersList;
|
||||
function getBundleForLocales(newLocales) {
|
||||
let locales = Array.from(new Set([
|
||||
...newLocales,
|
||||
...Services.locale.getRequestedLocales(),
|
||||
...Services.locale.requestedLocales,
|
||||
Services.locale.lastFallbackLocale,
|
||||
]));
|
||||
function generateContexts(resourceIds) {
|
||||
@ -785,7 +785,7 @@ var gMainPane = {
|
||||
},
|
||||
|
||||
initBrowserLocale() {
|
||||
let localeCodes = Services.locale.getAvailableLocales();
|
||||
let localeCodes = Services.locale.availableLocales;
|
||||
let localeNames = Services.intl.getLocaleDisplayNames(undefined, localeCodes);
|
||||
let locales = localeCodes.map((code, i) => ({code, name: localeNames[i]}));
|
||||
locales.sort((a, b) => a.name > b.name);
|
||||
@ -800,7 +800,7 @@ var gMainPane = {
|
||||
let menulist = document.getElementById("defaultBrowserLanguage");
|
||||
let menupopup = menulist.querySelector("menupopup");
|
||||
menupopup.appendChild(fragment);
|
||||
menulist.value = Services.locale.getRequestedLocale();
|
||||
menulist.value = Services.locale.requestedLocale;
|
||||
|
||||
document.getElementById("browserLanguagesBox").hidden = false;
|
||||
},
|
||||
@ -836,7 +836,7 @@ var gMainPane = {
|
||||
return;
|
||||
}
|
||||
let locales = localesString.split(",");
|
||||
Services.locale.setRequestedLocales(locales);
|
||||
Services.locale.requestedLocales = locales;
|
||||
|
||||
// Restart with the new locale.
|
||||
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
|
||||
@ -849,13 +849,13 @@ var gMainPane = {
|
||||
/* Show or hide the confirm change message bar based on the new locale. */
|
||||
onBrowserLanguageChange(event) {
|
||||
let locale = event.target.value;
|
||||
if (locale == Services.locale.getRequestedLocale()) {
|
||||
if (locale == Services.locale.requestedLocale) {
|
||||
this.hideConfirmLanguageChangeMessageBar();
|
||||
return;
|
||||
}
|
||||
let locales = Array.from(new Set([
|
||||
locale,
|
||||
...Services.locale.getRequestedLocales(),
|
||||
...Services.locale.requestedLocales,
|
||||
]).values());
|
||||
this.showConfirmLanguageChangeMessageBar(locales);
|
||||
},
|
||||
@ -993,14 +993,14 @@ var gMainPane = {
|
||||
/* Show or hide the confirm change message bar based on the updated ordering. */
|
||||
browserLanguagesClosed() {
|
||||
let requesting = this.gBrowserLanguagesDialog.requestedLocales;
|
||||
let requested = Services.locale.getRequestedLocales();
|
||||
let requested = Services.locale.requestedLocales;
|
||||
let defaultBrowserLanguage = document.getElementById("defaultBrowserLanguage");
|
||||
if (requesting && requesting.join(",") != requested.join(",")) {
|
||||
gMainPane.showConfirmLanguageChangeMessageBar(requesting);
|
||||
defaultBrowserLanguage.value = requesting[0];
|
||||
return;
|
||||
}
|
||||
defaultBrowserLanguage.value = Services.locale.getRequestedLocale();
|
||||
defaultBrowserLanguage.value = Services.locale.requestedLocale;
|
||||
gMainPane.hideConfirmLanguageChangeMessageBar();
|
||||
},
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const originalAvailable = Services.locale.getAvailableLocales();
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
Services.locale.setAvailableLocales(["ko-KR"]);
|
||||
Services.locale.setRequestedLocales(["ko-KR"]);
|
||||
const originalAvailable = Services.locale.availableLocales;
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
Services.locale.availableLocales = ["ko-KR"];
|
||||
Services.locale.requestedLocales = ["ko-KR"];
|
||||
|
||||
// First be sure we have a non-UTC timezone and a non en-US locale.
|
||||
var setTimeZone = SpecialPowers.Cu.getJSTestingFunctions().setTimeZone;
|
||||
@ -58,8 +58,8 @@
|
||||
SimpleTest.is(options.timeZoneName, "long", "Resist Fingerprinting Intl.DateTimeFormat.format.timeZoneName");
|
||||
|
||||
// Cleanup
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.setAvailableLocales(originalAvailable);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
Services.locale.availableLocales = originalAvailable;
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
|
@ -22,7 +22,7 @@ function isSubObjectOf(expectedObj, actualObj, name) {
|
||||
}
|
||||
|
||||
function getLocale() {
|
||||
return Services.locale.getRequestedLocale() || undefined;
|
||||
return Services.locale.requestedLocale || undefined;
|
||||
}
|
||||
|
||||
function promiseEvent(aTarget, aEventName, aPreventDefault) {
|
||||
|
@ -131,8 +131,8 @@ add_task(async function testObserver() {
|
||||
"component is notified of login change");
|
||||
Assert.equal(component.updatePanel.callCount, 4, "triggers panel update again");
|
||||
|
||||
Services.locale.setAvailableLocales(["ab-CD"]);
|
||||
Services.locale.setRequestedLocales(["ab-CD"]);
|
||||
Services.locale.availableLocales = ["ab-CD"];
|
||||
Services.locale.requestedLocales = ["ab-CD"];
|
||||
|
||||
Assert.ok(component.updateDir.calledTwice, "locale change triggers UI direction update");
|
||||
|
||||
|
@ -29,7 +29,7 @@ var Translation = {
|
||||
_defaultTargetLanguage: "",
|
||||
get defaultTargetLanguage() {
|
||||
if (!this._defaultTargetLanguage) {
|
||||
this._defaultTargetLanguage = Services.locale.getAppLocaleAsLangTag()
|
||||
this._defaultTargetLanguage = Services.locale.appLocaleAsLangTag
|
||||
.split("-")[0];
|
||||
}
|
||||
return this._defaultTargetLanguage;
|
||||
|
@ -270,7 +270,7 @@
|
||||
"C\u1EA3m \u01A1n"],
|
||||
};
|
||||
|
||||
let locale = Services.locale.getAppLocaleAsLangTag();
|
||||
let locale = Services.locale.appLocaleAsLangTag;
|
||||
if (!(locale in localizedStrings))
|
||||
locale = "en";
|
||||
let strings = localizedStrings[locale];
|
||||
|
@ -53,7 +53,7 @@ function isAvailable() {
|
||||
if (availablePref == "on") {
|
||||
return true;
|
||||
} else if (availablePref == "detect") {
|
||||
let locale = Services.locale.getRequestedLocale();
|
||||
let locale = Services.locale.requestedLocale;
|
||||
let region = Services.prefs.getCharPref("browser.search.region", "");
|
||||
let supportedCountries = Services.prefs.getCharPref("extensions.formautofill.supportedCountries")
|
||||
.split(",");
|
||||
|
@ -306,7 +306,7 @@ class ChromeActions {
|
||||
}
|
||||
|
||||
getLocale() {
|
||||
return Services.locale.getRequestedLocale() || "en-US";
|
||||
return Services.locale.requestedLocale || "en-US";
|
||||
}
|
||||
|
||||
getStrings(data) {
|
||||
|
@ -624,7 +624,7 @@ var pktUI = (function() {
|
||||
}
|
||||
|
||||
function getUILocale() {
|
||||
return Services.locale.getAppLocaleAsLangTag();
|
||||
return Services.locale.appLocaleAsLangTag;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,7 +246,7 @@ var pktApi = (function() {
|
||||
|
||||
var url = baseAPIUrl + options.path;
|
||||
var data = options.data || {};
|
||||
data.locale_lang = Services.locale.getAppLocaleAsLangTag();
|
||||
data.locale_lang = Services.locale.appLocaleAsLangTag;
|
||||
data.consumer_key = oAuthConsumerKey;
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
@ -358,7 +358,7 @@ var pktApi = (function() {
|
||||
|
||||
// Define variant for ho2
|
||||
if (data.flags) {
|
||||
var showHo2 = (Services.locale.getAppLocaleAsLangTag() === "en-US") ? data.flags.show_ffx_mobile_prompt : "control";
|
||||
var showHo2 = (Services.locale.appLocaleAsLangTag === "en-US") ? data.flags.show_ffx_mobile_prompt : "control";
|
||||
setSetting("test.ho2", showHo2);
|
||||
}
|
||||
data.ho2 = getSetting("test.ho2");
|
||||
|
@ -143,7 +143,7 @@ class PingCentre {
|
||||
}
|
||||
|
||||
let clientID = data.client_id || await this.telemetryClientId;
|
||||
let locale = data.locale || Services.locale.getAppLocalesAsLangTags().pop();
|
||||
let locale = data.locale || Services.locale.appLocaleAsLangTag;
|
||||
let profileCreationDate = TelemetryEnvironment.currentEnvironment.profile.resetDate ||
|
||||
TelemetryEnvironment.currentEnvironment.profile.creationDate;
|
||||
const payload = Object.assign({
|
||||
|
@ -25,7 +25,7 @@ function enum_to_array(strings) {
|
||||
function run_test() {
|
||||
|
||||
// without override
|
||||
Services.locale.setRequestedLocales(["de"]);
|
||||
Services.locale.requestedLocales = ["de"];
|
||||
Assert.equal(chromeReg.getSelectedLocale("basepack"), "en-US");
|
||||
Assert.equal(chromeReg.getSelectedLocale("overpack"), "de");
|
||||
Assert.deepEqual(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
|
||||
|
@ -80,7 +80,7 @@ const AboutDebugging = {
|
||||
L10nRegistry.registerSource(temporarySource);
|
||||
}
|
||||
|
||||
const locales = Services.locale.getAppLocalesAsBCP47();
|
||||
const locales = Services.locale.appLocalesAsBCP47;
|
||||
const generator =
|
||||
L10nRegistry.generateContexts(locales, ["aboutdebugging.ftl"]);
|
||||
|
||||
|
@ -65,7 +65,7 @@ window.Application = {
|
||||
* MessageContext elements.
|
||||
*/
|
||||
async createMessageContexts() {
|
||||
const locales = Services.locale.getAppLocalesAsBCP47();
|
||||
const locales = Services.locale.appLocalesAsBCP47;
|
||||
const generator =
|
||||
L10nRegistry.generateContexts(locales, ["devtools/application.ftl"]);
|
||||
|
||||
|
@ -45,7 +45,7 @@ window.onload = function() {
|
||||
geckobuildid: appInfo.platformBuildID,
|
||||
geckoversion: appInfo.platformVersion,
|
||||
useragent: window.navigator.userAgent,
|
||||
locale: Services.locale.getAppLocaleAsLangTag(),
|
||||
locale: Services.locale.appLocaleAsLangTag,
|
||||
os: appInfo.OS,
|
||||
processor: appInfo.XPCOMABI.split("-")[0],
|
||||
compiler: appInfo.XPCOMABI.split("-")[1],
|
||||
|
@ -114,7 +114,7 @@ async function getSystemInfo() {
|
||||
geckoversion: geckoVersion,
|
||||
|
||||
// Locale used in this build
|
||||
locale: Services.locale.getAppLocaleAsLangTag(),
|
||||
locale: Services.locale.appLocaleAsLangTag,
|
||||
|
||||
/**
|
||||
* Information regarding the operating system.
|
||||
|
@ -32,7 +32,7 @@ var gStringBundle;
|
||||
W3CTest.runner.requestLongerTimeout(2);
|
||||
|
||||
const { Services } = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
|
||||
Services.locale.setRequestedLocales(["en-US"]);
|
||||
Services.locale.requestedLocales = ["en-US"];
|
||||
|
||||
SpecialPowers.pushPrefEnv({ "set": [
|
||||
// Need to set devPixelsPerPx explicitly to gain
|
||||
|
@ -18,8 +18,8 @@ const localeService =
|
||||
Cc["@mozilla.org/intl/localeservice;1"].getService(Ci.mozILocaleService);
|
||||
const mozIntl = Cc["@mozilla.org/mozintl;1"].getService(Ci.mozIMozIntl);
|
||||
|
||||
let rpLocale = localeService.negotiateLanguages(localeService.getRegionalPrefsLocales(),
|
||||
localeService.getAvailableLocales())[0];
|
||||
let rpLocale = localeService.negotiateLanguages(localeService.regionalPrefsLocales,
|
||||
localeService.availableLocales)[0];
|
||||
|
||||
let testData = [
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ const localeService =
|
||||
Cc["@mozilla.org/intl/localeservice;1"].getService(Ci.mozILocaleService);
|
||||
|
||||
let rpLocales = localeService.negotiateLanguages(window.getRegionalPrefsLocales(),
|
||||
localeService.getAvailableLocales());
|
||||
localeService.availableLocales);
|
||||
|
||||
ok(rpLocales.length > 0, "getRegionalPrefsLocales returns at least one locale.");
|
||||
is(rpLocales[0], "en-US", "The first regional prefs locale should resolve to en-US.");
|
||||
|
@ -1288,7 +1288,7 @@ gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aL
|
||||
if (OSPreferences::GetInstance()->GetSystemLocales(sysLocales)) {
|
||||
LocaleService::GetInstance()->NegotiateLanguages(
|
||||
sysLocales, prefLocales, NS_LITERAL_CSTRING(""),
|
||||
LocaleService::LangNegStrategy::Filtering, negLocales);
|
||||
LocaleService::kLangNegStrategyFiltering, negLocales);
|
||||
for (const auto& localeStr : negLocales) {
|
||||
Locale locale(localeStr);
|
||||
|
||||
|
@ -333,8 +333,7 @@ carry different lists of available locales.
|
||||
Requested Locales
|
||||
=================
|
||||
|
||||
The list of requested locales can be read using :js:`LocaleService::GetRequestedLocales` API,
|
||||
and set using :js:`LocaleService::SetRequestedLocales` API.
|
||||
The list of requested locales can be read and set using :js:`LocaleService::requestedLocales` API.
|
||||
|
||||
Using the API will perform necessary sanity checks and canonicalize the values.
|
||||
|
||||
@ -349,7 +348,7 @@ The former is the current default setting for Firefox Desktop, and the latter is
|
||||
default setting for Firefox for Android.
|
||||
|
||||
If the developer wants to programmatically request the app to follow OS locales,
|
||||
they can call the :js:`SetRequestedLocales` API with no argument.
|
||||
they can assign :js:`null` to :js:`requestedLocales`.
|
||||
|
||||
Regional Preferences
|
||||
====================
|
||||
@ -450,8 +449,8 @@ a legacy "ja-JP-mac" locale. The "mac" is a variant and BCP47 requires all varia
|
||||
to be 5-8 character long.
|
||||
|
||||
Gecko supports the limitation by accepting the 3-letter variants in our APIs and also
|
||||
provides a special :js:`GetAppLocalesAsLangTags` method which returns this locale in that form.
|
||||
(:js:`GetAppLocalesAsBCP47` will canonicalize it and turn into `"ja-JP-macos"`).
|
||||
provides a special :js:`appLocalesAsLangTags` method which returns this locale in that form.
|
||||
(:js:`appLocalesAsBCP47` will canonicalize it and turn into `"ja-JP-macos"`).
|
||||
|
||||
Usage of language negotiation etc. shouldn't rely on this behavior.
|
||||
|
||||
@ -507,14 +506,14 @@ It may look like this:
|
||||
|
||||
L10nRegistry.registerSource(fs);
|
||||
|
||||
let availableLocales = Services.locale.getAvailableLocales();
|
||||
let availableLocales = Services.locale.availableLocales;
|
||||
|
||||
assert(availableLocales.includes("ko-KR"));
|
||||
assert(availableLocales.includes("ar"));
|
||||
|
||||
Services.locale.setRequestedLocales(["ko-KR");
|
||||
Services.locale.requestedLocales = ["ko-KR"];
|
||||
|
||||
let appLocales = Services.locale.getAppLocalesAsBCP47();
|
||||
let appLocales = Services.locale.appLocalesAsBCP47;
|
||||
assert(appLocales[0], "ko-KR");
|
||||
|
||||
From here, a resource :js:`test.ftl` can be added to a `Localization` and for ID :js:`key`
|
||||
@ -528,10 +527,10 @@ but it is also simpler:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
Services.locale.setAvailableLocales(["ko-KR", "ar"]);
|
||||
Services.locale.setRequestedLocales(["ko-KR"]);
|
||||
Services.locale.availableLocales = ["ko-KR", "ar"];
|
||||
Services.locale.requestedLocales = ["ko-KR"];
|
||||
|
||||
let appLocales = Services.locale.getAppLocalesAsBCP47();
|
||||
let appLocales = Services.locale.appLocalesAsBCP47;
|
||||
assert(appLocales[0], "ko-KR");
|
||||
|
||||
In the future, Mozilla plans to add a third way for add-ons (`bug 1440969`_)
|
||||
|
@ -581,7 +581,7 @@ class DOMLocalization extends Localization {
|
||||
// This means that the DOM alternations and directionality
|
||||
// are set in the same microtask.
|
||||
await this.translateFragment(root);
|
||||
let primaryLocale = Services.locale.getAppLocaleAsBCP47();
|
||||
let primaryLocale = Services.locale.appLocaleAsBCP47;
|
||||
let direction = Services.locale.isAppLocaleRTL ? "rtl" : "ltr";
|
||||
root.setAttribute("lang", primaryLocale);
|
||||
root.setAttribute(root.namespaceURI ===
|
||||
|
@ -121,7 +121,7 @@ const L10nRegistry = {
|
||||
throw new Error(`Source with name "${source.name}" already registered.`);
|
||||
}
|
||||
this.sources.set(source.name, source);
|
||||
Services.locale.setAvailableLocales(this.getAvailableLocales());
|
||||
Services.locale.availableLocales = this.getAvailableLocales();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ const L10nRegistry = {
|
||||
throw new Error(`Source with name "${source.name}" is not registered.`);
|
||||
}
|
||||
this.sources.set(source.name, source);
|
||||
Services.locale.setAvailableLocales(this.getAvailableLocales());
|
||||
Services.locale.availableLocales = this.getAvailableLocales();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -147,7 +147,7 @@ const L10nRegistry = {
|
||||
*/
|
||||
removeSource(sourceName) {
|
||||
this.sources.delete(sourceName);
|
||||
Services.locale.setAvailableLocales(this.getAvailableLocales());
|
||||
Services.locale.availableLocales = this.getAvailableLocales();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -135,7 +135,7 @@ class CachedAsyncIterable extends CachedIterable {
|
||||
* be localized into a different language - for example DevTools.
|
||||
*/
|
||||
function defaultGenerateMessages(resourceIds) {
|
||||
const appLocales = Services.locale.getAppLocalesAsBCP47();
|
||||
const appLocales = Services.locale.appLocalesAsBCP47;
|
||||
return L10nRegistry.generateContexts(appLocales, resourceIds);
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ class Localization {
|
||||
// we want to eagerly fetch just that one.
|
||||
// Otherwise, we're in a scenario where the first locale may
|
||||
// be partial and we want to eagerly fetch a fallback as well.
|
||||
const appLocale = Services.locale.getAppLocaleAsBCP47();
|
||||
const appLocale = Services.locale.appLocaleAsBCP47;
|
||||
const lastFallback = Services.locale.lastFallbackLocale;
|
||||
const prefetchCount = appLocale === lastFallback ? 1 : 2;
|
||||
this.ctxs.touchNext(prefetchCount);
|
||||
|
@ -22,7 +22,7 @@ link =
|
||||
`,
|
||||
};
|
||||
const originalLoad = L10nRegistry.load;
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
|
||||
L10nRegistry.load = async function(url) {
|
||||
return fs.hasOwnProperty(url) ? fs[url] : false;
|
||||
@ -47,7 +47,7 @@ link =
|
||||
// Cleanup
|
||||
L10nRegistry.removeSource(source.name);
|
||||
L10nRegistry.load = originalLoad;
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ subtitle = Welcome to Fluent
|
||||
`,
|
||||
};
|
||||
const originalLoad = L10nRegistry.load;
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
|
||||
L10nRegistry.load = async function(url) {
|
||||
return fs.hasOwnProperty(url) ? fs[url] : false;
|
||||
@ -46,7 +46,7 @@ subtitle = Welcome to Fluent
|
||||
// Cleanup
|
||||
L10nRegistry.removeSource(source.name);
|
||||
L10nRegistry.load = originalLoad;
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ title2 = Hello Another World
|
||||
`,
|
||||
};
|
||||
const originalLoad = L10nRegistry.load;
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
|
||||
L10nRegistry.load = async function(url) {
|
||||
return fs.hasOwnProperty(url) ? fs[url] : false;
|
||||
@ -51,7 +51,7 @@ title2 = Hello Another World
|
||||
// Cleanup
|
||||
L10nRegistry.removeSource(source.name);
|
||||
L10nRegistry.load = originalLoad;
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ add_task(async function test_methods_calling() {
|
||||
"/localization/en-US/browser/menu.ftl": "key = [en] Value2\nkey2 = [en] Value3",
|
||||
};
|
||||
const originalLoad = L10nRegistry.load;
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
|
||||
L10nRegistry.load = async function(url) {
|
||||
return fs[url];
|
||||
@ -44,7 +44,7 @@ add_task(async function test_methods_calling() {
|
||||
|
||||
L10nRegistry.sources.clear();
|
||||
L10nRegistry.load = originalLoad;
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
});
|
||||
|
||||
add_task(async function test_builtins() {
|
||||
@ -101,7 +101,7 @@ add_task(async function test_add_remove_resourceIds() {
|
||||
"/localization/en-US/toolkit/menu.ftl": "key2 = Value2",
|
||||
};
|
||||
const originalLoad = L10nRegistry.load;
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
|
||||
L10nRegistry.load = async function(url) {
|
||||
return fs[url];
|
||||
@ -137,5 +137,5 @@ add_task(async function test_add_remove_resourceIds() {
|
||||
|
||||
L10nRegistry.sources.clear();
|
||||
L10nRegistry.load = originalLoad;
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ const fs = {
|
||||
"/localization/en-US/browser/menu.ftl": "key = [en] Value",
|
||||
};
|
||||
const originalLoad = L10nRegistry.load;
|
||||
const originalRequested = Services.locale.getRequestedLocales();
|
||||
const originalRequested = Services.locale.requestedLocales;
|
||||
|
||||
// Variable used to test for `L10nRegistry.load`
|
||||
// execution count.
|
||||
@ -92,5 +92,5 @@ add_task(async function test_ready() {
|
||||
add_task(function cleanup() {
|
||||
L10nRegistry.sources.clear();
|
||||
L10nRegistry.load = originalLoad;
|
||||
Services.locale.setRequestedLocales(originalRequested);
|
||||
Services.locale.requestedLocales = originalRequested;
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ key = This is a single message
|
||||
.accesskey = f`,
|
||||
};
|
||||
originalValues.load = L10nRegistry.load;
|
||||
originalValues.requested = Services.locale.getRequestedLocales();
|
||||
originalValues.requested = Services.locale.requestedLocales;
|
||||
|
||||
L10nRegistry.load = async function(url) {
|
||||
return fs[url];
|
||||
@ -95,7 +95,7 @@ add_task(async function test_accented_works() {
|
||||
|
||||
L10nRegistry.sources.clear();
|
||||
L10nRegistry.load = originalValues.load;
|
||||
Services.locale.setRequestedLocales(originalValues.requested);
|
||||
Services.locale.requestedLocales = originalValues.requested;
|
||||
});
|
||||
|
||||
/**
|
||||
@ -126,5 +126,5 @@ add_task(async function test_unavailable_strategy_works() {
|
||||
Services.prefs.setStringPref("intl.l10n.pseudo", "");
|
||||
L10nRegistry.sources.clear();
|
||||
L10nRegistry.load = originalValues.load;
|
||||
Services.locale.setRequestedLocales(originalValues.requested);
|
||||
Services.locale.requestedLocales = originalValues.requested;
|
||||
});
|
||||
|
@ -396,7 +396,7 @@ var BrowserApp = {
|
||||
]);
|
||||
|
||||
// Initialize the default l10n resource sources for L10nRegistry.
|
||||
let locales = Services.locale.getPackagedLocales();
|
||||
let locales = Services.locale.packagedLocales;
|
||||
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
|
||||
L10nRegistry.registerSource(greSource);
|
||||
|
||||
@ -1698,7 +1698,7 @@ var BrowserApp = {
|
||||
},
|
||||
|
||||
getUALocalePref: function () {
|
||||
return Services.locale.getRequestedLocale() || undefined;
|
||||
return Services.locale.requestedLocale || undefined;
|
||||
},
|
||||
|
||||
getOSLocalePref: function () {
|
||||
@ -1775,9 +1775,9 @@ var BrowserApp = {
|
||||
|
||||
case "Locale:Changed": {
|
||||
if (data) {
|
||||
Services.locale.setRequestedLocales([data.languageTag]);
|
||||
Services.locale.requestedLocales = [data.languageTag];
|
||||
} else {
|
||||
Services.locale.setRequestedLocales([]);
|
||||
Services.locale.requestedLocales = [];
|
||||
}
|
||||
|
||||
console.log("Gecko display locale: " + this.getUALocalePref());
|
||||
|
@ -106,7 +106,7 @@ DirectoryProvider.prototype = {
|
||||
return;
|
||||
|
||||
let curLocale = "";
|
||||
let reqLocales = Services.locale.getRequestedLocales();
|
||||
let reqLocales = Services.locale.requestedLocales;
|
||||
if (reqLocales.length > 0) {
|
||||
curLocale = reqLocales[0];
|
||||
}
|
||||
|
@ -119,13 +119,13 @@ GeckoViewStartup.prototype = {
|
||||
GeckoViewTelemetryController.setup();
|
||||
|
||||
// Initialize the default l10n resource sources for L10nRegistry.
|
||||
let locales = Services.locale.getPackagedLocales();
|
||||
let locales = Services.locale.packagedLocales;
|
||||
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
|
||||
L10nRegistry.registerSource(greSource);
|
||||
|
||||
// Listen for global EventDispatcher messages
|
||||
EventDispatcher.instance.registerListener(
|
||||
(aEvent, aData, aCallback) => Services.locale.setRequestedLocales([aData.languageTag]),
|
||||
(aEvent, aData, aCallback) => Services.locale.requestedLocales = [aData.languageTag],
|
||||
"GeckoView:SetLocale");
|
||||
break;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class LocaleTest : BaseSessionTest() {
|
||||
val index = sessionRule.waitForChromeJS(String.format(
|
||||
"(function() {" +
|
||||
" return ChromeUtils.import('resource://gre/modules/Services.jsm', {})" +
|
||||
" .Services.locale.getRequestedLocales().indexOf('en-GB');" +
|
||||
" .Services.locale.requestedLocales.indexOf('en-GB');" +
|
||||
"})()")) as Double;
|
||||
|
||||
assertThat("Requested locale is found", index, greaterThanOrEqualTo(0.0));
|
||||
|
@ -1491,7 +1491,7 @@ class Extension extends ExtensionData {
|
||||
}
|
||||
|
||||
get manifestCacheKey() {
|
||||
return [this.id, this.version, Services.locale.getAppLocaleAsLangTag()];
|
||||
return [this.id, this.version, Services.locale.appLocaleAsLangTag];
|
||||
}
|
||||
|
||||
get isPrivileged() {
|
||||
@ -1723,7 +1723,7 @@ class Extension extends ExtensionData {
|
||||
let locales = await this.promiseLocales();
|
||||
|
||||
let matches = Services.locale.negotiateLanguages(
|
||||
Services.locale.getAppLocalesAsLangTags(),
|
||||
Services.locale.appLocalesAsLangTags,
|
||||
Array.from(locales.keys()),
|
||||
this.defaultLocale);
|
||||
|
||||
|
@ -1929,7 +1929,7 @@ LocaleData.prototype = {
|
||||
|
||||
|
||||
get uiLocale() {
|
||||
return Services.locale.getAppLocaleAsBCP47();
|
||||
return Services.locale.appLocaleAsBCP47;
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -11,11 +11,11 @@ server.registerDirectory("/data/", do_get_file("data"));
|
||||
|
||||
const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`;
|
||||
|
||||
var originalReqLocales = Services.locale.getRequestedLocales();
|
||||
var originalReqLocales = Services.locale.requestedLocales;
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Preferences.reset("intl.accept_languages");
|
||||
Services.locale.setRequestedLocales(originalReqLocales);
|
||||
Services.locale.requestedLocales = originalReqLocales;
|
||||
});
|
||||
|
||||
|
||||
@ -221,12 +221,12 @@ add_task(async function test_i18n_negotiation() {
|
||||
//
|
||||
// In the future, we should provide some way for tests to decouple their
|
||||
// language selection from that of Firefox.
|
||||
Services.locale.setAvailableLocales(["en-US", "fr", "jp"]);
|
||||
Services.locale.availableLocales = ["en-US", "fr", "jp"];
|
||||
|
||||
let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
|
||||
|
||||
for (let [lang, msg] of [["en-US", "English."], ["jp", "\u65e5\u672c\u8a9e"]]) {
|
||||
Services.locale.setRequestedLocales([lang]);
|
||||
Services.locale.requestedLocales = [lang];
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension(extensionData);
|
||||
await extension.startup();
|
||||
@ -238,7 +238,7 @@ add_task(async function test_i18n_negotiation() {
|
||||
|
||||
await extension.unload();
|
||||
}
|
||||
Services.locale.setRequestedLocales(originalReqLocales);
|
||||
Services.locale.requestedLocales = originalReqLocales;
|
||||
|
||||
await contentPage.close();
|
||||
});
|
||||
@ -383,7 +383,7 @@ add_task(async function test_get_ui_language() {
|
||||
|
||||
// We don't currently have a good way to mock this.
|
||||
if (false) {
|
||||
Services.locale.setRequestedLocales(["he"]);
|
||||
Services.locale.requestedLocales = ["he"];
|
||||
|
||||
extension.sendMessage(["expect-results", "he"]);
|
||||
|
||||
|
@ -129,14 +129,14 @@ async function test_i18n_css(options = {}) {
|
||||
// We don't wind up actually switching the chrome registry locale, since we
|
||||
// don't have a chrome package for Hebrew. So just override it, and force
|
||||
// RTL directionality.
|
||||
const origReqLocales = Services.locale.getRequestedLocales();
|
||||
Services.locale.setRequestedLocales(["he"]);
|
||||
const origReqLocales = Services.locale.requestedLocales;
|
||||
Services.locale.requestedLocales = ["he"];
|
||||
Preferences.set(DIR, 1);
|
||||
|
||||
css = await fetch(baseURL + "locale.css");
|
||||
equal(css, '* { content: "he rtl ltr right left" }', "CSS file localized in mochitest scope");
|
||||
|
||||
Services.locale.setRequestedLocales(origReqLocales);
|
||||
Services.locale.requestedLocales = origReqLocales;
|
||||
Preferences.reset(DIR);
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ add_task(async function() {
|
||||
//
|
||||
// In the future, we should provide some way for tests to decouple their
|
||||
// language selection from that of Firefox.
|
||||
Services.locale.setAvailableLocales(["en-US", "fr", "jp"]);
|
||||
Services.locale.availableLocales = ["en-US", "fr", "jp"];
|
||||
|
||||
await extension.startup();
|
||||
|
||||
@ -88,7 +88,7 @@ add_task(async function() {
|
||||
|
||||
|
||||
info("Change locale to 'fr' and restart");
|
||||
Services.locale.setRequestedLocales(["fr"]);
|
||||
Services.locale.requestedLocales = ["fr"];
|
||||
await AddonTestUtils.promiseRestartManager();
|
||||
await extension.awaitStartup();
|
||||
|
||||
@ -106,7 +106,7 @@ add_task(async function() {
|
||||
|
||||
|
||||
info("Change locale to 'en-US' and restart");
|
||||
Services.locale.setRequestedLocales(["en-US"]);
|
||||
Services.locale.requestedLocales = ["en-US"];
|
||||
await AddonTestUtils.promiseRestartManager();
|
||||
await extension.awaitStartup();
|
||||
|
||||
|
@ -22,7 +22,7 @@ const languageTagMatch = /^([a-z]{2,3}|[a-z]{4}|[a-z]{5,8})(?:[-_]([a-z]{4}))?(?
|
||||
*/
|
||||
function getLocales(locales) {
|
||||
if (!locales) {
|
||||
return Services.locale.getRegionalPrefsLocales();
|
||||
return Services.locale.regionalPrefsLocales;
|
||||
}
|
||||
return locales;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ var NormandyDriver = function(sandboxManager) {
|
||||
|
||||
get locale() {
|
||||
if (Services.locale.getAppLocaleAsLangTag) {
|
||||
return Services.locale.getAppLocaleAsLangTag();
|
||||
return Services.locale.getAppLocaleAsLangTag;
|
||||
}
|
||||
|
||||
return Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
|
@ -74,14 +74,14 @@ add_task(function test_setup() {
|
||||
Services.prefs.setCharPref("urlclassifier.downloadBlockTable",
|
||||
"goog-badbinurl-shavar");
|
||||
// SendRemoteQueryInternal needs locale preference.
|
||||
let originalReqLocales = Services.locale.getRequestedLocales();
|
||||
Services.locale.setRequestedLocales(["en-US"]);
|
||||
let originalReqLocales = Services.locale.requestedLocales;
|
||||
Services.locale.requestedLocales = ["en-US"];
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled");
|
||||
Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled");
|
||||
Services.prefs.clearUserPref("urlclassifier.downloadBlockTable");
|
||||
Services.locale.setRequestedLocales(originalReqLocales);
|
||||
Services.locale.requestedLocales = originalReqLocales;
|
||||
});
|
||||
|
||||
gHttpServer = new HttpServer();
|
||||
|
@ -163,15 +163,15 @@ add_task(async function test_setup() {
|
||||
Services.prefs.setCharPref("urlclassifier.downloadAllowTable",
|
||||
"goog-downloadwhite-digest256");
|
||||
// SendRemoteQueryInternal needs locale preference.
|
||||
let originalReqLocales = Services.locale.getRequestedLocales();
|
||||
Services.locale.setRequestedLocales(["en-US"]);
|
||||
let originalReqLocales = Services.locale.requestedLocales;
|
||||
Services.locale.requestedLocales = ["en-US"];
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled");
|
||||
Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled");
|
||||
Services.prefs.clearUserPref("urlclassifier.downloadBlockTable");
|
||||
Services.prefs.clearUserPref("urlclassifier.downloadAllowTable");
|
||||
Services.locale.setRequestedLocales(originalReqLocales);
|
||||
Services.locale.requestedLocales = originalReqLocales;
|
||||
});
|
||||
|
||||
gHttpServer = new HttpServer();
|
||||
|
@ -64,7 +64,7 @@ class _LanguagePrompt {
|
||||
}
|
||||
|
||||
_shouldPromptForLanguagePref() {
|
||||
return (Services.locale.getAppLocaleAsLangTag().substr(0, 2) !== "en")
|
||||
return (Services.locale.appLocaleAsLangTag.substr(0, 2) !== "en")
|
||||
&& (Services.prefs.getIntPref(kPrefSpoofEnglish) === 0);
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ function getDir(aKey, aIFace) {
|
||||
* exists in nsHttpHandler.cpp when building the UA string.
|
||||
*/
|
||||
function getLocale() {
|
||||
return Services.locale.getRequestedLocale();
|
||||
return Services.locale.requestedLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3441,7 +3441,7 @@ SearchService.prototype = {
|
||||
}
|
||||
|
||||
let searchSettings;
|
||||
let locale = Services.locale.getAppLocaleAsBCP47();
|
||||
let locale = Services.locale.appLocaleAsBCP47;
|
||||
if ("locales" in json &&
|
||||
locale in json.locales) {
|
||||
searchSettings = json.locales[locale];
|
||||
|
@ -234,7 +234,7 @@ function getDefaultEngineName(isUS) {
|
||||
let defaultEngineName = searchSettings.default.searchDefault;
|
||||
|
||||
if (isUS === undefined)
|
||||
isUS = Services.locale.getRequestedLocale() == "en-US" && isUSTimezone();
|
||||
isUS = Services.locale.requestedLocale == "en-US" && isUSTimezone();
|
||||
|
||||
if (isUS && ("US" in searchSettings &&
|
||||
"searchDefault" in searchSettings.US)) {
|
||||
@ -253,7 +253,7 @@ function getDefaultEngineList(isUS) {
|
||||
let visibleDefaultEngines = json.default.visibleDefaultEngines;
|
||||
|
||||
if (isUS === undefined)
|
||||
isUS = Services.locale.getRequestedLocale() == "en-US" && isUSTimezone();
|
||||
isUS = Services.locale.requestedLocale == "en-US" && isUSTimezone();
|
||||
|
||||
if (isUS) {
|
||||
let searchSettings = json.locales["en-US"];
|
||||
|
@ -19,8 +19,8 @@ add_task(async function test_listJSONlocale() {
|
||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||
resProt.setSubstitution("search-plugins", Services.io.newURI(url));
|
||||
|
||||
Services.locale.setAvailableLocales(["de"]);
|
||||
Services.locale.setRequestedLocales(["de"]);
|
||||
Services.locale.availableLocales = ["de"];
|
||||
Services.locale.requestedLocales = ["de"];
|
||||
|
||||
await asyncInit();
|
||||
|
||||
@ -35,8 +35,8 @@ add_task(async function test_listJSONlocale() {
|
||||
add_task(async function test_listJSONlocaleSwitch() {
|
||||
let promise = waitForSearchNotification("reinit-complete");
|
||||
|
||||
Services.locale.setAvailableLocales(["fr"]);
|
||||
Services.locale.setRequestedLocales(["fr"]);
|
||||
Services.locale.availableLocales = ["fr"];
|
||||
Services.locale.requestedLocales = ["fr"];
|
||||
|
||||
await promise;
|
||||
|
||||
|
@ -34,8 +34,8 @@ add_task(async function test_paramSubstitution() {
|
||||
check("{unknownOptional?}", "");
|
||||
check("{unknownRequired}", "{unknownRequired}");
|
||||
|
||||
check("{language}", Services.locale.getRequestedLocale());
|
||||
check("{language?}", Services.locale.getRequestedLocale());
|
||||
check("{language}", Services.locale.requestedLocale);
|
||||
check("{language?}", Services.locale.requestedLocale);
|
||||
|
||||
engine.wrappedJSObject._queryCharset = "UTF-8";
|
||||
check("{inputEncoding}", "UTF-8");
|
||||
@ -63,5 +63,5 @@ add_task(async function test_paramSubstitution() {
|
||||
check("{moz:official}", "official");
|
||||
Services.prefs.setBoolPref("browser.search.official", false);
|
||||
check("{moz:official}", "unofficial");
|
||||
check("{moz:locale}", Services.locale.getRequestedLocale());
|
||||
check("{moz:locale}", Services.locale.requestedLocale);
|
||||
});
|
||||
|
@ -298,7 +298,7 @@ function enforceBoolean(aValue) {
|
||||
*/
|
||||
function getBrowserLocale() {
|
||||
try {
|
||||
return Services.locale.getAppLocaleAsLangTag();
|
||||
return Services.locale.appLocaleAsLangTag;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ nsURLFormatterService.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIURLFormatter]),
|
||||
|
||||
_defaults: {
|
||||
LOCALE: () => Services.locale.getAppLocaleAsLangTag(),
|
||||
LOCALE: () => Services.locale.appLocaleAsLangTag,
|
||||
REGION() {
|
||||
try {
|
||||
// When the geoip lookup failed to identify the region, we fallback to
|
||||
|
@ -6,7 +6,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
var formatter = Services.urlFormatter;
|
||||
var locale = Services.locale.getAppLocaleAsLangTag();
|
||||
var locale = Services.locale.appLocaleAsLangTag;
|
||||
var OSVersion = Services.sysinfo.getProperty("name") + " " +
|
||||
Services.sysinfo.getProperty("version");
|
||||
try {
|
||||
|
@ -118,7 +118,7 @@ class ClientEnvironmentBase {
|
||||
}
|
||||
|
||||
static get locale() {
|
||||
return Services.locale.getAppLocaleAsLangTag();
|
||||
return Services.locale.appLocaleAsLangTag;
|
||||
}
|
||||
|
||||
static get doNotTrack() {
|
||||
|
@ -110,7 +110,7 @@
|
||||
<body><![CDATA[
|
||||
// TODO: When bug 1376616 lands, replace this.setGregorian with
|
||||
// mozIntl.Locale for setting calendar to Gregorian
|
||||
const locale = this.setGregorian(Services.locale.getAppLocaleAsBCP47());
|
||||
const locale = this.setGregorian(Services.locale.appLocaleAsBCP47);
|
||||
const dir = this.mozIntl.getLocaleInfo(locale).direction;
|
||||
|
||||
switch (this.type) {
|
||||
|
@ -618,10 +618,10 @@ var dataProviders = {
|
||||
Cc["@mozilla.org/intl/ospreferences;1"].getService(Ci.mozIOSPreferences);
|
||||
done({
|
||||
localeService: {
|
||||
requested: Services.locale.getRequestedLocales(),
|
||||
available: Services.locale.getAvailableLocales(),
|
||||
supported: Services.locale.getAppLocalesAsBCP47(),
|
||||
regionalPrefs: Services.locale.getRegionalPrefsLocales(),
|
||||
requested: Services.locale.requestedLocales,
|
||||
available: Services.locale.availableLocales,
|
||||
supported: Services.locale.appLocalesAsBCP47,
|
||||
regionalPrefs: Services.locale.regionalPrefsLocales,
|
||||
defaultLocale: Services.locale.defaultLocale,
|
||||
},
|
||||
osPrefs: {
|
||||
|
@ -238,7 +238,7 @@ async function promiseCallProvider(aProvider, aMethod, ...aArgs) {
|
||||
* @return the selected locale or "en-US" if none is selected
|
||||
*/
|
||||
function getLocale() {
|
||||
return Services.locale.getRequestedLocale() || "en-US";
|
||||
return Services.locale.requestedLocale || "en-US";
|
||||
}
|
||||
|
||||
const WEB_EXPOSED_ADDON_PROPERTIES = [ "id", "version", "type", "name",
|
||||
|
@ -273,7 +273,7 @@ function matchesOSABI(blocklistElement) {
|
||||
* @returns {string} The current requested locale.
|
||||
*/
|
||||
function getLocale() {
|
||||
return Services.locale.getRequestedLocale();
|
||||
return Services.locale.requestedLocale;
|
||||
}
|
||||
|
||||
/* Get the distribution pref values, from defaults only */
|
||||
|
@ -347,7 +347,7 @@ class AddonInternal {
|
||||
*/
|
||||
const locales = [].concat(...this.locales.map(loc => loc.locales));
|
||||
|
||||
let requestedLocales = Services.locale.getRequestedLocales();
|
||||
let requestedLocales = Services.locale.requestedLocales;
|
||||
|
||||
/**
|
||||
* If en-US is not in the list, add it as the last fallback.
|
||||
|
@ -510,7 +510,7 @@ function isNightlyChannel() {
|
||||
|
||||
|
||||
async function restartWithLocales(locales) {
|
||||
Services.locale.setRequestedLocales(locales);
|
||||
Services.locale.requestedLocales = locales;
|
||||
await promiseRestartManager();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ add_task(async function test_blocklist_disabled() {
|
||||
defaults.setCharPref(PREF_APP_UPDATE_CHANNEL, EXPECTED.channel);
|
||||
defaults.setCharPref(PREF_APP_DISTRIBUTION, EXPECTED.distribution);
|
||||
defaults.setCharPref(PREF_APP_DISTRIBUTION_VERSION, EXPECTED.distribution_version);
|
||||
Services.locale.setRequestedLocales([EXPECTED.locale]);
|
||||
Services.locale.requestedLocales = [EXPECTED.locale];
|
||||
|
||||
// This should correctly escape everything
|
||||
Services.prefs.setCharPref(PREF_BLOCKLIST_URL, "http://example.com/2?" + PARAMS);
|
||||
|
@ -62,7 +62,7 @@ const ADDON = {
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
|
||||
Services.locale.setRequestedLocales(["fr-FR"]);
|
||||
Services.locale.requestedLocales = ["fr-FR"];
|
||||
|
||||
await promiseStartupManager();
|
||||
await promiseInstallXPI(ADDON);
|
||||
|
@ -77,7 +77,7 @@ for (let [name, addon] of Object.entries(ADDONS)) {
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
Services.locale.setRequestedLocales(["fr-FR"]);
|
||||
Services.locale.requestedLocales = ["fr-FR"];
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
|
@ -73,7 +73,7 @@ add_task(async function() {
|
||||
|
||||
// Make sure that `und` locale is not installed.
|
||||
equal(L10nRegistry.getAvailableLocales().includes("und"), false);
|
||||
equal(Services.locale.getAvailableLocales().includes("und"), false);
|
||||
equal(Services.locale.availableLocales.includes("und"), false);
|
||||
|
||||
let [, {addon}] = await Promise.all([
|
||||
promiseLangpackStartup(),
|
||||
@ -82,13 +82,13 @@ add_task(async function() {
|
||||
|
||||
// Now make sure that `und` locale is available.
|
||||
equal(L10nRegistry.getAvailableLocales().includes("und"), true);
|
||||
equal(Services.locale.getAvailableLocales().includes("und"), true);
|
||||
equal(Services.locale.availableLocales.includes("und"), true);
|
||||
|
||||
await addon.disable();
|
||||
|
||||
// It is not available after the langpack has been disabled.
|
||||
equal(L10nRegistry.getAvailableLocales().includes("und"), false);
|
||||
equal(Services.locale.getAvailableLocales().includes("und"), false);
|
||||
equal(Services.locale.availableLocales.includes("und"), false);
|
||||
|
||||
// This quirky code here allows us to handle a scenario where enabling the
|
||||
// addon is synchronous or asynchronous.
|
||||
@ -99,13 +99,13 @@ add_task(async function() {
|
||||
|
||||
// After re-enabling it, the `und` locale is available again.
|
||||
equal(L10nRegistry.getAvailableLocales().includes("und"), true);
|
||||
equal(Services.locale.getAvailableLocales().includes("und"), true);
|
||||
equal(Services.locale.availableLocales.includes("und"), true);
|
||||
|
||||
await addon.uninstall();
|
||||
|
||||
// After the langpack has been uninstalled, no more `und` in locales.
|
||||
equal(L10nRegistry.getAvailableLocales().includes("und"), false);
|
||||
equal(Services.locale.getAvailableLocales().includes("und"), false);
|
||||
equal(Services.locale.availableLocales.includes("und"), false);
|
||||
});
|
||||
|
||||
/**
|
||||
@ -134,8 +134,8 @@ add_task(async function() {
|
||||
|
||||
{
|
||||
// Test chrome package
|
||||
let reqLocs = Services.locale.getRequestedLocales();
|
||||
Services.locale.setRequestedLocales(["und"]);
|
||||
let reqLocs = Services.locale.requestedLocales;
|
||||
Services.locale.requestedLocales = ["und"];
|
||||
|
||||
let bundle = Services.strings.createBundle(
|
||||
"chrome://global/locale/test.properties"
|
||||
@ -143,7 +143,7 @@ add_task(async function() {
|
||||
let entry = bundle.GetStringFromName("message");
|
||||
equal(entry, "Value from .properties");
|
||||
|
||||
Services.locale.setRequestedLocales(reqLocs);
|
||||
Services.locale.requestedLocales = reqLocs;
|
||||
}
|
||||
|
||||
await addon.uninstall();
|
||||
@ -153,7 +153,7 @@ add_task(async function() {
|
||||
add_task(async function test_amazing_disappearing_langpacks() {
|
||||
let check = (yes) => {
|
||||
equal(L10nRegistry.getAvailableLocales().includes("und"), yes);
|
||||
equal(Services.locale.getAvailableLocales().includes("und"), yes);
|
||||
equal(Services.locale.availableLocales.includes("und"), yes);
|
||||
};
|
||||
|
||||
await promiseStartupManager();
|
||||
|
@ -88,7 +88,7 @@ HandlerService.prototype = {
|
||||
|
||||
try {
|
||||
prefsDefaultHandlersVersion = Number(prefsDefaultHandlersVersion.data);
|
||||
let locale = Services.locale.getAppLocaleAsLangTag();
|
||||
let locale = Services.locale.appLocaleAsLangTag;
|
||||
|
||||
let defaultHandlersVersion =
|
||||
this._store.data.defaultHandlersVersion[locale] || 0;
|
||||
|
Loading…
Reference in New Issue
Block a user