Bug 661055 - Display number of windows and tabs to be restored from previous session. r?mikedeboer
This replaces the labels on the Restore Previous Session menu items on the
appMenu and History menu with a label including the count of windows and tabs
that will be restored.
MozReview-Commit-ID: 6vLKEmt55Uv
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -8438,16 +8438,31 @@ var RestoreLastSessionObserver = {
gBrowser.tabContainer.updateSessionRestoreVisibility();
restoreTabsButton.style.maxWidth = `${restoreTabsButtonWrapperWidth}px`;
gBrowser.tabContainer.addEventListener("TabOpen", this);
Services.telemetry.scalarSet("browser.session.restore.tabbar_restore_available", true);
restoreTabsButton.addEventListener("click", () => {
Services.telemetry.scalarSet("browser.session.restore.tabbar_restore_clicked", true);
});
}
+ let { windows, tabs } = SessionStore.restorableObjectsCount;
+ let winsBase = gNavigatorBundle.getString("menuRestoreLastSessionWindowCount");
+ let tabsBase = gNavigatorBundle.getString("menuRestoreLastSessionTabsCount");
+ let ending;
+ if (windows > 1) {
+ let labelVars = [PluralForm.get(windows, winsBase).replace("#1", windows),
+ PluralForm.get(tabs, tabsBase).replace("#1", tabs)];
+ ending = gNavigatorBundle.getFormattedString("menuRestoreLastSessionCount",
+ labelVars);
+ } else {
+ ending = PluralForm.get(tabs, tabsBase).replace("#1", tabs);
+ }
+ let label = gNavigatorBundle.getFormattedString("menuRestoreLastSessionLabel", [ending]);
+ document.getElementById("Browser:RestoreLastSession").setAttribute("label", label);
+
Services.obs.addObserver(this, "sessionstore-last-session-cleared", true);
goSetCommandEnabled("Browser:RestoreLastSession", true);
} else if (SessionStartup.isAutomaticRestoreEnabled()) {
document.getElementById("Browser:RestoreLastSession").setAttribute("hidden", true);
}
},
handleEvent(event) {
@@ -8471,16 +8486,20 @@ var RestoreLastSessionObserver = {
restoreTabsButton.style.maxWidth = 0;
gBrowser.tabContainer.removeEventListener("TabOpen", this);
},
observe() {
// The last session can only be restored once so there's
// no way we need to re-enable our menu item.
Services.obs.removeObserver(this, "sessionstore-last-session-cleared");
+ document.getElementById("Browser:RestoreLastSession").setAttribute(
+ "label",
+ gNavigatorBundle.getFormattedString("menuRestoreLastSessionLabel", [""])
+ );
goSetCommandEnabled("Browser:RestoreLastSession", false);
this.removeRestoreButton();
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference])
};
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -423,16 +423,29 @@ menuRestoreAllWindows.label=Restore All
# LOCALIZATION NOTE (menuRestoreAllWindowsSubview.label): like menuRestoreAllWindows.label,
# but used in the history subview in the panel UI, so needs to mention these are *closed* windows.
menuRestoreAllWindowsSubview.label=Restore Closed Windows
# LOCALIZATION NOTE (menuUndoCloseWindowLabel): Semicolon-separated list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 Window Title, #2 Number of tabs
menuUndoCloseWindowLabel=#1 (and #2 other tab);#1 (and #2 other tabs)
menuUndoCloseWindowSingleTabLabel=#1
+# LOCALIZATION NOTE (menuRestoreLastSessionLabel): Replaces historyRestoreLastSession.label
+# from browser.dtd with counts
+# %S is menuRestoreLastSessionCount, or menuRestoreLastSessionTabsCount if 1 window
+menuRestoreLastSessionLabel=Restore Previous Session %S
+# LOCALIZATION NOTE (menuRestoreLastSessionCount): %1$S is
+# menuRestoreLastSessionWindowCount, %2$S is menuRestoreLastSessionTabCount
+menuRestoreLastSessionCount=%1$S / %2$S
+# LOCALIZATION NOTE (menuRestoreLastSessionWindowsCount): Semicolon-separated list of plural forms.
+# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
+menuRestoreLastSessionWindowCount=#1 window;#1 windows
+# LOCALIZATION NOTE (menuRestoreLastSessionTabsCount): Semicolon-separated list of plural forms.
+# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
+menuRestoreLastSessionTabsCount=#1 tab;#1 tabs
# Unified Back-/Forward Popup
tabHistory.current=Stay on this page
tabHistory.goBack=Go back to this page
tabHistory.goForward=Go forward to this page
# URL Bar
pasteAndGo.label=Paste & Go