From 11623d4f8b6bdba6263bcd628eb380ffb6b01062 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 10 Mar 2011 22:06:29 +1100 Subject: [PATCH] Move some more message strings to the properties file. --- common/content/mappings.js | 2 +- common/content/modes.js | 2 +- common/locale/en-US/messages.properties | 17 +++++++++++++++++ common/modules/addons.jsm | 4 ++-- common/modules/downloads.jsm | 4 ++-- common/modules/io.jsm | 4 ++-- common/modules/options.jsm | 8 ++++---- common/modules/sanitizer.jsm | 4 ++-- common/modules/styles.jsm | 4 ++-- common/modules/util.jsm | 4 ++-- 10 files changed, 35 insertions(+), 18 deletions(-) diff --git a/common/content/mappings.js b/common/content/mappings.js index 668d8ce1..f78d6f59 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -119,7 +119,7 @@ var Map = Class("Map", { mappings.repeat = repeat; if (this.executing) - util.dumpStack("Attempt to execute mapping recursively: " + args.command); + util.dumpStack(_("map.recursive", args.command)); dactyl.assert(!this.executing, _("map.recursive", args.command)); try { diff --git a/common/content/modes.js b/common/content/modes.js index 55fa19fe..fd3d46bb 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -428,7 +428,7 @@ var Modes = Module("modes", { init: function init(name, options, params) { if (options.bases) util.assert(options.bases.every(function (m) m instanceof this, this.constructor), - "Invalid bases", true); + _("mode.invalidBases"), true); update(this, { id: 1 << Modes.Mode._id++, diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties index 662286b6..bd51a22b 100644 --- a/common/locale/en-US/messages.properties +++ b/common/locale/en-US/messages.properties @@ -7,6 +7,8 @@ abbrev.none = No abbreviations found addon.check-1 = Checking updates for addons: %S addon.cantInstallDir-1 = Cannot install a directory: %S addon.unavailable = Don't have add-on yet +addon.uknownCommand = Unknown command +addon.commandNotAllowed = Command not allowed autocmd.executing-2 = Executing %S Auto commands for %S autocmd.autocommand-1 = autocommand %S @@ -62,6 +64,13 @@ command.let.unexpectedChar = E18: Unexpected characters in :let command.let.illegalVar-1 = E461: Illegal variable name: %S command.let.undefinedVar-1 = E121: Undefined variable: %S command.let.invalidExpression-1 = E15: Invalid expression: %S +command.run.noPrevious = E34: No previous command +command.sanitize.privateMode = Cannot sanitize items in private mode +command.set.numberRequired-2 = E521: Number required after =: %S=%S +command.set.errorParsing-1 = Error parsing :set command: %S +command.set.unknownOption-1 = E518: Unknown option: %S +# TODO: use generic builtin message? +command.style.cantChangeBuiltin = Cannot modify styles in the builtin group dactyl.parsingCommandLine-1 = Parsing command line options: %S dactyl.notCommand-2 = E492: Not a %S command: %S @@ -74,6 +83,10 @@ dactyl.initialized-1 = %S fully initialized dialog.notAvailable-1 = Dialog %S not available +# TODO: merge with addon.*? +download.uknownCommand = Unknown command +download.commandNotAllowed = Command not allowed + group.cantChangeBuiltin-1 = Cannot change %S in the builtin group group.cantModifyBuiltin = Cannot modify builtin group group.cantRemoveBuiltin = Cannot remove builtin group @@ -138,6 +151,7 @@ mark.unset-1 = Mark not set: %S mark.noMatching-1 = E283: No marks matching %S mode.recursiveSet = Not executing modes.set recursively +mode.invalidBases = Invalid bases mow.noPreviousOutput = No previous command output @@ -192,6 +206,9 @@ error.argumentOrBang = Argument or ! required error.invalidOperation = Invalid operation error.monkeyPatchOverlay-1 = Not replacing property with eval-generated overlay by %S error.nullComputedStyle-1 = Computed style is null: %S +error.syntaxError = Syntax error +error.charsOutsideRange-1 = Character list outside the range %S +error.invalidCharRange = Invalid character range: %S warn.notDefaultBranch-2 = You are running %S from a testing branch: %S. Please do not report errors which do not also occur in the default branch. diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index 03c4e0fb..f460948f 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -165,7 +165,7 @@ var Addon = Class("Addon", { }, commandAllowed: function commandAllowed(cmd) { - util.assert(set.has(actions, cmd), "Unknown command"); + util.assert(set.has(actions, cmd), _("addon.unknownCommand")); let action = actions[cmd]; if ("perm" in action && !(this.permissions & AddonManager["PERM_CAN_" + action.perm.toUpperCase()])) @@ -176,7 +176,7 @@ var Addon = Class("Addon", { }, command: function command(cmd) { - util.assert(this.commandAllowed(cmd), "Command not allowed"); + util.assert(this.commandAllowed(cmd), _("addon.commandNotAllowed")); let action = actions[cmd]; if (action.action) diff --git a/common/modules/downloads.jsm b/common/modules/downloads.jsm index 403c1e41..3a829aa0 100644 --- a/common/modules/downloads.jsm +++ b/common/modules/downloads.jsm @@ -78,8 +78,8 @@ var Download = Class("Download", { })), command: function command(name) { - util.assert(set.has(this.allowedCommands, name), "Unknown command"); - util.assert(this.allowedCommands[name], "Command not allowed"); + util.assert(set.has(this.allowedCommands, name), _("download.unknownCommand")); + util.assert(this.allowedCommands[name], _("download.commandNotAllowed")); services.downloadManager[name + "Download"](this.id); }, diff --git a/common/modules/io.jsm b/common/modules/io.jsm index a6487a99..ce55a0bd 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -639,7 +639,7 @@ var IO = Module("io", { if (file.exists() && file.isDirectory() || args[0] && /\/$/.test(args[0])) file.append(config.name + ".vim"); - dactyl.assert(!file.exists() || args.bang, "File exists"); + dactyl.assert(!file.exists() || args.bang, _("io.exists")); let template = util.compileMacro( count) return prev = parse.call(this, filter, val); else { - util.assert(prev, "Syntax error", false); + util.assert(prev, _("error.syntaxError"), false); prev.result += "," + v; } }, this)) @@ -592,7 +592,7 @@ var Option = Class("Option", { let value = parseInt(values); util.assert(Number(values) % 1 == 0, - "E521: Number required after =: " + this.name + "=" + values); + _("command.set.numberRequired", this.name, values)); switch (operator) { case "+": @@ -1044,10 +1044,10 @@ var Options = Module("options", { } let opt = modules.options.parseOpt(arg, modifiers); - util.assert(opt, "Error parsing :set command: " + arg); + util.assert(opt, _("command.set.errorParsing", arg)); let option = opt.option; - util.assert(option != null || opt.all, "E518: Unknown option: " + opt.name); + util.assert(option != null || opt.all, _("command.set.unknownOption", opt.name)); // reset a variable to its default value if (opt.reset) { diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index c7f3ac9e..6f6fb0ce 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -399,7 +399,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef commands.add(["sa[nitize]"], "Clear private data", function (args) { - dactyl.assert(!modules.options['private'], "Cannot sanitize items in private mode"); + dactyl.assert(!modules.options['private'], _("command.sanitize.privateMode")); let timespan = args["-timespan"] || modules.options["sanitizetimespan"]; @@ -419,7 +419,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef function (k) modules.options.get("sanitizeitems").has(k)); } else - dactyl.assert(modules.options.get("sanitizeitems").validator(items), "Valid items required"); + dactyl.assert(modules.options.get("sanitizeitems").validator(items), _("error.invalidArgument")); if (items.indexOf("all") >= 0) items = Object.keys(sanitizer.itemMap).filter(function (k) items.indexOf(k) === -1); diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index adfc725c..d143cf34 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -556,7 +556,7 @@ var Styles = Module("Styles", { styles.list(window.content, filter, args["-name"], args.explicitOpts["-group"] ? [args["-group"]] : null); else { util.assert(args["-group"].modifiable && args["-group"].hive.modifiable, - "Cannot modify styles in the builtin group"); + _("command.style.cantChangeBuiltin")); if (args["-append"]) { let sheet = args["-group"].get(args["-name"]); @@ -642,7 +642,7 @@ var Styles = Module("Styles", { commands.add(cmd.name, cmd.desc, function (args) { dactyl.assert(args.bang ^ !!(args[0] || args[1] || args["-name"] || args["-index"]), - "Argument or ! required"); + _("error.argumentOrBang")); args["-group"].find(args["-name"], args[0], args.literalArg, args["-index"]) .forEach(cmd.action); diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 673366a0..6a1a8ea6 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -181,12 +181,12 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), // check for chars not in the accepted range this.assert(RegExp("^[" + accepted + "-]+$").test(list), - "Character list outside the range " + accepted.quote()); + _("error.charsOutsideRange", accepted.quote())); // check for illegal ranges for (let [match] in this.regexp.iterate(/.-./g, list)) this.assert(match.charCodeAt(0) <= match.charCodeAt(2), - "Invalid character range: " + list.slice(list.indexOf(match))) + _("error.invalidCharRange", list.slice(list.indexOf(match)))); return RegExp("[" + util.regexp.escape(list) + "]"); },