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