Bug 1468440 - Update close, unblock audio and mute/unmute button tooltips for multi-selected tabs. r=mconley,flod
authorJared Wein <jwein@mozilla.com>
Wed, 29 Aug 2018 18:44:35 +0000
changeset 491681 c21566b512f1a7339bb3d0e286865dadc5e25ace
parent 491680 141d116489a7de2cd69ca7bd5eb494d1a1dfafbc
child 491682 bda9e323c7fb9731fd39373f3dcd586530ead2a7
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, flod
bugs1468440
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1468440 - Update close, unblock audio and mute/unmute button tooltips for multi-selected tabs. r=mconley,flod Differential Revision: https://phabricator.services.mozilla.com/D4390
browser/base/content/tabbrowser.js
browser/locales/en-US/chrome/browser/tabbrowser.properties
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -4090,44 +4090,51 @@ window._gBrowser = {
   createTooltip(event) {
     event.stopPropagation();
     var tab = document.tooltipNode;
     if (tab.localName != "tab") {
       event.preventDefault();
       return;
     }
 
-    let stringWithShortcut = (stringId, keyElemId) => {
+    let stringWithShortcut = (stringId, keyElemId, pluralCount) => {
       let keyElem = document.getElementById(keyElemId);
       let shortcut = ShortcutUtils.prettifyShortcut(keyElem);
-      return gTabBrowserBundle.formatStringFromName(stringId, [shortcut], 1);
+      return PluralForm.get(pluralCount, gTabBrowserBundle.GetStringFromName(stringId))
+                       .replace("%S", shortcut)
+                       .replace("#1", pluralCount);
     };
 
-    var label;
+    let label;
+    const selectedTabs = this.selectedTabs;
+    const contextTabInSelection = selectedTabs.includes(tab);
+    const affectedTabsLength = contextTabInSelection ? selectedTabs.length : 1;
     if (tab.mOverCloseButton) {
       label = tab.selected ?
-        stringWithShortcut("tabs.closeSelectedTab.tooltip", "key_close") :
-        gTabBrowserBundle.GetStringFromName("tabs.closeTab.tooltip");
+        stringWithShortcut("tabs.closeSelectedTabs.tooltip", "key_close", affectedTabsLength) :
+        PluralForm.get(affectedTabsLength, gTabBrowserBundle.GetStringFromName("tabs.closeTabs.tooltip"))
+                  .replace("#1", affectedTabsLength);
     } else if (tab._overPlayingIcon) {
       let stringID;
       if (tab.selected) {
         stringID = tab.linkedBrowser.audioMuted ?
-          "tabs.unmuteAudio.tooltip" :
-          "tabs.muteAudio.tooltip";
-        label = stringWithShortcut(stringID, "key_toggleMute");
+          "tabs.unmuteAudio2.tooltip" :
+          "tabs.muteAudio2.tooltip";
+        label = stringWithShortcut(stringID, "key_toggleMute", affectedTabsLength);
       } else {
         if (tab.hasAttribute("activemedia-blocked")) {
-          stringID = "tabs.unblockAudio.tooltip";
+          stringID = "tabs.unblockAudio2.tooltip";
         } else {
           stringID = tab.linkedBrowser.audioMuted ?
-            "tabs.unmuteAudio.background.tooltip" :
-            "tabs.muteAudio.background.tooltip";
+            "tabs.unmuteAudio2.background.tooltip" :
+            "tabs.muteAudio2.background.tooltip";
         }
 
-        label = gTabBrowserBundle.GetStringFromName(stringID);
+        label = PluralForm.get(affectedTabsLength, gTabBrowserBundle.GetStringFromName(stringID))
+                          .replace("#1", affectedTabsLength);
       }
     } else {
       label = tab._fullLabel || tab.getAttribute("label");
       if (AppConstants.NIGHTLY_BUILD &&
           tab.linkedBrowser &&
           tab.linkedBrowser.isRemoteBrowser &&
           tab.linkedBrowser.frameLoader) {
         label += " (pid " + tab.linkedBrowser.frameLoader.tabParent.osPid + ")";
--- a/browser/locales/en-US/chrome/browser/tabbrowser.properties
+++ b/browser/locales/en-US/chrome/browser/tabbrowser.properties
@@ -29,30 +29,67 @@ tabs.closeWarningMultipleWindows=;You ar
 # LOCALIZATION NOTE (tabs.closeWarningMultipleWindowsTabSnippet):
 # Semicolon-separated list of plural forms. See:
 # http://developer.mozilla.org/en/docs/Localization_and_Plurals
 # The singular form is not considered since this string is used only for
 # multiple windows which must contain multiple tabs (in total).
 # This string will be inserted in tabs.closeWarningMultipleWindows
 tabs.closeWarningMultipleWindowsTabSnippet=;with #1 tabs
 
-tabs.closeTab.tooltip=Close tab
-# LOCALIZATION NOTE (tabs.closeSelectedTab.tooltip):
-# %S is the keyboard shortcut for closing the current tab
-tabs.closeSelectedTab.tooltip=Close tab (%S)
-# LOCALIZATION NOTE (tabs.muteAudio.tooltip):
-# %S is the keyboard shortcut for "Mute tab"
-tabs.muteAudio.tooltip=Mute tab (%S)
-# LOCALIZATION NOTE (tabs.unmuteAudio.tooltip):
-# %S is the keyboard shortcut for "Unmute tab"
-tabs.unmuteAudio.tooltip=Unmute tab (%S)
-tabs.muteAudio.background.tooltip=Mute tab
-tabs.unmuteAudio.background.tooltip=Unmute tab
+# LOCALIZATION NOTE (tabs.closeTabs.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# #1 is the number of tabs that will be closed. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.closeTabs.tooltip=Close tab;Close #1 tabs
+
+# LOCALIZATION NOTE (tabs.closeSelectedTabs.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# %S is the keyboard shortcut for closing the current tab.
+# #1 is the number of tabs that will be closed. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.closeSelectedTabs.tooltip=Close tab (%S);Close #1 tabs (%S)
+
+# LOCALIZATION NOTE (tabs.muteAudio2.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# %S is the keyboard shortcut for "Mute tab".
+# #1 is the number of tabs that will be muted. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.muteAudio2.tooltip=Mute tab (%S);Mute #1 tabs (%S)
 
-tabs.unblockAudio.tooltip=Play tab
+# LOCALIZATION NOTE (tabs.unmuteAudio2.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# %S is the keyboard shortcut for "Unmute tab".
+# #1 is the number of tabs that will be unmuted. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.unmuteAudio2.tooltip=Unmute tab (%S);Unmute #1 tabs (%S)
+
+# LOCALIZATION NOTE (tabs.muteAudio2.background.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# #1 is the number of tabs that will be muted. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.muteAudio2.background.tooltip=Mute tab;Mute #1 tabs
+
+# LOCALIZATION NOTE (tabs.unmuteAudio2.background.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# #1 is the number of tabs that will be unmuted. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.unmuteAudio2.background.tooltip=Unmute tab;Unmute #1 tabs
+
+# LOCALIZATION NOTE (tabs.unblockAudio2.tooltip):
+# Semicolon-separated list of plural forms. See:
+# http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# #1 is the number of tabs that will have their audio unblocked. This is ignored for the
+# single tab case in English, but can be used by other locales as necessary.
+tabs.unblockAudio2.tooltip=Play tab;Play #1 tabs
 
 # LOCALIZATION NOTE (tabs.allowTabFocusByPromptForSite):
 # %S is the hostname of the site where dialogs are allowed to switch tabs
 tabs.allowTabFocusByPromptForSite=Allow dialogs from %S to take you to their tab
 
 # LOCALIZATION NOTE (tabs.containers.tooltip):
 # Displayed as a tooltip on container tabs
 # %1$S is the title of the current tab