Bug 761268 - GCLI has hard-coded strings; r=dcamp
authorJoe Walker <jwalker@mozilla.com>
Tue, 12 Jun 2012 11:57:26 +0100
changeset 96558 0acca26e3763fd118c93ab7809583f2636e80515
parent 96557 c823ffa89a339c64a3cd219d3399e81219219200
child 96559 cfe3d2e340405e3f8ac719126454a1d272717239
push id22912
push usertim.taubert@gmx.de
push dateWed, 13 Jun 2012 13:37:46 +0000
treeherdermozilla-central@bdbed29aaaa6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdcamp
bugs761268
milestone16.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 761268 - GCLI has hard-coded strings; r=dcamp
browser/devtools/commandline/gcli.jsm
browser/devtools/commandline/test/browser_gcli_web.js
browser/locales/en-US/chrome/browser/devtools/gcli.properties
--- a/browser/devtools/commandline/gcli.jsm
+++ b/browser/devtools/commandline/gcli.jsm
@@ -7915,53 +7915,57 @@ help.startup = function() {
 help.shutdown = function() {
   canon.removeCommand(helpCommandSpec);
 };
 
 /**
  * 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);
     },
 
     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;
-    }
   };
 }
 
 /**
  * Create a block of data suitable to be passed to the help_man.html template
  */
 function getManTemplateData(command, context) {
   var manTemplateData = {
@@ -7981,20 +7985,20 @@ function getManTemplateData(command, con
       var parent = element.ownerDocument.createElement('div');
       util.setContents(parent, text);
       return parent.childNodes;
     },
 
     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;
       }
       return '(' + param.type.name + ', ' + input + ')';
     }
   };
 
@@ -8061,20 +8065,20 @@ define("text!gcli/commands/help_man.html
   "    </ul>\n" +
   "  </div>\n" +
   "\n" +
   "</div>\n" +
   "");
 
 define("text!gcli/commands/help_list.html", [], "\n" +
   "<div>\n" +
-  "  <h3>${getHeading()}</h3>\n" +
+  "  <h3>${heading}</h3>\n" +
   "\n" +
   "  <table>\n" +
-  "    <tr foreach=\"command in ${getMatchingCommands()}\"\n" +
+  "    <tr foreach=\"command in ${matchingCommands}\"\n" +
   "        onclick=\"${onclick}\" ondblclick=\"${ondblclick}\">\n" +
   "      <th class=\"gcli-help-name\">${command.name}</th>\n" +
   "      <td class=\"gcli-help-arrow\">-</td>\n" +
   "      <td>\n" +
   "        ${command.description}\n" +
   "        <span class=\"gcli-out-shortcut\" data-command=\"help ${command.name}\">help ${command.name}</span>\n" +
   "      </td>\n" +
   "    </tr>\n" +
--- a/browser/devtools/commandline/test/browser_gcli_web.js
+++ b/browser/devtools/commandline/test/browser_gcli_web.js
@@ -2010,33 +2010,33 @@ define('gclitest/testHelp', ['require', 
           /Get help/
         ]
       });
     }
 
     helpers.exec(options, {
       typed: 'help nomatch',
       args: { search: 'nomatch' },
-      outputMatch: /Commands starting with 'nomatch':$/
+      outputMatch: /No commands starting with 'nomatch'$/
     });
 
     helpers.exec(options, {
       typed: 'help help',
       args: { search: 'help' },
       outputMatch: [
         /Synopsis:/,
         /Provide help either/,
         /\(string, optional\)/
       ]
     });
 
     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, {
       typed: 'help hel',
       args: { search: 'hel' },
       outputMatch: [
         /Commands starting with 'hel':/,
         /Get help on the available commands/
--- a/browser/locales/en-US/chrome/browser/devtools/gcli.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/gcli.properties
@@ -132,16 +132,38 @@ helpManDescription=Description
 # LOCALIZATION NOTE (helpManParameters): A heading shown above the parameters
 # in a help page for a command in the console.
 helpManParameters=Parameters
 
 # LOCALIZATION NOTE (helpManNone): Some text shown under the 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 <search>' 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
+# <search>' 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
 subCommands=Sub-Commands
 
 # LOCALIZATION NOTE (subCommandsNone): Text shown as part of the output of the
 # 'help' command when the command in question should have sub-commands but in
 # fact has none