--- a/accessible/jsat/Utils.jsm
+++ b/accessible/jsat/Utils.jsm
@@ -232,18 +232,17 @@ this.Utils = { // jshint ignore:line
let args = aDetails.args;
let count = aDetails.count;
if (args) {
str = bundle.formatStringFromName(string, args, args.length);
} else {
str = bundle.GetStringFromName(string);
}
if (count) {
- str = PluralForm.get(count, str);
- str = str.replace("#1", count);
+ str = PluralForm.getReplace(count, str);
}
} catch (e) {
Logger.debug("Failed to get a string from a bundle for", string);
} finally {
return str;
}
}
};
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -176,19 +176,18 @@ var gXPInstallObserver = {
messageString = gNavigatorBundle.getString("addonConfirmInstallSomeUnsigned.message");
notification.setAttribute("warning", "true");
options.learnMoreURL += "unsigned-addons";
}
let brandBundle = document.getElementById("bundle_brand");
let brandShortName = brandBundle.getString("brandShortName");
- messageString = PluralForm.get(installInfo.installs.length, messageString);
- messageString = messageString.replace("#1", brandShortName);
- messageString = messageString.replace("#2", installInfo.installs.length);
+ messageString = PluralForm.getReplaceAll(installInfo.installs.length,
+ messageString, [brandShortName, installInfo.installs.length]);
let action = {
label: gNavigatorBundle.getString("addonInstall.acceptButton2.label"),
accessKey: gNavigatorBundle.getString("addonInstall.acceptButton2.accesskey"),
callback: acceptInstallation,
};
let secondaryAction = {
@@ -311,18 +310,17 @@ var gXPInstallObserver = {
return aInstall.state != AddonManager.STATE_DOWNLOADED;
}
// If all installs have already been downloaded then there is no need to
// show the download progress
if (!installInfo.installs.some(needsDownload))
return;
notificationID = "addon-progress";
messageString = gNavigatorBundle.getString("addonDownloadingAndVerifying");
- messageString = PluralForm.get(installInfo.installs.length, messageString);
- messageString = messageString.replace("#1", installInfo.installs.length);
+ messageString = PluralForm.getReplace(installInfo.installs.length, messageString);
options.installs = installInfo.installs;
options.contentWindow = browser.contentWindow;
options.sourceURI = browser.currentURI;
options.eventCallback = function(aEvent) {
switch (aEvent) {
case "shown":
let notificationElement = [...this.owner.panel.childNodes]
.find(n => n.notification == this);
@@ -457,20 +455,18 @@ var gXPInstallObserver = {
accessKey: gNavigatorBundle.getString("addonInstallRestartIgnoreButton.accesskey"),
callback: () => {},
}];
} else {
messageString = gNavigatorBundle.getString("addonsInstalled");
action = null;
}
- messageString = PluralForm.get(installInfo.installs.length, messageString);
- messageString = messageString.replace("#1", installInfo.installs[0].name);
- messageString = messageString.replace("#2", installInfo.installs.length);
- messageString = messageString.replace("#3", brandShortName);
+ messageString = PluralForm.getReplaceAll(installInfo.installs.length, messageString,
+ [installInfo.installs[0].name, installInfo.installs.length, brandShortName]);
// Remove notification on dismissal, since it's possible to cancel the
// install through the addons manager UI, making the "restart" prompt
// irrelevant.
options.removeOnDismissal = true;
options.persistent = false;
PopupNotifications.show(browser, notificationID, messageString, anchorID,
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -228,17 +228,17 @@ var ctrlTab = {
},
updatePreviews: function ctrlTab_updatePreviews() {
for (let i = 0; i < this.previews.length; i++)
this.updatePreview(this.previews[i], this.tabList[i]);
var showAllLabel = gNavigatorBundle.getString("ctrlTab.listAllTabs.label");
this.showAllButton.label =
- PluralForm.get(this.tabCount, showAllLabel).replace("#1", this.tabCount);
+ PluralForm.getReplace(this.tabCount, showAllLabel);
this.showAllButton.hidden = !allTabs.canOpen;
},
updatePreview: function ctrlTab_updatePreview(aPreview, aTab) {
if (aPreview == this.showAllButton)
return;
aPreview._tab = aTab;
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -289,20 +289,19 @@ var StarUI = {
this._itemGuids = [];
await PlacesUtils.bookmarks.fetch({url: aUrl},
bookmark => this._itemGuids.push(bookmark.guid));
if (!PlacesUIUtils.useAsyncTransactions) {
this._itemIdsMap = await PlacesUtils.promiseManyItemIds(this._itemGuids);
}
- let forms = gNavigatorBundle.getString("editBookmark.removeBookmarks.label");
let bookmarksCount = this._itemGuids.length;
- let label = PluralForm.get(bookmarksCount, forms)
- .replace("#1", bookmarksCount);
+ let label = PluralForm.getReplaceFromBundle(
+ bookmarksCount, gNavigatorBundle, "editBookmark.removeBookmarks.label");
this._element("editBookmarkPanelRemoveButton").label = label;
this.beginBatch();
if (aAnchorElement && aAnchorElement.closest("#urlbar")) {
this._anchorToolbarButton = aAnchorElement;
aAnchorElement.setAttribute("open", "true");
} else {
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -642,20 +642,18 @@ var gPopupBlockerObserver = {
var stringKey = AppConstants.platform == "win"
? "popupWarningButton"
: "popupWarningButtonUnix";
var popupButtonText = gNavigatorBundle.getString(stringKey);
var popupButtonAccesskey = gNavigatorBundle.getString(stringKey + ".accesskey");
- var messageBase = gNavigatorBundle.getString("popupWarning.message");
- var message = PluralForm.get(popupCount, messageBase)
- .replace("#1", brandShortName)
- .replace("#2", popupCount);
+ var message = PluralForm.getReplaceAllFromBundle(popupCount,
+ gNavigatorBundle, "popupWarning.message", [brandShortName, popupCount]);
let notificationBox = gBrowser.getNotificationBox();
let notification = notificationBox.getNotificationWithValue("popup-blocked");
if (notification) {
notification.label = message;
} else {
var buttons = [{
label: popupButtonText,
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2916,18 +2916,17 @@
// focus the window before prompting.
// this will raise any minimized window, which will
// make it obvious which window the prompt is for and will
// solve the problem of windows "obscuring" the prompt.
// see bug #350299 for more details
window.focus();
var warningMessage =
- PluralForm.get(tabsToClose, bundle.getString("tabs.closeWarningMultiple"))
- .replace("#1", tabsToClose);
+ PluralForm.getReplace(tabsToClose, bundle.getString("tabs.closeWarningMultiple"));
var buttonPressed =
ps.confirmEx(window,
bundle.getString("tabs.closeWarningTitle"),
warningMessage,
(ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0)
+ (ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1),
bundle.getString("tabs.closeButtonMultiple"),
null, null,
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -2439,20 +2439,18 @@ BrowserGlue.prototype = {
if (unknownDevice) {
tabArrivingBody = "unnamedTabsArrivingNotificationNoDevice.body";
} else if (allSameDevice) {
tabArrivingBody = "unnamedTabsArrivingNotification2.body";
} else {
tabArrivingBody = "unnamedTabsArrivingNotificationMultiple2.body"
}
- body = bundle.GetStringFromName(tabArrivingBody);
- body = PluralForm.get(URIs.length, body);
- body = body.replace("#1", URIs.length);
- body = body.replace("#2", deviceName);
+ body = PluralForm.getReplaceAllFromBundle(URIs.length, bundle,
+ tabArrivingBody, [URIs.length, deviceName]);
}
const clickCallback = (obsSubject, obsTopic, obsData) => {
if (obsTopic == "alertclickcallback") {
win.gBrowser.selectedTab = firstTab;
}
}
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -289,23 +289,17 @@ this.PlacesUIUtils = {
* @param aParams
* Array whose items will substitute #1, #2,... #n parameters
* in the string.
*
* @see https://developer.mozilla.org/en/Localization_and_Plurals
* @return The localized plural string.
*/
getPluralString: function PUIU_getPluralString(aKey, aNumber, aParams) {
- let str = PluralForm.get(aNumber, bundle.GetStringFromName(aKey));
-
- // Replace #1 with aParams[0], #2 with aParams[1], and so on.
- return str.replace(/\#(\d+)/g, function(matchedId, matchedNumber) {
- let param = aParams[parseInt(matchedNumber, 10) - 1];
- return param !== undefined ? param : matchedId;
- });
+ return PluralForm.getReplaceAllFromBundle(aNumber, bundle, aKey, aParams);
},
getString: function PUIU_getString(key) {
return bundle.GetStringFromName(key);
},
get _copyableAnnotations() {
return [
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -562,20 +562,20 @@ var gCookiesWindow = {
if (!item) continue;
if (item.container)
selectedCookieCount += item.cookies.length;
else if (!item.container)
++selectedCookieCount;
}
}
- let buttonLabel = this._bundle.getString("removeSelectedCookies.label");
let removeSelectedCookies = document.getElementById("removeSelectedCookies");
- removeSelectedCookies.label = PluralForm.get(selectedCookieCount, buttonLabel)
- .replace("#1", selectedCookieCount);
+ removeSelectedCookies.label =
+ PluralForm.getReplaceFromBundle(selectedCookieCount, this._bundle,
+ "removeSelectedCookies.label");
removeSelectedCookies.disabled = !(seln.count > 0);
},
performDeletion: function gCookiesWindow_performDeletion(deleteItems) {
var psvc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var blockFutureCookies = false;
--- a/browser/components/preferences/in-content/containers.js
+++ b/browser/components/preferences/in-content/containers.js
@@ -43,18 +43,18 @@ let gContainersPane = {
async onRemoveClick(button) {
let userContextId = parseInt(button.getAttribute("value"), 10);
let count = ContextualIdentityService.countContainerTabs(userContextId);
if (count > 0) {
let bundlePreferences = document.getElementById("bundlePreferences");
let title = bundlePreferences.getString("removeContainerAlertTitle");
- let message = PluralForm.get(count, bundlePreferences.getString("removeContainerMsg"))
- .replace("#S", count)
+ let message = PluralForm.getFromBundle(count, bundlePreferences, "removeContainerMsg")
+ .replace("#S", count);
let okButton = bundlePreferences.getString("removeContainerOkButton");
let cancelButton = bundlePreferences.getString("removeContainerButton2");
let buttonFlags = (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
let rv = Services.prompt.confirmEx(window, title, message, buttonFlags,
okButton, cancelButton, null, null, {});
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -1026,20 +1026,22 @@ var gMainPane = {
if (count == 0) {
Services.prefs.setBoolPref("privacy.userContext.enabled", false);
return;
}
let bundlePreferences = document.getElementById("bundlePreferences");
let title = bundlePreferences.getString("disableContainersAlertTitle");
- let message = PluralForm.get(count, bundlePreferences.getString("disableContainersMsg"))
- .replace("#S", count)
- let okButton = PluralForm.get(count, bundlePreferences.getString("disableContainersOkButton"))
- .replace("#S", count)
+ let message =
+ PluralForm.getFromBundle(count, bundlePreferences, "disableContainersMsg")
+ .replace("#S", count);
+ let okButton =
+ PluralForm.getRFromBundle(count, bundlePreferences, "disableContainersOkButton")
+ .replace("#S", count);
let cancelButton = bundlePreferences.getString("disableContainersButton2");
let buttonFlags = (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
let rv = Services.prompt.confirmEx(window, title, message, buttonFlags,
okButton, cancelButton, null, null, {});
if (rv == 0) {
--- a/browser/modules/ContentCrashHandlers.jsm
+++ b/browser/modules/ContentCrashHandlers.jsm
@@ -742,20 +742,18 @@ this.UnsubmittedCrashHandler = {
* @returns The <xul:notification> if one is shown. null otherwise.
*/
showPendingSubmissionsNotification(reportIDs) {
let count = reportIDs.length;
if (!count) {
return null;
}
- let messageTemplate =
- gNavigatorBundle.GetStringFromName("pendingCrashReports2.label");
-
- let message = PluralForm.get(count, messageTemplate).replace("#1", count);
+ let message = PluralForm.getReplaceFromBundle(
+ count, gNavigatorBundle, "pendingCrashReports2.label");
let notification = this.show({
notificationID: "pending-crash-reports",
message,
reportIDs,
onAction: () => {
this.showingNotification = false;
},
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -591,19 +591,18 @@ function prompt(aBrowser, aRequest) {
} else {
name = device.name;
if (type == "application") {
// The application names returned by the platform are of the form:
// <window count>\x1e<application name>
let sepIndex = name.indexOf("\x1e");
let count = name.slice(0, sepIndex);
let sawcStringId = "getUserMedia.shareApplicationWindowCount.label";
- name = PluralForm.get(parseInt(count), stringBundle.getString(sawcStringId))
- .replace("#1", name.slice(sepIndex + 1))
- .replace("#2", count);
+ name = PluralForm.getReplaceAllFromBundle(parseInt(count),
+ stringBundle, sawcStringId, [name.slice(sepIndex + 1), count]);
}
}
let item = addDeviceToList(menupopup, name, i, typeName);
item.deviceId = device.id;
if (device.scary)
item.scary = true;
}
@@ -902,17 +901,17 @@ function getGlobalIndicator() {
this.appendChild(menuitem);
return true;
}
// We show a different menu when there are several active streams.
let menuitem = this.ownerDocument.createElement("menuitem");
let labelId = "webrtcIndicator.sharing" + type + "WithNTabs.menuitem";
let count = activeStreams.length;
- let label = PluralForm.get(count, bundle.GetStringFromName(labelId)).replace("#1", count);
+ let label = PluralForm.getReplaceAllFromBundle(count, bundle, labelId);
menuitem.setAttribute("label", label);
menuitem.setAttribute("disabled", "true");
this.appendChild(menuitem);
for (let stream of activeStreams) {
let item = this.ownerDocument.createElement("menuitem");
labelId = "webrtcIndicator.controlSharingOn.menuitem";
label = stream.browser.contentTitle || stream.uri;
--- a/mobile/android/chrome/content/aboutDownloads.js
+++ b/mobile/android/chrome/content/aboutDownloads.js
@@ -203,18 +203,18 @@ var downloadLists = {
removeFinished: function() {
let finished = this.finished;
if (finished.length == 0) {
return;
}
let title = strings.GetStringFromName("downloadAction.deleteAll");
- let messageForm = strings.GetStringFromName("downloadMessage.deleteAll");
- let message = PluralForm.get(finished.length, messageForm).replace("#1", finished.length);
+ let message = PluralForm.getReplaceFromBundle(finished.length, strings,
+ "downloadMessage.deleteAll");
if (Services.prompt.confirm(null, title, message)) {
Downloads.getList(Downloads.ALL)
.then(list => {
for (let download of finished) {
list.remove(download).catch(Cu.reportError);
deleteDownload(download);
}
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -582,18 +582,17 @@ var BrowserApp = {
function(aTarget) {
UITelemetry.addEvent("action.1", "contextmenu", null, "web_open_new_tab");
UITelemetry.addEvent("loadurl.1", "contextmenu", null);
let url = NativeWindow.contextmenus._getLinkURL(aTarget);
ContentAreaUtils.urlSecurityCheck(url, aTarget.ownerDocument.nodePrincipal);
let tab = BrowserApp.addTab(url, { selected: false, parentId: BrowserApp.selectedTab.id });
- let newtabStrings = Strings.browser.GetStringFromName("newtabpopup.opened");
- let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
+ let label = PluralForm.getReplaceFromBundle(1, Strings.browser, "newtabpopup.opened");
let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
Snackbars.show(label, Snackbars.LENGTH_LONG, {
action: {
label: buttonLabel,
callback: () => { BrowserApp.selectTab(tab); },
}
});
@@ -611,18 +610,18 @@ var BrowserApp = {
function (aTarget) {
UITelemetry.addEvent("action.1", "contextmenu", null, "web_open_new_tab");
UITelemetry.addEvent("loadurl.1", "contextmenu", null);
let url = NativeWindow.contextmenus._getLinkURL(aTarget);
ContentAreaUtils.urlSecurityCheck(url, aTarget.ownerDocument.nodePrincipal);
let tab = BrowserApp.addTab(url, {selected: false, parentId: BrowserApp.selectedTab.id, isPrivate: true});
- let newtabStrings = Strings.browser.GetStringFromName("newprivatetabpopup.opened");
- let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
+ let label = PluralForm.getReplaceFromBundle(1, Strings.browser,
+ "newprivatetabpopup.opened");
let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
Snackbars.show(label, Snackbars.LENGTH_LONG, {
action: {
label: buttonLabel,
callback: () => { BrowserApp.selectTab(tab); },
}
});
});
@@ -5191,19 +5190,18 @@ var PopupBlockerObserver = {
// notifications are per-browser, we don't need to worry about re-adding
// it.
if (!browser.pageReport.reported) {
if (Services.prefs.getBoolPref("privacy.popups.showBrowserMessage")) {
let brandShortName = Strings.brand.GetStringFromName("brandShortName");
let popupCount = browser.pageReport.length;
let strings = Strings.browser;
- let message = PluralForm.get(popupCount, strings.GetStringFromName("popup.message"))
- .replace("#1", brandShortName)
- .replace("#2", popupCount);
+ let message = PluralForm.getReplaceAllFromBundle(popupCount, strings,
+ "popup.message", [brandShortName, popupCount]);
let buttons = [
{
label: strings.GetStringFromName("popup.dontShow"),
callback: function(aChecked) {
if (aChecked)
PopupBlockerObserver.allowPopupsForSite(false);
}
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -880,18 +880,17 @@ this.ExtensionData = class {
result.msgs.push(...items.map(item => bundle.formatStringFromName(itemKey, [item], 1)));
}
if (list.length < 5) {
formatItems(list);
} else {
formatItems(list.slice(0, 3));
let remaining = list.length - 3;
- result.msgs.push(PluralForm.get(remaining, bundle.GetStringFromName(moreKey))
- .replace("#1", remaining));
+ result.msgs.push(PluralForm.getReplaceFromBundle(remaining, bundle, moreKey));
}
};
format(Array.from(wildcards), "webextPerms.hostDescription.wildcard",
"webextPerms.hostDescription.tooManyWildcards");
format(Array.from(sites), "webextPerms.hostDescription.oneSite",
"webextPerms.hostDescription.tooManySites");
}
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -760,19 +760,18 @@ AboutReader.prototype = {
_formatReadTime(slowEstimate, fastEstimate) {
let displayStringKey = "aboutReader.estimatedReadTimeRange1";
// only show one reading estimate when they are the same value
if (slowEstimate == fastEstimate) {
displayStringKey = "aboutReader.estimatedReadTimeValue1";
}
- return PluralForm.get(slowEstimate, gStrings.GetStringFromName(displayStringKey))
- .replace("#1", fastEstimate)
- .replace("#2", slowEstimate);
+ return PluralForm.getReplaceAllFromBundle(
+ slowEstimate, gStrings, displayStringKey, [fastEstimate, slowEstimate]);
},
_showError() {
this._headerElement.style.display = "none";
this._contentElement.style.display = "none";
let errorMessage = gStrings.GetStringFromName("aboutReader.loadError");
this._messageElement.textContent = errorMessage;
--- a/toolkit/components/tooltiptext/TooltipTextProvider.js
+++ b/toolkit/components/tooltiptext/TooltipTextProvider.js
@@ -73,21 +73,21 @@ TooltipTextProvider.prototype = {
const TRUNCATED_FILE_COUNT = 20;
let count = Math.min(files.length, TRUNCATED_FILE_COUNT);
for (let i = 1; i < count; ++i) {
titleText += "\n" + files[i].name;
}
if (files.length == TRUNCATED_FILE_COUNT + 1) {
titleText += "\n" + files[TRUNCATED_FILE_COUNT].name;
} else if (files.length > TRUNCATED_FILE_COUNT + 1) {
- let xmoreStr = bundle.GetStringFromName("AndNMoreFiles");
let xmoreNum = files.length - TRUNCATED_FILE_COUNT;
let tmp = {};
Cu.import("resource://gre/modules/PluralForm.jsm", tmp);
- let andXMoreStr = tmp.PluralForm.get(xmoreNum, xmoreStr).replace("#1", xmoreNum);
+ let andXMoreStr =
+ tmp.PluralForm.getReplaceFromBundle(xmoreNum, bundle, "AndNMoreFiles");
titleText += "\n" + andXMoreStr;
}
}
} catch (e) {}
}
// Check texts against null so that title="" can be used to undefine a
// title on a child element.
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -108,18 +108,17 @@ var snapshotFormatters = {
crashes: function crashes(data) {
if (!AppConstants.MOZ_CRASHREPORTER)
return;
let strings = stringBundle();
let daysRange = Troubleshoot.kMaxCrashAge / (24 * 60 * 60 * 1000);
$("crashes-title").textContent =
- PluralForm.get(daysRange, strings.GetStringFromName("crashesTitle"))
- .replace("#1", daysRange);
+ PluralForm.getReplaceFromBundle(daysRange, strings, "crashesTitle");
let reportURL;
try {
reportURL = Services.prefs.getCharPref("breakpad.reportURL");
// Ignore any non http/https urls
if (!/^https?:/i.test(reportURL))
reportURL = null;
} catch (e) { }
if (!reportURL) {
@@ -127,40 +126,36 @@ var snapshotFormatters = {
$("crashes-noConfig").classList.remove("no-copy");
return;
}
$("crashes-allReports").style.display = "block";
$("crashes-allReports").classList.remove("no-copy");
if (data.pending > 0) {
$("crashes-allReportsWithPending").textContent =
- PluralForm.get(data.pending, strings.GetStringFromName("pendingReports"))
- .replace("#1", data.pending);
+ PluralForm.getReplaceFromBundle(data.pending, strings, "pendingReports");
}
let dateNow = new Date();
$.append($("crashes-tbody"), data.submitted.map(function(crash) {
let date = new Date(crash.date);
let timePassed = dateNow - date;
let formattedDate;
if (timePassed >= 24 * 60 * 60 * 1000) {
let daysPassed = Math.round(timePassed / (24 * 60 * 60 * 1000));
- let daysPassedString = strings.GetStringFromName("crashesTimeDays");
- formattedDate = PluralForm.get(daysPassed, daysPassedString)
- .replace("#1", daysPassed);
+ formattedDate =
+ PluralForm.getReplaceFromBundle(daysPassed, strings, "crashesTimeDays");
} else if (timePassed >= 60 * 60 * 1000) {
let hoursPassed = Math.round(timePassed / (60 * 60 * 1000));
- let hoursPassedString = strings.GetStringFromName("crashesTimeHours");
- formattedDate = PluralForm.get(hoursPassed, hoursPassedString)
- .replace("#1", hoursPassed);
+ formattedDate =
+ PluralForm.getReplaceFromBundle(hoursPassed, strings, "crashesTimeHours");
} else {
let minutesPassed = Math.max(Math.round(timePassed / (60 * 1000)), 1);
- let minutesPassedString = strings.GetStringFromName("crashesTimeMinutes");
- formattedDate = PluralForm.get(minutesPassed, minutesPassedString)
- .replace("#1", minutesPassed);
+ formattedDate =
+ PluralForm.getReplaceFromBundle(minutesPassed, strings, "crashesTimeMinutes");
}
return $.new("tr", [
$.new("td", [
$.new("a", crash.id, null, {href: reportURL + crash.id})
]),
$.new("td", formattedDate)
]);
}));
--- a/toolkit/mozapps/downloads/DownloadUtils.jsm
+++ b/toolkit/mozapps/downloads/DownloadUtils.jsm
@@ -539,17 +539,17 @@ function convertTimeUnitsValue(aTime) {
* Index into gStr.timeUnits for the appropriate unit
* @return The appropriate plural form of the unit for the time
*/
function convertTimeUnitsUnits(aTime, aIndex) {
// Negative index would be an invalid unit, so just give empty
if (aIndex < 0)
return "";
- return PluralForm.get(aTime, gBundle.GetStringFromName(gStr.timeUnits[aIndex]));
+ return PluralForm.getFromBundle(aTime, gBundle, gStr.timeUnits[aIndex]);
}
/**
* Private helper function to log errors to the error console and command line
*
* @param aMsg
* Error message to log or an array of strings to concat
*/
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2639,19 +2639,18 @@ var gSearchView = {
},
showAllResultsLink(aTotalResults) {
if (aTotalResults == 0) {
this._allResultsLink.hidden = true;
return;
}
- var linkStr = gStrings.ext.GetStringFromName("showAllSearchResults");
- linkStr = PluralForm.get(aTotalResults, linkStr);
- linkStr = linkStr.replace("#1", aTotalResults);
+ var linkStr =
+ PluralForm.getReplaceFromBundle(aTotalResults, gStrings.ext, "showAllSearchResults");
this._allResultsLink.setAttribute("value", linkStr);
this._allResultsLink.setAttribute("href",
AddonRepository.getSearchURL(this._lastQuery));
this._allResultsLink.hidden = false;
},
updateListAttributes() {
@@ -3271,20 +3270,18 @@ var gDetailView = {
rating.averageRating = aAddon.averageRating;
rating.hidden = false;
} else {
rating.hidden = true;
}
var reviews = document.getElementById("detail-reviews");
if (aAddon.reviewURL) {
- var text = gStrings.ext.GetStringFromName("numReviews");
- text = PluralForm.get(aAddon.reviewCount, text)
- text = text.replace("#1", aAddon.reviewCount);
- reviews.value = text;
+ reviews.value =
+ PluralForm.getReplaceFromBundle(aAddon.reviewCount, gStrings.ext, "numReviews");
reviews.hidden = false;
reviews.href = aAddon.reviewURL;
} else {
reviews.hidden = true;
}
document.getElementById("detail-rating-row").hidden = !aAddon.averageRating && !aAddon.reviewURL;
@@ -3348,19 +3345,17 @@ var gDetailView = {
let timeKey = prefix + "time.";
let timeMessage;
if (days < 1) {
timeKey += (active ? "endsToday" : "endedToday");
timeMessage = gStrings.ext.GetStringFromName(timeKey);
} else {
timeKey += (active ? "daysRemaining" : "daysPassed");
days = Math.round(days);
- let timeString = gStrings.ext.GetStringFromName(timeKey);
- timeMessage = PluralForm.get(days, timeString)
- .replace("#1", days);
+ timeMessage = PluralForm.getReplaceFromBundle(days, gStrings.ext, timeKey);
}
document.getElementById("detail-experiment-time").value = timeMessage;
}
this.fillSettingsRows(aScrollToPreferences, () => {
this.updateState();
gViewController.notifyViewChanged();
--- a/toolkit/mozapps/extensions/content/extensions.xml
+++ b/toolkit/mozapps/extensions/content/extensions.xml
@@ -1446,18 +1446,17 @@
if (days < 1) {
timeKey += (active ? "endsToday" : "endedToday");
timeMessage = gStrings.ext.GetStringFromName(timeKey);
} else {
timeKey += (active ? "daysRemaining" : "daysPassed");
days = Math.round(days);
let timeString = gStrings.ext.GetStringFromName(timeKey);
- timeMessage = PluralForm.get(days, timeString)
- .replace("#1", days);
+ timeMessage = PluralForm.getReplace(days, timeString);
}
this._experimentTime.value = timeMessage;
}
}
]]></body>
</method>