Bug 1629275 - part3 - better fix for porting
bug 1621674 to Thunderbird (Unify Localization.jsm, mozILocalization and Localization IDL). r=Paenglab DONTBUILD
--- a/calendar/base/modules/calCalendarDeactivator.jsm
+++ b/calendar/base/modules/calCalendarDeactivator.jsm
@@ -1,21 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
this.EXPORTED_SYMBOLS = ["calendarDeactivator"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
-const { Localization } = ChromeUtils.import("resource://gre/modules/Localization.jsm");
-const syncL10n = new Localization(["calendar/calendar-widgets.ftl"], true);
-syncL10n.setIsSync(true);
-syncL10n.init();
+var l10n = new Localization(["calendar/calendar-widgets.ftl"], true);
/**
* Handles deactivation of calendar UI and background processes/services (such
* as the alarms service) when users do not want to use calendar functionality.
* Also handles re-activation when users change their mind.
*
* If all of a user's calendars are disabled (e.g. calendar > properties >
* "turn this calendar on") then full calendar functionality is deactivated.
@@ -124,17 +121,17 @@ var calendarDeactivator = {
];
for (let [notificationbox, messageName] of notificationboxes) {
let existingNotification = notificationbox.getNotificationWithValue(value);
if (calendarIsActivated) {
notificationbox.removeNotification(existingNotification);
} else if (!existingNotification) {
- let message = syncL10n.formatValueSync(messageName);
+ let message = l10n.formatValueSync(messageName);
let priority = notificationbox.PRIORITY_WARNING_MEDIUM;
notificationbox.appendNotification(message, value, null, priority, null);
}
}
},
// calICalendarManagerObserver methods
--- a/chat/content/otr-finger.js
+++ b/chat/content/otr-finger.js
@@ -1,21 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
var { OTR } = ChromeUtils.import("resource:///modules/OTR.jsm");
-var { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
-);
-var l10n = new Localization(["messenger/otr/finger-sync.ftl"]);
-l10n.setIsSync(true);
-l10n.init();
+var l10n = new Localization(["messenger/otr/finger-sync.ftl"], true);
var gFingers;
var fingerTreeView = {
selection: null,
rowCount: 0,
setTree(tree) {},
getImageSrc(row, column) {},
--- a/chat/modules/OTR.jsm
+++ b/chat/modules/OTR.jsm
@@ -1,36 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-const { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
-);
const { BasePromiseWorker } = ChromeUtils.import(
"resource://gre/modules/PromiseWorker.jsm"
);
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
const { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
const { CLib } = ChromeUtils.import("resource:///modules/CLib.jsm");
const { OTRLibLoader } = ChromeUtils.import("resource:///modules/OTRLib.jsm");
-var workerPath = "chrome://chat/content/otrWorker.js";
const { OTRHelpers } = ChromeUtils.import("resource:///modules/OTRHelpers.jsm");
-const syncL10n = new Localization(["messenger/otr/otr.ftl"]);
-syncL10n.setIsSync(true);
-syncL10n.init();
+var l10n = new Localization(["messenger/otr/otr.ftl"], true);
function _str(id) {
- return syncL10n.formatValueSync(id);
+ return l10n.formatValueSync(id);
}
function _strArgs(id, args) {
- return syncL10n.formatValueSync(id, args);
+ return l10n.formatValueSync(id, args);
}
// some helpers
function setInterval(fn, delay) {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.init(fn, delay, Ci.nsITimer.TYPE_REPEATING_SLACK);
return timer;
@@ -232,17 +226,17 @@ var OTR = {
if (!address) {
OTRLib.otrl_privkey_generate_cancelled(OTR.userstate, newkey);
throw new Error(
"generatePrivateKey failed to parse ptr.toSource(): " + keyPtrSrc
);
}
- let worker = new BasePromiseWorker(workerPath);
+ let worker = new BasePromiseWorker("chrome://chat/content/otrWorker.js");
return worker
.post("generateKey", [OTRLib.path, OTRLib.otrl_version, address])
.then(function() {
let err = OTRLib.otrl_privkey_generate_finish(
OTR.userstate,
newkey,
OTR.privateKeyPath
);
--- a/chat/modules/OTRUI.jsm
+++ b/chat/modules/OTRUI.jsm
@@ -1,30 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
this.EXPORTED_SYMBOLS = ["OTRUI"];
-const { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
-);
const { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
const { OTR } = ChromeUtils.import("resource:///modules/OTR.jsm");
-const syncL10n = new Localization(["messenger/otr/otrUI.ftl"]);
-syncL10n.setIsSync(true);
-syncL10n.init();
+var l10n = new Localization(["messenger/otr/otrUI.ftl"], true);
function _str(id) {
- return syncL10n.formatValueSync(id);
+ return l10n.formatValueSync(id);
}
function _strArgs(id, args) {
- return syncL10n.formatValueSync(id, args);
+ return l10n.formatValueSync(id, args);
}
const OTR_AUTH_DIALOG_URL = "chrome://chat/content/otr-auth.xhtml";
const OTR_ADD_FINGER_DIALOG_URL =
"chrome://chat/content/otr-add-fingerprint.xhtml";
const AUTH_STATUS_UNVERIFIED = "otr-auth-unverified";
var authLabelMap;
@@ -422,19 +417,19 @@ var OTRUI = {
OTRUI.noOtrPossible(otrContainer, context);
return;
}
if (addSystemMessage) {
let trust = OTRUI.getTrustSettings(context);
let id = "state-" + trust.class;
let msg;
if (OTR.trust(context) == OTR.trustState.TRUST_NOT_PRIVATE) {
- msg = syncL10n.formatValueSync(id);
+ msg = l10n.formatValueSync(id);
} else {
- msg = syncL10n.formatValueSync(id, { name: context.username });
+ msg = l10n.formatValueSync(id, { name: context.username });
}
uiConv.systemMessage(msg);
}
} catch (e) {
OTRUI.noOtrPossible(otrContainer, context);
return;
}
@@ -594,17 +589,17 @@ var OTRUI = {
msg,
context.username,
null,
priority,
buttons,
null
);
- let verifyTitle = syncL10n.formatValueSync("verify-title");
+ let verifyTitle = l10n.formatValueSync("verify-title");
this.updateNotificationUI(
context,
verifyTitle,
context.username,
AUTH_STATUS_UNVERIFIED
);
if (!this.visibleConv) {
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -29,24 +29,20 @@
const { DBViewWrapper } = ChromeUtils.import(
"resource:///modules/DBViewWrapper.jsm"
);
const { TagUtils } = ChromeUtils.import("resource:///modules/TagUtils.jsm");
var { MimeParser } = ChromeUtils.import("resource:///modules/mimeParser.jsm");
var { DisplayNameUtils } = ChromeUtils.import(
"resource:///modules/DisplayNameUtils.jsm"
);
- var { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
+ var l10n = new Localization(
+ ["messenger/messengercompose/messengercompose.ftl"],
+ true
);
- var l10n = new Localization([
- "messenger/messengercompose/messengercompose.ftl",
- ]);
- l10n.setIsSync(true);
- l10n.init();
class MozMailHeaderfield extends MozXULElement {
connectedCallback() {
this.setAttribute("context", "copyPopup");
this.classList.add("headerValue");
}
set headerValue(val) {
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -16,19 +16,16 @@ var { AddonManager } = ChromeUtils.impor
"resource://gre/modules/AddonManager.jsm"
);
var { StringBundle } = ChromeUtils.import(
"resource:///modules/StringBundle.jsm"
);
var { ExtensionParent } = ChromeUtils.import(
"resource://gre/modules/ExtensionParent.jsm"
);
-var { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
-);
function tabProgressListener(aTab, aStartsBlank) {
this.mTab = aTab;
this.mBrowser = aTab.browser;
this.mBlank = aStartsBlank;
this.mProgressListener = null;
}
@@ -379,19 +376,17 @@ var contentTabBaseType = {
// Let's not mess with about:blank.
null,
// about:profiles
function(aDocument, aTab) {
// Need a timeout to let the script run to create the needed buttons.
setTimeout(() => {
- let l10n = new Localization(["messenger/aboutProfilesExtra.ftl"]);
- l10n.setIsSync(true);
- l10n.init();
+ let l10n = new Localization(["messenger/aboutProfilesExtra.ftl"], true);
for (let button of aDocument.querySelectorAll(
`[data-l10n-id="profiles-launch-profile"]`
)) {
button.textContent = l10n.formatValueSync(
"profiles-launch-profile-plain"
);
}
}, 500);
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -48,24 +48,20 @@ var { PluralForm } = ChromeUtils.import(
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
var { MailConstants } = ChromeUtils.import(
"resource:///modules/MailConstants.jsm"
);
-var { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
+var l10n = new Localization(
+ ["messenger/messengercompose/messengercompose.ftl"],
+ true
);
-var l10n = new Localization([
- "messenger/messengercompose/messengercompose.ftl",
-]);
-l10n.setIsSync(true);
-l10n.init();
ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
ChromeUtils.defineModuleGetter(
this,
"ShortcutUtils",
"resource://gre/modules/ShortcutUtils.jsm"
);
--- a/mail/components/preferences/general.js
+++ b/mail/components/preferences/general.js
@@ -25,19 +25,16 @@ var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
var { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
var { L10nRegistry } = ChromeUtils.import(
"resource://gre/modules/L10nRegistry.jsm"
);
-var { Localization } = ChromeUtils.import(
- "resource://gre/modules/Localization.jsm"
-);
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { UpdateUtils } = ChromeUtils.import(
"resource://gre/modules/UpdateUtils.jsm"
);
var { TagUtils } = ChromeUtils.import("resource:///modules/TagUtils.jsm");
XPCOMUtils.defineLazyServiceGetters(this, {
gHandlerService: [
--- a/mailnews/base/content/msgAccountCentral.js
+++ b/mailnews/base/content/msgAccountCentral.js
@@ -5,19 +5,17 @@
/* import-globals-from ../../../mail/base/content/mailCore.js */
/* import-globals-from ../prefs/content/accountUtils.js */
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
);
-var l10n = new Localization(["messenger/accountCentral.ftl"]);
-l10n.setIsSync(true);
-l10n.init();
+var l10n = new Localization(["messenger/accountCentral.ftl"], true);
var gSelectedServer = null;
var gSelectedFolder = null;
/**
* Set up the whole page depending on the selected folder/account.
* The folder is passed in via the document URL.
*/