From 8d4199e39ac6a05b84c005c8da73ebdd7e176439 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Fri, 25 Jan 2013 18:14:53 +0200 Subject: [PATCH] Bug 834721 - Use plurals for toolbox button tooltip; r=paul --- browser/devtools/shared/DeveloperToolbar.jsm | 17 ++++++++++++++++- .../browser_toolbar_webconsole_errors_count.js | 2 +- .../chrome/browser/devtools/toolbox.properties | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/browser/devtools/shared/DeveloperToolbar.jsm b/browser/devtools/shared/DeveloperToolbar.jsm index 13a9ee67acf1..a98033ce31e2 100644 --- a/browser/devtools/shared/DeveloperToolbar.jsm +++ b/browser/devtools/shared/DeveloperToolbar.jsm @@ -27,6 +27,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "CmdCommands", XPCOMUtils.defineLazyModuleGetter(this, "PageErrorListener", "resource://gre/modules/devtools/WebConsoleUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", + "resource://gre/modules/PluralForm.jsm"); + XPCOMUtils.defineLazyGetter(this, "prefBranch", function() { let prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); @@ -622,7 +625,19 @@ function DT__updateErrorsCount(aChangedTabId) let warnings = this._warningsCount[tabId]; let btn = this._errorCounterButton; if (errors) { - let tooltiptext = toolboxStrings.formatStringFromName("toolboxDockButtons.errorsCount.tooltip", [errors, warnings], 2); + let errorsText = toolboxStrings + .GetStringFromName("toolboxToggleButton.errorsCount"); + errorsText = PluralForm.get(errors, errorsText); + + let warningsText = toolboxStrings + .GetStringFromName("toolboxToggleButton.warningsCount"); + warningsText = PluralForm.get(warnings, warningsText); + + let tooltiptext = toolboxStrings + .formatStringFromName("toolboxToggleButton.tooltiptext", + [errors, errorsText, warnings, + warningsText], 4); + btn.setAttribute("error-count", errors); btn.setAttribute("tooltiptext", tooltiptext); } else { diff --git a/browser/devtools/shared/test/browser_toolbar_webconsole_errors_count.js b/browser/devtools/shared/test/browser_toolbar_webconsole_errors_count.js index b3d6b291568f..85d8d825a9f8 100644 --- a/browser/devtools/shared/test/browser_toolbar_webconsole_errors_count.js +++ b/browser/devtools/shared/test/browser_toolbar_webconsole_errors_count.js @@ -44,7 +44,7 @@ function test() { function getTooltipValues() { let matches = webconsole.getAttribute("tooltiptext") - .match(/(\d+) errors, (\d+) warnings/); + .match(/(\d+) errors?, (\d+) warnings?/); return matches ? [matches[1], matches[2]] : [0, 0]; } diff --git a/browser/locales/en-US/chrome/browser/devtools/toolbox.properties b/browser/locales/en-US/chrome/browser/devtools/toolbox.properties index f5c08f442a24..01264cad4d9d 100644 --- a/browser/locales/en-US/chrome/browser/devtools/toolbox.properties +++ b/browser/locales/en-US/chrome/browser/devtools/toolbox.properties @@ -1,4 +1,10 @@ toolboxDockButtons.bottom.tooltip=Dock to bottom of browser window toolboxDockButtons.side.tooltip=Dock to side of browser window toolboxDockButtons.window.tooltip=Show in separate window -toolboxDockButtons.errorsCount.tooltip=%S errors, %S warnings.\nClick to toggle developer tools. \ No newline at end of file + +# LOCALIZATION NOTE (toolboxToggleButton): These strings are used for the button +# that allows users to open/close the developer tools. You can find this button +# on the developer toolbar. +toolboxToggleButton.errorsCount=error;errors +toolboxToggleButton.warningsCount=warning;warnings +toolboxToggleButton.tooltiptext=%S %S, %S %S.\nClick to toggle the developer tools.