diff --git a/browser/devtools/commandline/gcli.jsm b/browser/devtools/commandline/gcli.jsm index 405341f86043..219bcd8ff6b1 100644 --- a/browser/devtools/commandline/gcli.jsm +++ b/browser/devtools/commandline/gcli.jsm @@ -7920,9 +7920,39 @@ help.shutdown = function() { * Create a block of data suitable to be passed to the help_list.html template */ function getListTemplateData(args, context) { + var matchingCommands = canon.getCommands().filter(function(command) { + if (command.hidden) { + return false; + } + + if (args.search && command.name.indexOf(args.search) !== 0) { + // Filtered out because they don't match the search + return false; + } + if (!args.search && command.name.indexOf(' ') != -1) { + // We don't show sub commands with plain 'help' + return false; + } + return true; + }); + matchingCommands.sort(); + + var heading; + if (matchingCommands.length === 0) { + heading = l10n.lookupFormat('helpListNone', [ args.search ]); + } + else if (args.search == null) { + heading = l10n.lookup('helpListAll'); + } + else { + heading = l10n.lookupFormat('helpListPrefix', [ args.search ]); + } + return { l10n: l10n.propertyLookup, includeIntro: args.search == null, + matchingCommands: matchingCommands, + heading: heading, onclick: function(ev) { util.updateCommand(ev.currentTarget, context); @@ -7931,32 +7961,6 @@ function getListTemplateData(args, context) { ondblclick: function(ev) { util.executeCommand(ev.currentTarget, context); }, - - getHeading: function() { - return args.search == null ? - 'Available Commands:' : - 'Commands starting with \'' + args.search + '\':'; - }, - - getMatchingCommands: function() { - var matching = canon.getCommands().filter(function(command) { - if (command.hidden) { - return false; - } - - if (args.search && command.name.indexOf(args.search) !== 0) { - // Filtered out because they don't match the search - return false; - } - if (!args.search && command.name.indexOf(' ') != -1) { - // We don't show sub commands with plain 'help' - return false; - } - return true; - }); - matching.sort(); - return matching; - } }; } @@ -7986,10 +7990,10 @@ function getManTemplateData(command, context) { getTypeDescription: function(param) { var input = ''; if (param.defaultValue === undefined) { - input = 'required'; + input = l10n.lookup('helpManRequired'); } else if (param.defaultValue === null) { - input = 'optional'; + input = l10n.lookup('helpManOptional'); } else { input = param.defaultValue; @@ -8066,10 +8070,10 @@ define("text!gcli/commands/help_man.html", [], "\n" + define("text!gcli/commands/help_list.html", [], "\n" + "
\n" + - "

${getHeading()}

\n" + + "

${heading}

\n" + "\n" + " \n" + - " \n" + " \n" + " \n" + diff --git a/browser/devtools/commandline/test/browser_gcli_web.js b/browser/devtools/commandline/test/browser_gcli_web.js index e2ce21d82d65..e3b2b5709cfc 100644 --- a/browser/devtools/commandline/test/browser_gcli_web.js +++ b/browser/devtools/commandline/test/browser_gcli_web.js @@ -2015,7 +2015,7 @@ define('gclitest/testHelp', ['require', 'exports', 'module' , 'gclitest/helpers' helpers.exec(options, { typed: 'help nomatch', args: { search: 'nomatch' }, - outputMatch: /Commands starting with 'nomatch':$/ + outputMatch: /No commands starting with 'nomatch'$/ }); helpers.exec(options, { @@ -2031,7 +2031,7 @@ define('gclitest/testHelp', ['require', 'exports', 'module' , 'gclitest/helpers' helpers.exec(options, { typed: 'help a b', args: { search: 'a b' }, - outputMatch: /Commands starting with 'a b':$/ + outputMatch: /No commands starting with 'a b'$/ }); helpers.exec(options, { diff --git a/browser/locales/en-US/chrome/browser/devtools/gcli.properties b/browser/locales/en-US/chrome/browser/devtools/gcli.properties index 456c960329c2..d9b1a3569340 100644 --- a/browser/locales/en-US/chrome/browser/devtools/gcli.properties +++ b/browser/locales/en-US/chrome/browser/devtools/gcli.properties @@ -137,6 +137,28 @@ helpManParameters=Parameters # heading in a help page for a command which has no parameters. helpManNone=None +# LOCALIZATION NOTE (helpListAll): The heading shown in response to the 'help' +# command when used without a filter, just above the list of known commands. +helpListAll=Available Commands: + +# LOCALIZATION NOTE (helpListPrefix): The heading shown in response to the +# 'help ' command (i.e. with a search string), just above the list of +# matching commands. +helpListPrefix=Commands starting with '%1$S': + +# LOCALIZATION NOTE (helpListNone): The heading shown in response to the 'help +# ' command (i.e. with a search string), when there are no matching +# commands. +helpListNone=No commands starting with '%1$S' + +# LOCALIZATION NOTE (helpManRequired): When the 'help x' command wants to show +# the manual for the 'x' command it needs to be able to describe the +# parameters as either required or optional. See also 'helpManOptional'. +helpManRequired=required + +# LOCALIZATION NOTE (helpManOptional): See description of 'helpManRequired' +helpManOptional=optional + # LOCALIZATION NOTE (subCommands): Text shown as part of the output of the # 'help' command when the command in question has sub-commands, before a list # of the matching sub-commands
${command.name}-