diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-03-02 02:59:04 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-03-02 02:59:04 -0500 |
commit | e032a82d621c49ae2b733818165508392d27669c (patch) | |
tree | eed258d3016972128be26846404ac9e18c2ce4b1 /common | |
parent | 28d1c1bcade5d1cff91bafc32f5b9a28b32a3fcd (diff) | |
download | pentadactyl-e032a82d621c49ae2b733818165508392d27669c.tar.gz |
Move some more strings to messages.properties and report (but don't throw) an error for unknown strings.
Diffstat (limited to 'common')
-rw-r--r-- | common/content/events.js | 10 | ||||
-rw-r--r-- | common/locale/en-US/messages.properties | 121 | ||||
-rw-r--r-- | common/modules/addons.jsm | 16 | ||||
-rw-r--r-- | common/modules/commands.jsm | 43 | ||||
-rw-r--r-- | common/modules/contexts.jsm | 20 | ||||
-rw-r--r-- | common/modules/highlight.jsm | 8 | ||||
-rw-r--r-- | common/modules/io.jsm | 8 | ||||
-rw-r--r-- | common/modules/messages.jsm | 24 | ||||
-rw-r--r-- | common/modules/template.jsm | 2 |
9 files changed, 148 insertions, 104 deletions
diff --git a/common/content/events.js b/common/content/events.js index a7feeafa..ef7a742a 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -302,10 +302,12 @@ var EventHive = Class("EventHive", Contexts.Hive, { * phase, otherwise during the bubbling phase. */ listen: function (target, event, callback, capture, allowUntrusted) { - if (isObject(event)) - var [self, events] = [event, event[callback || "events"]]; - else - [self, events] = [null, array.toObject([[event, callback]])]; + if (!isObject(event)) + var [self, events] = [null, array.toObject([[event, callback]])]; + else { + [self, events] = [event, event[callback || "events"]]; + [,, capture, allowUntrusted] = arguments; + } for (let [event, callback] in Iterator(events)) { let args = [Cu.getWeakReference(target), diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties index 25a0fb0c..ae36efeb 100644 --- a/common/locale/en-US/messages.properties +++ b/common/locale/en-US/messages.properties @@ -1,107 +1,142 @@ abbrev.noSuch = No such abbreviation abbrev.none = No abbreviations found -autocmd.executing- = Executing %S Auto commands for %S -autocmd.autocommand- = autocommand %S +autocmd.executing-2 = Executing %S Auto commands for %S +autocmd.autocommand-1 = autocommand %S autocmd.noMatching = No matching autocommands -autocmd.noGroup- = No such group or event: %S +autocmd.noGroup-1 = No such group or event: %S autocmd.cantExecuteAll = Can't execute autocommands for ALL events -bookmark.noMatching- = No bookmarks matching tags %S and string %S -bookmark.noMatchingTags- = No bookmarks matching tags %S -bookmark.noMatchingString- = No bookmarks matching string %S +bookmark.noMatching-2 = No bookmarks matching tags %S and string %S +bookmark.noMatchingTags-1 = No bookmarks matching tags %S +bookmark.noMatchingString-1 = No bookmarks matching string %S bookmark.none = No bookmarks set -bookmark.cantAdd- = Could not add bookmark %S +bookmark.cantAdd-1 = Could not add bookmark %S bookmark.allGone = All bookmarks deleted -buffer.fewer- = %S fewer tab%S +buffer.fewer-2 = %S fewer tab%S buffer.cantDetatchLast = Can't detach the last tab -buffer.noMatching- = No matching buffer for %S -buffer.multipleMatching- = More than one match for %S +buffer.noMatching-1 = No matching buffer for %S +buffer.multipleMatching-1 = More than one match for %S buffer.noClosed = No matching closed tab buffer.noAlternate = No alternate page -dactyl.parsingCommandLine = Parsing command line options: %S - -dialog.notAvailable = Dialog %S not available +command.commands = commands + +command.cantDelete = Cannot delete non-user commands +command.cantReplace-1 = E182: Can't replace non-user command: %S +command.wontReplace-1 = Not replacing command: %S +command.eof = Unexpected end of file waiting for %S +command.noSuch = No such command +command.noSuch-1 = No such command: %S +command.noSuchUser-1 = No such user-defined command: %S +command.notUseful-1 = This command is not useful in this version of %S +command.invalidName-1 = "Invalid command name: %S +command.invalidOpt-1 = "Invalid option: %S +command.invalidOptArg-2 = "Invalid argument for option %S: %S +command.invalidOptTypeArg-3 = "Invalid argument for %S option %S: %S +command.parsing-1 = Error parsing arguments: %S + +command.colorscheme.notFound = E185: Cannot find color scheme %S +command.conditional.illegal = Invalid use of conditional +command.finish.illegal = E168: :finish used outside of a sourced file + +dactyl.parsingCommandLine-1 = Parsing command line options: %S + +dialog.notAvailable-1 = Dialog %S not available + +group.cantChangeBuiltin = Cannot change %S in the builtin group +group.cantModifyBuiltin = Cannot modify builtin group +group.cantRemoveBuiltin = Cannot remove builtin group +group.noSuch = No such group: %S +group.invalidName-1 = Invalid group name: %S +group.noCurrent = No current group editor.noEditor = No editor specified -emenu.notFound = Menu not found: %S +emenu.notFound-1 = Menu not found: %S -event.error = Processing %S event: %S +event.error-2 = Processing %S event: %S event.nothingToPass = No events to pass help.dontPanic = E478: Don't panic! -help.noFile = Sorry, help file %S not found -help.noTopic = Sorry, no help for %S +help.noFile-1 = Sorry, help file %S not found +help.noTopic-1 = Sorry, no help for %S -hints.noMatcher = Invalid hintmatching type: %S +hints.noMatcher-1 = Invalid hintmatching type: %S -history.noMatching- = No history matching %S +history.noMatching-1 = No history matching %S history.none = No history set history.noURL = URL not found in history -io.notReadable- = Can't open file %S -io.notWriteable- = %S: Can't open file for writing +io.noSuchDir = E344: Can't find directory %S +io.noPrevDir = E186: No previous directory +io.notReadable-1 = Can't open file %S +io.notWriteable-1 = %S: Can't open file for writing io.exists = File exists (add ! to override) -macro.canceled- = Canceled playback of macro '%S' -macro.recorded- = Recorded macro '%S' -macro.loadFailed- = Page did not load completely in %S seconds. +macro.canceled-1 = Canceled playback of macro '%S' +macro.recorded-1 = Recorded macro '%S' +macro.loadFailed-1 = Page did not load completely in %S seconds. macro.loadWaiting = Waiting for page to load... -macro.noSuch- = Macro '%S' not set +macro.noSuch-1 = Macro '%S' not set macro.noPrevious = No previous macro -macro.invalid- = Invalid macro name: '%S' +macro.invalid-1 = Invalid macro name: '%S' map.builtinImmutable = Cannot change mappings in the builtin group map.none = No mapping found -map.noSuch- = No such mapping: %S -map.recursive = Attempt to execute mapping recursively: %S +map.noSuch-1 = No such mapping: %S +map.recursive-1 = Attempt to execute mapping recursively: %S mark.none = No marks set mark.invalid = Invalid mark -mark.unset- = Mark not set: %S -mark.noMatching = E283: No marks matching %S +mark.unset-1 = Mark not set: %S +mark.noMatching-1 = E283: No marks matching %S mow.noPreviousOutput = No previous command output -plugin.searchingFor = Searching for %S -plugin.searchingForIn = Searching for %S in %S +option.noSuch = No such option +option.noSuch-1 = No such option: %S + +plugin.searchingFor-1 = Searching for %S +plugin.searchingForIn-2 = Searching for %S in %S -print.toFile = Printing to file: %S +print.toFile-1 = Printing to file: %S print.sending = Sending to printer... print.sent = Print job sent. -print.printed = Printed: %S +print.printed-1 = Printed: %S quickmark.none = No QuickMarks set -quickmark.noMatching = No QuickMarks matching %S +quickmark.noMatching-1 = No QuickMarks matching %S quickmark.notSet = QuickMark not set quickmark.invalid = Argument must be an ASCII letter or digit -save.invalidDestination = Invalid destination: %S +save.invalidDestination-1 = Invalid destination: %S -status.link- = Link: %S +status.link-1 = Link: %S time.total = Total time: %S window.cantAttachSame = Can't reattach to the same window -window.noIndex = Window %S does not exist +window.noIndex-1 = Window %S does not exist -zoom.outOfRange = Zoom value out of range (%S - %S%%) +zoom.outOfRange-2 = Zoom value out of range (%S - %S%%) zoom.illegal = Illegal zoom value error.clipboardEmpty = No clipboard data -error.countRequired- = Count required for %S -error.cantOpen- = Error opening %S: %S +error.countRequired-1 = Count required for %S +error.cantOpen-2 = Error opening %S: %S error.interrupted = Interrupted -error.invalidSort- = Invalid sort order: %S +error.invalidSort-1 = Invalid sort order: %S error.argRequired = Argument required error.trailing = Trailing characters +error.invalid-1 = Invalid %S error.invalidArgument = Invalid argument -error.invalidArgument- = Invalid argument: %S +error.invalidArgument-1 = Invalid argument: %S +error.unavailable-2 = Not available on %S %S error.argumentRequired = Argument required error.argumentOrBang = Argument or ! required +error.invalidOperation = Invalid operation # vim:se ft=jproperties tw=0: diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index fec2164d..322d52c3 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -11,7 +11,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("addons", { exports: ["AddonManager", "Addons", "Addon", "addons"], require: ["services"], - use: ["completion", "config", "io", "prefs", "template", "util"] + use: ["completion", "config", "io", "messages", "prefs", "template", "util"] }, this); var callResult = function callResult(method) { @@ -49,7 +49,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, { init.supercall(this, modules); util.assert(!addons.length || addons[0].findUpdates, - "Not available on " + config.host + " " + services.runtime.version); + _("error.unavailible", config.host, services.runtime.version)); this.remaining = addons; this.upgrade = []; @@ -110,7 +110,7 @@ var actions = { name: "extr[ehash]", description: "Reload an extension", action: function (addon) { - util.assert(util.haveGecko("2b"), "This command is not useful in this version of " + config.host); + util.assert(util.haveGecko("2b"), _("error.notUseful", config.host)); util.timeout(function () { addon.userDisabled = true; addon.userDisabled = false; @@ -413,17 +413,17 @@ var Addons = Module("addons", { function (args) { let name = args[0]; if (args.bang && !command.bang) - dactyl.assert(!name, "E488: Trailing characters"); + dactyl.assert(!name, _("error.trailing")); else - dactyl.assert(name, "E471: Argument required"); + dactyl.assert(name, _("error.argumentRequired")); AddonManager.getAddonsByTypes(["extension"], dactyl.wrapCallback(function (list) { if (!args.bang || command.bang) { list = list.filter(function (extension) extension.name == name); if (list.length == 0) - return void dactyl.echoerr("E475: Invalid argument: " + name); + return void dactyl.echoerr(_("error.invalidArgument", name)); if (!list.every(ok)) - return void dactyl.echoerr("Permission denied"); + return void dactyl.echoerr(_("error.invalidOperation")); } if (command.actions) command.actions(list, this.modules); @@ -563,7 +563,7 @@ else }); }, getInstallForURL: function (url, callback, mimetype) { - util.assert(false, "Install by URL not implemented"); + util.assert(false, _("error.unavailable", config.host, services.runtime.version)); }, observers: [], addAddonListener: function (listener) { diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 719cb746..43a3310d 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -12,7 +12,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("commands", { exports: ["ArgType", "Command", "Commands", "CommandOption", "Ex", "commands"], require: ["contexts", "util"], - use: ["config", "options", "services", "template"] + use: ["config", "messages", "options", "services", "template"] }, this); let base = util.regexp.escape(Components.stack.filename.replace(/[^\/]+$/, "")); @@ -305,11 +305,11 @@ var Command = Class("Command", { if (this.command.argCount) { util.assert((this.length > 0 || !/^[1+]$/.test(this.command.argCount)) && (this.literal == null || !/[1+]/.test(this.command.argCount) || /\S/.test(this.literalArg || "")), - "E471: Argument required"); + _("error.argumentRequired")); util.assert((this.length == 0 || this.command.argCount !== "0") && (this.length <= 1 || !/^[01?]$/.test(this.command.argCount)), - "E488: Trailing characters"); + _("error.trailing")); } } }); @@ -396,7 +396,7 @@ var Ex = Module("Ex", { let opt = cmd.optionMap["-" + k]; let val = opt.type && opt.type.parse(v); util.assert(val != null && (typeof val !== "number" || !isNaN(val)), - "No such option: " + k); + _("option.noSuch", k)); Class.replaceProperty(args, opt.names[0], val); args.explicitOpts[opt.names[0]] = val; } @@ -416,7 +416,7 @@ var Ex = Module("Ex", { _run: function E_run(name) { const self = this; let cmd = this.commands.get(name); - util.assert(cmd, "No such command"); + util.assert(cmd, _("command.noSuch")); return update(function exCommand(options) { let args = self._args(cmd, arguments); @@ -469,10 +469,10 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { let name = names[0]; util.assert(!names.some(function (name) name in commands.builtin._map), - "E182: Can't replace non-user command: " + name); + _("command.cantReplace", name)); util.assert(replace || names.every(function (name) !(name in this._map), this), - "Not replacing command " + name); + _("command.wontReplace", name)); for (let name in values(names)) { ex.__defineGetter__(name, function () this._run(name)); @@ -504,7 +504,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { * @returns {Command} */ clear: function clear() { - util.assert(this.group.modifiable, "Cannot delete non-user commands"); + util.assert(this.group.modifiable, _("command.cantDelete")); this._map = {}; this._list = []; }, @@ -529,7 +529,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { * any of the command's names. */ remove: function remove(name) { - util.assert(this.group.modifiable, "Cannot delete non-user commands"); + util.assert(this.group.modifiable, _("command.cantDelete")); let cmd = this.get(name); this._list = this._list.filter(function (c) c !== cmd); @@ -586,7 +586,7 @@ var Commands = Module("commands", { return res.join("\n"); res.push(lines[i]); } - util.assert(false, "Unexpected end of file waiting for " + end); + util.assert(false, _("command.eof", end)); }; args = update({}, args || {}); @@ -932,11 +932,12 @@ var Commands = Module("commands", { if (sub.indexOf(optname) == 0) { let count = 0; let invalid = false; - let arg, uote, quoted; + let arg, quote, quoted; let sep = sub[optname.length]; + let argString = sub.substr(optname.length + 1); if (sep == "=" || /\s/.test(sep) && opt.type != CommandOption.NOARG) { - [count, quoted, quote, error] = getNextArg(sub.substr(optname.length + 1), true); + [count, quoted, quote, error] = getNextArg(argString, true); arg = Option.dequote(quoted); util.assert(!error, error); @@ -951,7 +952,7 @@ var Commands = Module("commands", { let context = null; if (!complete && quote) - fail("Invalid argument for option " + optname); + fail(_("command.invalidOptArg", optname, argString)); if (!invalid) { if (complete && !/[\s=]/.test(sep)) @@ -975,7 +976,7 @@ var Commands = Module("commands", { if (arg == null || (typeof arg == "number" && isNaN(arg))) { if (!complete || orig != "" || args.completeStart != str.length) - fail("Invalid argument for " + opt.type.description + " option: " + optname); + fail(_("command.invalidOptTypeArg", opt.type.description, optname, argString)); if (complete) complete.highlight(args.completeStart, count - 1, "SPELLCHECK"); } @@ -984,7 +985,7 @@ var Commands = Module("commands", { // we have a validator function if (typeof opt.validator == "function") { if (opt.validator(arg, quoted) == false && (arg || !complete)) { - fail("Invalid argument for option: " + optname); + fail(_("command.invalidOptArg", optname, argString)); if (complete) // Always true. complete.highlight(args.completeStart, count - 1, "SPELLCHECK"); } @@ -1046,9 +1047,9 @@ var Commands = Module("commands", { args.completeFilter = arg || ""; } else if (count == -1) - fail("Error parsing arguments: " + arg); + fail(_("command.parsing", arg)); else if (!onlyArgumentsRemaining && sub[0] === "-") - fail("Invalid option: " + arg); + fail(_("command.invalidOpt", arg)); if (arg != null) args.push(arg); @@ -1367,13 +1368,13 @@ var Commands = Module("commands", { let cmd = args[0]; util.assert(!cmd || cmd.split(",").every(commands.validName.closure.test), - "E182: Invalid command name"); + _("command.invalidName", cmd)); if (!args.literalArg) commands.list(); else { util.assert(args["-group"].modifiable, - "Cannot change commands in the builtin group"); + _("group.cantChangeBuiltin", _("command.commands"))); let completer = args["-complete"]; let completerFunc = null; // default to no completion for user commands @@ -1514,7 +1515,7 @@ var Commands = Module("commands", { commands.add(["delc[ommand]"], "Delete the specified user-defined command", function (args) { - util.assert(args.bang ^ !!args[0], "Argument or ! required"); + util.assert(args.bang ^ !!args[0], _("error.argumentOrBang")); let name = args[0]; if (args.bang) @@ -1522,7 +1523,7 @@ var Commands = Module("commands", { else if (args["-group"].get(name)) args["-group"].remove(name); else - dactyl.echoerr("E184: No such user-defined command: " + name); + dactyl.echoerr(_("command.noSuchUser", name)); }, { argCount: "?", bang: true, diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index f2a8da12..1d61d412 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -9,7 +9,7 @@ try { Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("contexts", { exports: ["Contexts", "Group", "contexts"], - use: ["commands", "options", "services", "storage", "styles", "template", "util"] + use: ["commands", "messages", "options", "services", "storage", "styles", "template", "util"] }, this); var Const = function Const(val) Class.Property({ enumerable: true, value: val }); @@ -324,7 +324,7 @@ var Contexts = Module("contexts", { let group = this.getGroup(name); - util.assert(!group || !group.builtin, "Cannot remove builtin group"); + util.assert(!group || !group.builtin, _("group.cantRemoveBuiltin")); if (group) { name = group.name; @@ -445,8 +445,8 @@ var Contexts = Module("contexts", { function (args) { if (args.length > 0) { var name = Option.dequote(args[0]); - util.assert(name !== "builtin", "Cannot modify builtin group"); - util.assert(commands.validName.test(name), "Invalid group name"); + util.assert(name !== "builtin", _("group.cantModifyBuiltin")); + util.assert(commands.validName.test(name), _("group.invalidName", name)); var group = contexts.getGroup(name); } @@ -455,7 +455,7 @@ var Contexts = Module("contexts", { else return void modules.completion.listCompleter("group", "", null, null); - util.assert(group || name, "No current group"); + util.assert(group || name, _("group.noCurrent")); let filter = Group.compileFilter(args["-locations"]); if (!group || args.bang) @@ -481,7 +481,7 @@ var Contexts = Module("contexts", { util.assert(!group.builtin || !["-description", "-locations", "-nopersist"] .some(function (arg) set.has(args.explicitOpts, arg)), - "Cannot modify builtin group"); + _("group.cantModifyBuiltin")); }, { argCount: "?", @@ -538,7 +538,7 @@ var Contexts = Module("contexts", { commands.add(["delg[roup]"], "Delete a group", function (args) { - util.assert(contexts.getGroup(args[0]), "No such group: " + args[0]); + util.assert(contexts.getGroup(args[0]), _("group.noSuch", args[0])); contexts.removeGroup(args[0]); }, { @@ -552,7 +552,7 @@ var Contexts = Module("contexts", { commands.add(["fini[sh]"], "Stop sourcing a script file", function (args) { - util.assert(args.context, "E168: :finish used outside of a sourced file"); + util.assert(args.context, _("command.finish.illegal")); args.context.finished = true; }, { argCount: "0" }); @@ -560,14 +560,14 @@ var Contexts = Module("contexts", { function checkStack(cmd) { util.assert(contexts.context && contexts.context.stack && contexts.context.stack[cmd] && contexts.context.stack[cmd].length, - "Invalid use of conditional"); + _("command.conditional.illegal")); } function pop(cmd) { checkStack(cmd); return contexts.context.stack[cmd].pop(); } function push(cmd, value) { - util.assert(contexts.context, "Invalid use of conditional"); + util.assert(contexts.context, _("command.conditional.illegal")); if (arguments.length < 2) value = contexts.context.noExecute; contexts.context.stack = contexts.context.stack || {}; diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index c3107342..48ba697a 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -8,7 +8,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("highlight", { exports: ["Highlight", "Highlights", "highlight"], require: ["services", "styles", "util"], - use: ["template"] + use: ["messages", "template"] }, this); var Highlight = Struct("class", "selector", "sites", @@ -306,7 +306,7 @@ var Highlights = Module("Highlight", { highlight.clear(); else { lastScheme = modules.io.sourceFromRuntimePath(["colors/" + scheme + "." + config.fileExtension]); - dactyl.assert(lastScheme, "E185: Cannot find color scheme " + scheme); + dactyl.assert(lastScheme, _("command.colorscheme.notFound", scheme)); } autocommands.trigger("ColorScheme", { name: scheme }); }, @@ -337,7 +337,7 @@ var Highlights = Module("Highlight", { if (!modify && /&$/.test(key)) [clear, modify, key] = [true, true, key.replace(/&$/, "")]; - dactyl.assert(!(clear && css), "E488: Trailing characters"); + dactyl.assert(!(clear && css), _("error.trailing")); if (!modify) modules.commandline.commandOutput( @@ -355,7 +355,7 @@ var Highlights = Module("Highlight", { else if (key) highlight.set(key, css, clear, "-append" in args, args["-link"]); else - util.assert(false, "Invalid arguments"); + util.assert(false, _("error.invalidArgument")); }, { // TODO: add this as a standard highlight completion function? diff --git a/common/modules/io.jsm b/common/modules/io.jsm index 8f0e4061..e56511dc 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -13,7 +13,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("io", { exports: ["IO", "io"], require: ["services"], - use: ["config", "storage", "styles", "template", "util"] + use: ["config", "messages", "storage", "styles", "template", "util"] }, this); // TODO: why are we passing around strings rather than file objects? @@ -251,12 +251,12 @@ var IO = Module("io", { newDir = newDir && newDir.path || newDir || "~"; if (newDir == "-") { - util.assert(this._oldcwd != null, "E186: No previous directory"); + util.assert(this._oldcwd != null, _("io.noPrevDir")); [this._cwd, this._oldcwd] = [this._oldcwd, this.cwd]; } else { let dir = io.File(newDir); - util.assert(dir.exists() && dir.isDirectory(), "E344: Can't find directory " + dir.path.quote()); + util.assert(dir.exists() && dir.isDirectory(), _("io.noSuchDir", dir.path.quote())); dir.normalize(); [this._cwd, this._oldcwd] = [dir.path, this.cwd]; } @@ -483,7 +483,7 @@ var IO = Module("io", { let shell = io.pathSearch(storage["options"].get("shell").value); let shcf = storage["options"].get("shellcmdflag").value; - util.assert(shell, "Invalid 'shell'"); + util.assert(shell, _("error.invalid", "'shell'")); if (isArray(command)) command = command.map(escape).join(" "); diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm index 836bc0fd..f8f079a1 100644 --- a/common/modules/messages.jsm +++ b/common/modules/messages.jsm @@ -20,11 +20,19 @@ var Messages = Module("messages", { this.bundle = services.stringBundle.createBundle(JSMLoader.getTarget("dactyl://locale/messages.properties")); + this._ = function _(message) { + if (arguments.length > 1) { + let args = Array.slice(arguments, 1); + return this.format(message + "-" + args.length, args, null) || this.format(message, args); + } + return this.get(message); + }; + let seen = {}; for (let prop in iter(this.bundle.getSimpleEnumeration())) { let key = prop.QueryInterface(Ci.nsIPropertyElement).key.split(".")[0]; if (!set.add(seen, key)) - this[key] = { + this._[key] = this[key] = { __noSuchMethod__: function __(prop, args) self._.apply(self, [prop].concat(args)) }; } @@ -34,19 +42,14 @@ var Messages = Module("messages", { services.stringBundle.flushBundles(); }, - _: function _(message) { - if (arguments.length > 1) { - let args = Array.slice(arguments, 1); - return this.format(message + "-", args, null) || this.format(message, args); - } - return this.get(message); - }, - get: function get(value, default_) { try { return this.bundle.GetStringFromName(value); } catch (e) { + // Report error so tests fail, but don't throw + if (arguments.length < 2) + util.reportError(Error("Invalid locale string: " + value + ": " + e)); return arguments.length > 1 ? default_ : value; } }, @@ -56,6 +59,9 @@ var Messages = Module("messages", { return this.bundle.formatStringFromName(value, args, args.length); } catch (e) { + // Report error so tests fail, but don't throw + if (arguments.length < 3) + util.reportError(Error("Invalid locale string: " + value + ": " + e)); return arguments.length > 2 ? default_ : value; } } diff --git a/common/modules/template.jsm b/common/modules/template.jsm index f42adb9b..702876fe 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -8,7 +8,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("template", { exports: ["Binding", "Template", "template"], require: ["util"], - use: ["services"] + use: ["messages", "services"] }, this); default xml namespace = XHTML; |