Bug 834721 - Use plurals for toolbox button tooltip; r=paul

This commit is contained in:
Mihai Sucan 2013-01-25 18:14:53 +02:00
parent 3f10682513
commit 639c0b690a
3 changed files with 24 additions and 3 deletions

View File

@ -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 {

View File

@ -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];
}

View File

@ -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.
# 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.