summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-02-25 20:23:15 -0500
committerKris Maglione <maglione.k@gmail.com>2011-02-25 20:23:15 -0500
commit7c7a7c48650dbec8e9d653fa0e5a3f7f5ce43743 (patch)
treeb20cee1c42f78ee7989bafdb1ba4e5e28a55d257
parent885b16d7db9bd0d0bea63d26707d4cb0b0e81810 (diff)
downloadpentadactyl-7c7a7c48650dbec8e9d653fa0e5a3f7f5ce43743.tar.gz
Move some messages to properties file. Local and modules directories still to be done.
-rw-r--r--common/content/abbreviations.js8
-rw-r--r--common/content/autocommands.js16
-rw-r--r--common/content/bookmarks.js12
-rw-r--r--common/content/browser.js5
-rw-r--r--common/content/buffer.js36
-rw-r--r--common/content/commandline.js2
-rw-r--r--common/content/dactyl.js40
-rw-r--r--common/content/editor.js2
-rw-r--r--common/content/events.js43
-rw-r--r--common/content/hints.js2
-rw-r--r--common/content/history.js10
-rw-r--r--common/content/mappings.js13
-rw-r--r--common/content/marks.js22
-rw-r--r--common/content/mow.js5
-rw-r--r--common/content/quickmarks.js14
-rw-r--r--common/content/tabs.js30
-rw-r--r--common/locale/en-US/messages.properties107
-rw-r--r--common/modules/messages.jsm73
-rw-r--r--common/modules/overlay.jsm1
19 files changed, 309 insertions, 132 deletions
diff --git a/common/content/abbreviations.js b/common/content/abbreviations.js
index 0e9a7cb5..9a76fa37 100644
--- a/common/content/abbreviations.js
+++ b/common/content/abbreviations.js
@@ -224,7 +224,7 @@ var Abbreviations = Module("abbreviations", {
// TODO: Move this to an ItemList to show this automatically
if (list.*.length() === list.text().length() + 2)
- dactyl.echomsg("No abbreviations found");
+ dactyl.echomsg(_("abbrev.none"));
else
commandline.commandOutput(list);
}
@@ -256,7 +256,7 @@ var Abbreviations = Module("abbreviations", {
function (args) {
let [lhs, rhs] = args;
dactyl.assert(!args.length || abbreviations._check.test(lhs),
- "E474: Invalid argument");
+ _("error.invalidArgument"));
if (!rhs)
abbreviations.list(modes, lhs || "");
@@ -296,12 +296,12 @@ var Abbreviations = Module("abbreviations", {
commands.add([ch + "una[bbreviate]"],
"Remove an abbreviation" + modeDescription,
function (args) {
- util.assert(args.bang ^ !!args[0], "Argument or ! required");
+ util.assert(args.bang ^ !!args[0], _("error.argumentOrBang"));
if (args.bang)
args["-group"].clear(modes);
else if (!args["-group"].remove(modes, args[0]))
- return dactyl.echoerr("E24: No such abbreviation");
+ return dactyl.echoerr(_("abbrev.noSuch"));
}, {
argCount: "?",
bang: true,
diff --git a/common/content/autocommands.js b/common/content/autocommands.js
index fb437eaa..57545448 100644
--- a/common/content/autocommands.js
+++ b/common/content/autocommands.js
@@ -138,7 +138,7 @@ var AutoCommands = Module("autocommands", {
if (options.get("eventignore").has(event))
return;
- dactyl.echomsg('Executing ' + event + ' Auto commands for "*"', 8);
+ dactyl.echomsg(_("autocmd.executing", event, "*".quote()), 8);
let lastPattern = null;
var { url, doc } = args;
@@ -156,10 +156,10 @@ var AutoCommands = Module("autocommands", {
for (let autoCmd in values(hive._store))
if (autoCmd.eventName === event && autoCmd.filter(uri, doc)) {
if (!lastPattern || lastPattern !== String(autoCmd.filter))
- dactyl.echomsg("Executing " + event + " Auto commands for " + autoCmd.filter, 8);
+ dactyl.echomsg(_("autocmd.executing", event, autoCmd.filter), 8);
lastPattern = String(autoCmd.filter);
- dactyl.echomsg("autocommand " + autoCmd.command, 9);
+ dactyl.echomsg(_("autocmd.autocommand", autoCmd.command), 9);
dactyl.trapErrors(autoCmd.command, autoCmd, args);
}
@@ -181,7 +181,7 @@ var AutoCommands = Module("autocommands", {
events = Option.parse.stringlist(event);
dactyl.assert(events.every(function (event) validEvents.indexOf(event.toLowerCase()) >= 0),
- "E216: No such group or event: " + event);
+ _("autocmd.noGroup", event));
}
if (args.length > 2) { // add new command, possibly removing all others with the same event/pattern
@@ -237,7 +237,7 @@ var AutoCommands = Module("autocommands", {
function (args) {
// Vim compatible
if (args.length == 0)
- return void dactyl.echomsg("No matching autocommands");
+ return void dactyl.echomsg(_("msg.noMatchingAutocmd"));
let [event, url] = args;
let defaultURL = url || buffer.uri.spec;
@@ -245,11 +245,11 @@ var AutoCommands = Module("autocommands", {
// TODO: add command validators
dactyl.assert(event != "*",
- "E217: Can't execute autocommands for ALL events");
+ _("autocmd.cantExecuteAll"));
dactyl.assert(validEvents.indexOf(event) >= 0,
- "E216: No such group or event: " + args);
+ _("autocmd.noGroup", args));
dactyl.assert(autocommands.get(event).some(function (c) c.patterns.some(function (re) re.test(defaultURL) ^ !re.result)),
- "No matching autocommands");
+ _("autocmd.noMatching"));
if (this.name == "doautoall" && dactyl.has("tabs")) {
let current = tabs.index();
diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js
index 1e2c3138..eef65aba 100644
--- a/common/content/bookmarks.js
+++ b/common/content/bookmarks.js
@@ -344,13 +344,13 @@ var Bookmarks = Module("bookmarks", {
return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
if (filter.length > 0 && tags.length > 0)
- dactyl.echoerr("E283: No bookmarks matching tags: " + tags.map(String.quote) + " and string: " + filter.quote());
+ dactyl.echoerr(_("bookmark.noMatching", tags.map(String.quote), filter.quote()));
else if (filter.length > 0)
- dactyl.echoerr("E283: No bookmarks matching string: " + filter.quote());
+ dactyl.echoerr(_("bookmark.noMatchingString", filter.quote()));
else if (tags.length > 0)
- dactyl.echoerr("E283: No bookmarks matching tags: " + tags.map(String.quote));
+ dactyl.echoerr(_("bookmark.noMatchingTags", tags.map(String.quote)));
else
- dactyl.echoerr("No bookmarks set");
+ dactyl.echoerr(_("bookmark.none"));
return null;
}
}, {
@@ -433,7 +433,7 @@ var Bookmarks = Module("bookmarks", {
1, commandline.FORCE_SINGLELINE);
}
else
- dactyl.echoerr("Exxx: Could not add bookmark " + opts.title.quote(), commandline.FORCE_SINGLELINE);
+ dactyl.echoerr(_("bookmark.cantAdd", opts.title.quote()));
}, {
argCount: "?",
bang: true,
@@ -489,7 +489,7 @@ var Bookmarks = Module("bookmarks", {
function (resp) {
if (resp && resp.match(/^y(es)?$/i)) {
bookmarks.remove(Object.keys(bookmarkcache.bookmarks));
- dactyl.echomsg("All bookmarks deleted");
+ dactyl.echomsg(_("bookmark.allGone"));
}
});
else {
diff --git a/common/content/browser.js b/common/content/browser.js
index 158ec690..d8798c9f 100644
--- a/common/content/browser.js
+++ b/common/content/browser.js
@@ -195,11 +195,12 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
setOverLink.superapply(this, arguments);
switch (options["showstatuslinks"]) {
case "status":
- statusline.updateUrl(link ? "Link: " + link : null);
+ statusline.updateUrl(link ? _("status.link", link) : null);
break;
case "command":
if (link)
- dactyl.echo("Link: " + link, commandline.DISALLOW_MULTILINE);
+ dactyl.echo(_("status.link", link),
+ commandline.DISALLOW_MULTILINE);
else
commandline.clear();
break;
diff --git a/common/content/buffer.js b/common/content/buffer.js
index f970e9f3..759fe0b4 100644
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -574,7 +574,7 @@ var Buffer = Module("buffer", {
file.create(File.NORMAL_FILE_TYPE, octal(644));
}
catch (e) {
- util.assert(false, "Invalid destination: " + e.name);
+ util.assert(false, _("save.invalidDestination", e.name));
}
buffer.saveURI(uri, file);
@@ -978,7 +978,7 @@ var Buffer = Module("buffer", {
*/
setZoom: function setZoom(value, fullZoom) {
dactyl.assert(value >= Buffer.ZOOM_MIN || value <= Buffer.ZOOM_MAX,
- "Zoom value out of range (" + Buffer.ZOOM_MIN + " - " + Buffer.ZOOM_MAX + "%)");
+ _("zoom.outOfRange", Buffer.ZOOM_MIN, Buffer.ZOOM_MAX));
if (fullZoom !== undefined)
ZoomManager.useFullZoom = fullZoom;
@@ -986,7 +986,7 @@ var Buffer = Module("buffer", {
ZoomManager.zoom = value / 100;
}
catch (e if e == Cr.NS_ERROR_ILLEGAL_VALUE) {
- return dactyl.echoerr("Illegal zoom value"); // XXX
+ return dactyl.echoerr(_("zoom.illegal"));
}
if ("FullZoom" in window)
@@ -1237,16 +1237,16 @@ var Buffer = Module("buffer", {
// FIXME: arg handling is a bit of a mess, check for filename
dactyl.assert(!arg || arg[0] == ">" && !util.OS.isWindows,
- "E488: Trailing characters");
+ _("error.trailing"));
prefs.withContext(function () {
if (arg) {
prefs.set("print.print_to_file", "true");
prefs.set("print.print_to_filename", io.File(arg.substr(1)).path);
- dactyl.echomsg("Printing to file: " + arg.substr(1));
+ dactyl.echomsg(_("print.toFile", arg.substr(1)));
}
else
- dactyl.echomsg("Sending to printer...");
+ dactyl.echomsg(_("print.sending"));
prefs.set("print.always_print_silent", args.bang);
prefs.set("print.show_print_progress", !args.bang);
@@ -1255,9 +1255,9 @@ var Buffer = Module("buffer", {
});
if (arg)
- dactyl.echomsg("Printed: " + arg.substr(1));
+ dactyl.echomsg(_("print.printed", arg.substr(1)));
else
- dactyl.echomsg("Print job sent.");
+ dactyl.echomsg(messgaes.print.sent());
},
{
argCount: "?",
@@ -1271,7 +1271,8 @@ var Buffer = Module("buffer", {
let arg = args[0];
let opt = options.get("pageinfo");
- dactyl.assert(!arg || opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg);
+ dactyl.assert(!arg || opt.validator(opt.parse(arg)),
+ _("error.invalidArgument", arg));
buffer.showPageInfo(true, arg);
},
{
@@ -1290,7 +1291,7 @@ var Buffer = Module("buffer", {
let titles = buffer.alternateStyleSheets.map(function (stylesheet) stylesheet.title);
dactyl.assert(!arg || titles.indexOf(arg) >= 0,
- "E475: Invalid argument: " + arg);
+ _("error.invalidArgument", arg));
if (options["usermode"])
options["usermode"] = false;
@@ -1331,14 +1332,15 @@ var Buffer = Module("buffer", {
if (/^>>/.test(filename)) {
let file = io.File(filename.replace(/^>>\s*/, ""));
- dactyl.assert(args.bang || file.exists() && file.isWritable(), file.path.quote() + ": E212: Can't open file for writing");
+ dactyl.assert(args.bang || file.exists() && file.isWritable(),
+ _("io.notWriteable", file.path.quote()));
return buffer.viewSourceExternally(buffer.focusedFrame.document,
function (tmpFile) {
try {
file.write(tmpFile, ">>");
}
catch (e) {
- dactyl.echoerr(file.path.quote() + ": E212: Can't open file for writing");
+ dactyl.echoerr(_("io.notWriteable", file.path.quote()));
}
});
}
@@ -1348,7 +1350,7 @@ var Buffer = Module("buffer", {
if (filename.substr(-1) === File.PATH_SEP || file.exists() && file.isDirectory())
file.append(Buffer.getDefaultNames(doc)[0][0]);
- dactyl.assert(args.bang || !file.exists(), "E13: File exists (add ! to override)");
+ dactyl.assert(args.bang || !file.exists(), _("io.exists"));
chosenData = { file: file, uri: util.newURI(doc.location.href) };
}
@@ -1414,7 +1416,7 @@ var Buffer = Module("buffer", {
level = Math.constrain(level, Buffer.ZOOM_MIN, Buffer.ZOOM_MAX);
}
else
- dactyl.assert(false, "E488: Trailing characters");
+ dactyl.assert(false, _("error.trailing"));
buffer.setZoom(level, args.bang);
},
@@ -1682,7 +1684,7 @@ var Buffer = Module("buffer", {
"Open (]put) a URL based on the current clipboard contents in a new buffer",
function () {
let url = dactyl.clipboardRead();
- dactyl.assert(url, "No clipboard data");
+ dactyl.assert(url, _("error.clipboardEmpty"));
dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true });
});
@@ -1690,7 +1692,7 @@ var Buffer = Module("buffer", {
"Open (put) a URL based on the current clipboard contents in the current buffer",
function () {
let url = dactyl.clipboardRead();
- dactyl.assert(url, "No clipboard data");
+ dactyl.assert(url, _("error.clipboardEmpty"));
dactyl.open(url);
});
@@ -1698,7 +1700,7 @@ var Buffer = Module("buffer", {
"Open (put) a URL based on the current clipboard contents in a new buffer",
function () {
let url = dactyl.clipboardRead();
- dactyl.assert(url, "No clipboard data");
+ dactyl.assert(url, _("error.clipboardEmpty"));
dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB });
});
diff --git a/common/content/commandline.js b/common/content/commandline.js
index 8611bb30..e2ac592e 100644
--- a/common/content/commandline.js
+++ b/common/content/commandline.js
@@ -704,7 +704,7 @@ var CommandLine = Module("commandline", {
messageCount: 0,
echo: function echo(data, highlightGroup, flags) {
// dactyl.echo uses different order of flags as it omits the highlight group, change commandline.echo argument order? --mst
- if (this._silent)
+ if (this._silent || !this.widgets)
return;
this.messageCount++;
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index 37822604..68c03316 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -344,7 +344,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
if (isinstance(str, ["Error", "Exception"]))
dactyl.reportError(str);
- if (typeof str == "object" && "echoerr" in str)
+ if (isObject(str) && "echoerr" in str)
str = str.echoerr;
else if (isinstance(str, ["Error"]) && str.fileName)
str = <>{str.fileName.replace(/^.* -> /, "")}: {str.lineNumber}: {str}</>;
@@ -377,7 +377,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* @param {number} flags These control the multi-line message behavior.
* See {@link CommandLine#echo}.
*/
- echomsg: function (str, verbosity, flags) {
+ echomsg: function echomsg(str, verbosity, flags) {
if (verbosity == null)
verbosity = 0; // verbosity level is exclusionary
@@ -1044,12 +1044,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
if (helpFile in services["dactyl:"].FILE_MAP)
dactyl.open("dactyl://help/" + helpFile, { from: "help" });
else
- dactyl.echomsg("Sorry, help file " + helpFile.quote() + " not found");
+ dactyl.echomsg(_("help.noFile", helpFile.quote()));
return;
}
let page = this.findHelp(topic, consolidated);
- dactyl.assert(page != null, "E149: Sorry, no help for " + topic);
+ dactyl.assert(page != null, _("help.noTopic", topic));
dactyl.open("dactyl://help/" + page, { from: "help" });
},
@@ -1066,7 +1066,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
loadPlugins: function (args, force) {
function sourceDirectory(dir) {
- dactyl.assert(dir.isReadable(), "E484: Can't open file " + dir.path);
+ dactyl.assert(dir.isReadable(), _("io.notReadable", dir.path));
dactyl.log("Sourcing plugin directory: " + dir.path + "...", 3);
@@ -1096,12 +1096,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
return;
}
- dactyl.echomsg('Searching for "plugins/**/*.{js,' + config.fileExtension + '}" in '
- + [dir.path.replace(/.plugins$/, "") for ([, dir] in Iterator(dirs))]
- .join(",").quote(), 2);
+ dactyl.echomsg(
+ _("plugin.searchingForIn",
+ ("plugins/**/*.{js," + config.fileExtension + "}").quote(),
+ [dir.path.replace(/.plugins$/, "") for ([, dir] in Iterator(dirs))]
+ .join(",").quote()),
+ 2);
dirs.forEach(function (dir) {
- dactyl.echomsg("Searching for " + (dir.path + "/**/*.{js," + config.fileExtension + "}").quote(), 3);
+ dactyl.echomsg(_("plugin.searchingFor", (dir.path + "/**/*.{js," + config.fileExtension + "}").quote()), 3);
sourceDirectory(dir);
});
},
@@ -1705,14 +1708,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function (args) {
let dialog = args[0];
- dactyl.assert(dialog in config.dialogs, "E475: Invalid argument: " + dialog);
+ dactyl.assert(dialog in config.dialogs,
+ _("error.invalidArgument", dialog));
dactyl.assert(!config.dialogs[dialog][2] || config.dialogs[dialog][2](),
- "Dialog " + dialog + " not available");
+ _("dialog.notAvailable", dialog));
try {
config.dialogs[dialog][1]();
}
catch (e) {
- dactyl.echoerr("Error opening " + dialog.quote() + ": " + (e.message || e));
+ dactyl.echoerr(_("error.cantOpen", dialog.quote(), e.message || e));
}
}, {
argCount: "1",
@@ -1730,7 +1734,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let items = Dactyl.getMenuItems();
dactyl.assert(items.some(function (i) i.fullMenuPath == arg),
- "E334: Menu not found: " + arg);
+ _("emenu.notFound", arg));
for (let [, item] in Iterator(items)) {
if (item.fullMenuPath == arg)
@@ -1771,7 +1775,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
commands.add([command.name],
command.description,
function (args) {
- dactyl.assert(!args.bang, "E478: Don't panic!");
+ dactyl.assert(!args.bang, _("help.dontPanic"));
dactyl.help(args.literalArg, consolidated);
}, {
argCount: "?",
@@ -1873,7 +1877,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
commands.add(names, desc,
function (args) {
let toolbar = findToolbar(args[0] || "");
- dactyl.assert(toolbar, "E474: Invalid argument");
+ dactyl.assert(toolbar, _("error.invalidArgument"));
action(toolbar);
events.checkFocus();
}, {
@@ -1959,9 +1963,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let afterTime = Date.now();
if (afterTime - beforeTime >= 100)
- dactyl.echo("Total time: " + ((afterTime - beforeTime) / 1000.0).toFixed(2) + " sec");
+ dactyl.echo(_("time.total", ((afterTime - beforeTime) / 1000.0).toFixed(2) + " sec"));
else
- dactyl.echo("Total time: " + (afterTime - beforeTime) + " msec");
+ dactyl.echo(_("time.total", (afterTime - beforeTime) + " msec"));
}
}
catch (e) {
@@ -2078,7 +2082,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}
}
catch (e) {
- dactyl.echoerr("Parsing command line options: " + e);
+ dactyl.echoerr(_("dactyl.parsingCommandLine", e));
}
dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3);
diff --git a/common/content/editor.js b/common/content/editor.js
index 33db7b5b..34460f49 100644
--- a/common/content/editor.js
+++ b/common/content/editor.js
@@ -252,7 +252,7 @@ var Editor = Module("editor", {
let args = options.get("editor").format(args);
- dactyl.assert(args.length >= 1, "No editor specified");
+ dactyl.assert(args.length >= 1, _("editor.noEditor"));
io.run(args.shift(), args, blocking);
},
diff --git a/common/content/events.js b/common/content/events.js
index 41ea97a3..263d81a9 100644
--- a/common/content/events.js
+++ b/common/content/events.js
@@ -473,9 +473,9 @@ var Events = Module("events", {
catch (e) {
dactyl.reportError(e);
if (e.message == "Interrupted")
- dactyl.echoerr("Interrupted", commandline.FORCE_SINGLELINE);
+ dactyl.echoerr(_("error.interrupted"), commandline.FORCE_SINGLELINE);
else
- dactyl.echoerr("Processing " + event.type + " event: " + (e.echoerr || e),
+ dactyl.echoerr(_("event.error", event.type, e.echoerr || e),
commandline.FORCE_SINGLELINE);
}
};
@@ -498,7 +498,7 @@ var Events = Module("events", {
set recording(macro) {
dactyl.assert(macro == null || /[a-zA-Z0-9]/.test(macro),
- "E354: Invalid register name: '" + macro + "'");
+ _("macro.invalid", macro));
modes.recording = !!macro;
@@ -517,7 +517,7 @@ var Events = Module("events", {
});
dactyl.log("Recorded " + this.recording + ": " + this._macroKeys.join(""), 9);
- dactyl.echomsg("Recorded macro '" + this.recording + "'");
+ dactyl.echomsg(_("macro.recorded", this.recording));
}
this._recording = macro || null;
},
@@ -530,17 +530,11 @@ var Events = Module("events", {
*/
playMacro: function (macro) {
let res = false;
- if (!/[a-zA-Z0-9@]/.test(macro) && macro.length == 1) {
- dactyl.echoerr("E354: Invalid register name: '" + macro + "'");
- return false;
- }
+ dactyl.assert(!/[a-zA-Z0-9@]/.test(macro) && macro.length == 1,
+ _("macro.invalid", macro));
- if (macro == "@") { // use lastMacro if it's set
- if (!this._lastMacro) {
- dactyl.echoerr("E748: No previously used register");
- return false;
- }
- }
+ if (macro == "@")
+ dactyl.assert(this._lastMacro, _("macro.noPrevious"));
else
this._lastMacro = macro.toLowerCase(); // XXX: sets last played macro, even if it does not yet exist
@@ -555,7 +549,7 @@ var Events = Module("events", {
}
else
// TODO: ignore this like Vim?
- dactyl.echoerr("Exxx: Register '" + this._lastMacro + "' not set");
+ dactyl.echoerr(_("macro.notSet", this._lastMacro));
return res;
},
@@ -1041,13 +1035,13 @@ var Events = Module("events", {
if (buffer.loaded)
return true;
- dactyl.echo("Waiting for page to load...", commandline.DISALLOW_MULTILINE);
+ dactyl.echo(_("macro.loadWaiting"), commandline.DISALLOW_MULTILINE);
const maxWaitTime = (time || 25);
util.waitFor(function () !events.feedingKeys || buffer.loaded, this, maxWaitTime * 1000, true);
if (!buffer.loaded)
- dactyl.echoerr("Page did not load completely in " + maxWaitTime + " seconds.");
+ dactyl.echoerr(_("macro.loadFailed", maxWaitTime));
return buffer.loaded;
},
@@ -1192,7 +1186,7 @@ var Events = Module("events", {
events.feedingKeys = false;
if (modes.replaying) {
modes.replaying = false;
- this.timeout(function () { dactyl.echomsg("Canceled playback of macro '" + this._lastMacro + "'"); }, 100);
+ this.timeout(function () { dactyl.echomsg(_("macro.canceled", this._lastMacro)); }, 100);
}
}
else
@@ -1467,14 +1461,14 @@ var Events = Module("events", {
commands.add(["delmac[ros]"],
"Delete macros",
function (args) {
- dactyl.assert(!args.bang || !args[0], "E474: Invalid argument");
+ dactyl.assert(!args.bang || !args[0], _("error.invalidArgument"));
if (args.bang)
events.deleteMacros();
else if (args[0])
events.deleteMacros(args[0]);
else
- dactyl.echoerr("E471: Argument required");
+ dactyl.echoerr(_("error.argumentRequired"));
}, {
bang: true,
completer: function (context) completion.macro(context),
@@ -1522,7 +1516,8 @@ var Events = Module("events", {
mappings.add([modes.BASE],
["<Pass>"], "Pass the events consumed by the last executed mapping",
function ({ keypressEvents: [event] }) {
- dactyl.assert(event.dactylSavedEvents, "No events to pass");
+ dactyl.assert(event.dactylSavedEvents,
+ _("event.nothingToPass"));
return function () {
events.feedevents(null, event.dactylSavedEvents,
{ skipmap: true, isMacro: true, isReplay: true });
@@ -1542,8 +1537,8 @@ var Events = Module("events", {
["@", "<play-macro>"], "Play a macro",
function ({ arg, count }) {
count = Math.max(count, 1);
- while (count-- && events.playMacro(arg))
- ;
+ while (count--)
+ events.playMacro(arg);
},
{ arg: true, count: true });
@@ -1551,7 +1546,7 @@ var Events = Module("events", {
["<A-m>s", "<sleep>"], "Sleep for {count} milliseconds before continuing macro playback",
function ({ command, count }) {
let now = Date.now();
- dactyl.assert(count, "Count required for " + command);
+ dactyl.assert(count, _("error.countRequired", command));
if (events.feedingKeys)
util.sleep(count);
},
diff --git a/common/content/hints.js b/common/content/hints.js
index a3e5c6cc..12eb36da 100644
--- a/common/content/hints.js
+++ b/common/content/hints.js
@@ -963,7 +963,7 @@ var Hints = Module("hints", {
case "wordstartswith": return wordStartsWithMatcher(hintString, true);
case "firstletters" : return wordStartsWithMatcher(hintString, false);
case "custom" : return dactyl.plugins.customHintMatcher(hintString);
- default : dactyl.echoerr("Invalid hintmatching type: " + hintMatching);
+ default : dactyl.echoerr(_("hints.noMatcher", hintMatching));
}
return null;
}, //}}}
diff --git a/common/content/history.js b/common/content/history.js
index b768a02c..cf985d99 100644
--- a/common/content/history.js
+++ b/common/content/history.js
@@ -26,7 +26,7 @@ var History = Module("history", {
(order = "SORT_BY_" + order[2].toUpperCase() + "_" +
(order[1] == "+" ? "ASCENDING" : "DESCENDING")) &&
order in options,
- "Invalid sort order");
+ _("error.invalidSort", order));
options.sortingMode = options[order];
options.resultType = options.RESULTS_AS_URI;
@@ -113,9 +113,9 @@ var History = Module("history", {
return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
if (filter.length > 0)
- dactyl.echoerr("E283: No history matching " + filter.quote());
+ dactyl.echoerr(_("history.noMatching", filter.quote()));
else
- dactyl.echoerr("No history set");
+ dactyl.echoerr(_("history.none"));
return null;
}
}, {
@@ -137,7 +137,7 @@ var History = Module("history", {
for (let [i, ent] in Iterator(sh.slice(0, sh.index).reverse()))
if (ent.URI.spec == url)
return void window.getWebNavigation().gotoIndex(i);
- dactyl.echoerr("Exxx: URL not found in history");
+ dactyl.echoerr(_("history.noURL"));
}
else
history.stepTo(-Math.max(args.count, 1));
@@ -177,7 +177,7 @@ var History = Module("history", {
for (let [i, ent] in Iterator(sh.slice(sh.index + 1)))
if (ent.URI.spec == url)
return void window.getWebNavigation().gotoIndex(i);
- dactyl.echoerr("Exxx: URL not found in history");
+ dactyl.echoerr(_("history.noURL"));
}
else
history.stepTo(Math.max(args.count, 1));
diff --git a/common/content/mappings.js b/common/content/mappings.js
index f4a29d73..a30aefe2 100644
--- a/common/content/mappings.js
+++ b/common/content/mappings.js
@@ -118,7 +118,7 @@ var Map = Class("Map", {
if (this.executing)
util.dumpStack("Attempt to execute mapping recursively: " + args.command);
- dactyl.assert(!this.executing, "Attempt to execute mapping recursively: " + args.command);
+ dactyl.assert(!this.executing, _("map.recursive", args.command));
try {
this.executing = true;
@@ -427,7 +427,7 @@ var Mappings = Module("mappings", {
// TODO: Move this to an ItemList to show this automatically
if (list.*.length() === list.text().length() + 2)
- dactyl.echomsg("No mapping found");
+ dactyl.echomsg(_("map.none"));
else
commandline.commandOutput(list);
}
@@ -459,7 +459,7 @@ var Mappings = Module("mappings", {
mappings.list(mapmodes, mappings.expandLeader(lhs), hives);
else {
util.assert(args["-group"].modifiable,
- "Cannot change mappings in the builtin group");
+ _("map.builtinImmutable"));
args["-group"].add(mapmodes, [lhs],
args["-description"],
@@ -579,10 +579,9 @@ var Mappings = Module("mappings", {
commands.add([ch + "unm[ap]"],
"Remove a mapping" + modeDescription,
function (args) {
- util.assert(args["-group"].modifiable,
- "Cannot change mappings in the builtin group");
+ util.assert(args["-group"].modifiable, _("map.builtinImmutable"));
- util.assert(args.bang ^ !!args[0], "Argument or ! required");
+ util.assert(args.bang ^ !!args[0], _("error.argumentOrBang"));
let mapmodes = array.uniq(args["-modes"].map(findMode));
@@ -596,7 +595,7 @@ var Mappings = Module("mappings", {
}
if (!found && !args.bang)
- dactyl.echoerr("E31: No such mapping");
+ dactyl.echoerr(_("map.noSuch", args[0]));
},
{
argCount: "?",
diff --git a/common/content/marks.js b/common/content/marks.js
index c6c88179..aedbfc06 100644
--- a/common/content/marks.js
+++ b/common/content/marks.js
@@ -101,7 +101,7 @@ var Marks = Module("marks", {
jumpTo: function (char) {
if (Marks.isURLMark(char)) {
let mark = this._urlMarks.get(char);
- dactyl.assert(mark, "E20: Mark not set: " + char);
+ dactyl.assert(mark, _("mark.unset", char));
let tab = mark.tab && mark.tab.get();
if (!tab || !tab.linkedBrowser || tabs.allTabs.indexOf(tab) == -1)
@@ -144,13 +144,13 @@ var Marks = Module("marks", {
}
else if (Marks.isLocalMark(char)) {
let mark = (this._localMarks.get(this.localURI) || {})[char];
- dactyl.assert(mark, "E20: Mark not set: " + char);
+ dactyl.assert(mark, _("mark.unset", char));
dactyl.log("Jumping to local mark: " + Marks.markToString(char, mark), 5);
buffer.scrollToPercent(mark.position.x * 100, mark.position.y * 100);
}
else
- dactyl.echoerr("E20: Invalid mark");
+ dactyl.echoerr(_("mark.invalid"));
},
@@ -162,12 +162,12 @@ var Marks = Module("marks", {
list: function (filter) {
let marks = this.all;
- dactyl.assert(marks.length > 0, "No marks set");
+ dactyl.assert(marks.length > 0, _("mark.none"));
if (filter.length > 0) {
let pattern = util.charListToRegexp(filter, "a-zA-Z");
marks = marks.filter(function ([k, ]) pattern.test(k));
- dactyl.assert(marks.length > 0, "E283: No marks matching " + filter.quote());
+ dactyl.assert(marks.length > 0, _("mark.noMatching", filter.quote()));
}
commandline.commandOutput(
@@ -215,8 +215,7 @@ var Marks = Module("marks", {
mappings.add(myModes,
["m"], "Set mark at the cursor position",
function ({ arg }) {
- dactyl.assert(/^[a-zA-Z]$/.test(arg),
- "E191: Argument must be an ASCII letter");
+ dactyl.assert(/^[a-zA-Z]$/.test(arg), _("mark.invalid"));
marks.add(arg);
},
{ arg: true });
@@ -235,8 +234,8 @@ var Marks = Module("marks", {
let arg = args[0] || "";
// assert(special ^ args)
- dactyl.assert( special || arg, "E471: Argument required");
- dactyl.assert(!special || !arg, "E474: Invalid argument");
+ dactyl.assert( special || arg, _("error.argumentRequired"));
+ dactyl.assert(!special || !arg, _("error.invalidArgument"));
marks.remove(arg, special);
},
@@ -250,9 +249,8 @@ var Marks = Module("marks", {
"Mark current location within the web page",
function (args) {
let mark = args[0] || "";
- dactyl.assert(mark.length <= 1, "E488: Trailing characters");
- dactyl.assert(/[a-zA-Z]/.test(mark),
- "E191: Argument must be an ASCII letter");
+ dactyl.assert(mark.length <= 1, _("error.trailing"));
+ dactyl.assert(/[a-zA-Z]/.test(mark), _("mark.invalid"));
marks.add(mark);
},
diff --git a/common/content/mow.js b/common/content/mow.js
index f27a0e57..50f361cc 100644
--- a/common/content/mow.js
+++ b/common/content/mow.js
@@ -36,6 +36,7 @@ var MOW = Module("mow", {
events.listen(window, this, "windowEvents");
+ modules.mow = this;
let fontSize = util.computedStyle(document.documentElement).fontSize;
styles.system.add("font-size", "dactyl://content/buffer.xhtml",
"body { font-size: " + fontSize + "; } \
@@ -126,7 +127,7 @@ var MOW = Module("mow", {
data.document = this.document;
output.appendChild(data.message);
- this.messages.push(data);
+ this._("push", data);
}
else {
let style = isString(data) ? "pre" : "nowrap";
@@ -305,7 +306,7 @@ var MOW = Module("mow", {
mappings.add([modes.COMMAND],
["g<lt>"], "Redisplay the last command output",
function () {
- dactyl.assert(commandline.lastOutput, "No previous command output");
+ dactyl.assert(commandline.lastOutput, _("mow.noPreviousOutput"));
mow.echo(mow.lastOutput, "Normal");
});
diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js
index 386bd100..532343a5 100644
--- a/common/content/quickmarks.js
+++ b/common/content/quickmarks.js
@@ -89,7 +89,7 @@ var QuickMarks = Module("quickmarks", {
if (url)
dactyl.open(url, where);
else
- dactyl.echoerr("E20: QuickMark not set");
+ dactyl.echoerr(_("quickmark.notSet"));
},
/**
@@ -105,12 +105,12 @@ var QuickMarks = Module("quickmarks", {
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
- dactyl.assert(marks.length > 0, "No QuickMarks set");
+ dactyl.assert(marks.length > 0, _("quickmark.none"));
if (filter.length > 0) {
let pattern = util.charListToRegexp(filter, "a-zA-Z0-9");
marks = marks.filter(function (qmark) pattern.test(qmark));
- dactyl.assert(marks.length >= 0, "E283: No QuickMarks matching " + filter.quote());
+ dactyl.assert(marks.length >= 0, _("quickmark.noMatching", filter.quote()));
}
commandline.commandOutput(template.tabular(["QuickMark", "URL"], [],
@@ -124,8 +124,8 @@ var QuickMarks = Module("quickmarks", {
function (args) {
// TODO: finish arg parsing - we really need a proper way to do this. :)
// assert(args.bang ^ args[0])
- dactyl.assert( args.bang || args[0], "E471: Argument required");
- dactyl.assert(!args.bang || !args[0], "E474: Invalid argument");
+ dactyl.assert( args.bang || args[0], _("error.argumentRequired"));
+ dactyl.assert(!args.bang || !args[0], _("error.invalidArgument"));
if (args.bang)
quickmarks.removeAll();
@@ -142,7 +142,7 @@ var QuickMarks = Module("quickmarks", {
"Mark a URL with a letter for quick access",
function (args) {
dactyl.assert(/^[a-zA-Z0-9]$/.test(args[0]),
- "E191: Argument must be an ASCII letter or digit");
+ _("quickmark.invalid"));
if (!args[1])
quickmarks.add(args[0], buffer.uri.spec);
else
@@ -197,7 +197,7 @@ var QuickMarks = Module("quickmarks", {
mappings.add(myModes,
["M"], "Add new QuickMark for current URL",
function ({ arg }) {
- dactyl.assert(/^[a-zA-Z0-9]$/.test(arg), "E191: Argument must be an ASCII letter or digit");
+ dactyl.assert(/^[a-zA-Z0-9]$/.test(arg), _("quickmark.invalid"));
quickmarks.add(arg, buffer.uri.spec);
},
{ arg: true });
diff --git a/common/content/tabs.js b/common/content/tabs.js
index 6e0c8a6f..6426c749 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -409,7 +409,7 @@ var Tabs = Module("tabs", {
*/
selectAlternateTab: function () {
dactyl.assert(tabs.alternate != null && tabs.getTab() != tabs.alternate,
- "E23: No alternate page");
+ _("buffer.noAlternate"));
tabs.select(tabs.alternate);
},
@@ -476,9 +476,9 @@ var Tabs = Module("tabs", {
matches = completion.runCompleter("buffer", buffer).map(function (obj) obj.tab);
if (matches.length == 0)
- dactyl.echoerr("E94: No matching buffer for " + buffer);
+ dactyl.echoerr(_("buffer.noMatching", buffer));
else if (matches.length > 1 && !allowNonUnique)
- dactyl.echoerr("E93: More than one match for " + buffer);
+ dactyl.echoerr(_("buffer.multipleMatching", buffer));
else {
let start = matches.indexOf(tabs.getTab());
if (start == -1 && reverse)
@@ -565,9 +565,9 @@ var Tabs = Module("tabs", {
}
if (removed > 0)
- dactyl.echomsg(removed + " fewer tab(s)", 9);
+ dactyl.echomsg(_("buffer.fewer", removed, removed == 1 ? "" : "s"), 9);
else
- dactyl.echoerr("E94: No matching tab for " + arg);
+ dactyl.echoerr(_("buffer.noMatching", arg));
}
else // just remove the current tab
tabs.remove(tabs.getTab(), Math.max(count, 1), special);
@@ -644,7 +644,7 @@ var Tabs = Module("tabs", {
if (/^\d+$/.test(arg))
tabs.select("-" + arg, true);
else
- dactyl.echoerr("E488: Trailing characters");
+ dactyl.echoerr(_("error.trailing"));
}
else if (count > 0)
tabs.select("-" + count, true);
@@ -667,7 +667,7 @@ var Tabs = Module("tabs", {
// count is ignored if an arg is specified, as per Vim
if (arg) {
- dactyl.assert(/^\d+$/.test(arg), "E488: Trailing characters");
+ dactyl.assert(/^\d+$/.test(arg), _("error.trailing"));
index = arg - 1;
}
else
@@ -736,7 +736,7 @@ var Tabs = Module("tabs", {
// FIXME: tabmove! N should probably produce an error
dactyl.assert(!arg || /^([+-]?\d+)$/.test(arg),
- "E488: Trailing characters");
+ _("error.trailing"));
// if not specified, move to after the last tab
tabs.move(config.tabbrowser.mCurrentTab, arg || "$", args.bang);
@@ -764,11 +764,7 @@ var Tabs = Module("tabs", {
commands.add(["tabde[tach]"],
"Detach current tab to its own window",
- function () {
- dactyl.assert(tabs.count > 1, "Can't detach the last tab");
-
- tabs.detachTab(null);
- },
+ function () { tabs.detachTab(null); },
{ argCount: "0" });
commands.add(["tabdu[plicate]"],
@@ -795,13 +791,13 @@ var Tabs = Module("tabs", {
"Attach the current tab to another window",
function (args) {
dactyl.assert(args.length <= 2 && !args.some(function (i) !/^\d+$/.test(i)),
- "E488: Trailing characters");
+ _("error.trailing"));
let [winIndex, tabIndex] = args.map(parseInt);
let win = dactyl.windows[winIndex - 1];
- dactyl.assert(win, "Window " + winIndex + " does not exist");
- dactyl.assert(win != window, "Can't reattach to the same window");
+ dactyl.assert(win, _("window.noIndex", winIndex));
+ dactyl.assert(win != window, _("window.cantAttachSame"));
let browser = win.getBrowser();
let dummy = browser.addTab("about:blank");
@@ -846,7 +842,7 @@ var Tabs = Module("tabs", {
return;
}
- dactyl.echoerr("Exxx: No matching closed tab");
+ dactyl.echoerr(_("buffer.noClosed"));
}
}, {
argCount: "?",
diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties
new file mode 100644
index 00000000..25a0fb0c
--- /dev/null
+++ b/common/locale/en-US/messages.properties
@@ -0,0 +1,107 @@
+abbrev.noSuch = No such abbreviation
+abbrev.none = No abbreviations found
+
+autocmd.executing- = Executing %S Auto commands for %S
+autocmd.autocommand- = autocommand %S
+autocmd.noMatching = No matching autocommands
+autocmd.noGroup- = 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.none = No bookmarks set
+bookmark.cantAdd- = Could not add bookmark %S
+bookmark.allGone = All bookmarks deleted
+
+buffer.fewer- = %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.noClosed = No matching closed tab
+buffer.noAlternate = No alternate page
+
+dactyl.parsingCommandLine = Parsing command line options: %S
+
+dialog.notAvailable = Dialog %S not available
+
+editor.noEditor = No editor specified
+
+emenu.notFound = Menu not found: %S
+
+event.error = 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
+
+hints.noMatcher = Invalid hintmatching type: %S
+
+history.noMatching- = 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.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.loadWaiting = Waiting for page to load...
+macro.noSuch- = Macro '%S' not set
+macro.noPrevious = No previous macro
+macro.invalid- = 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
+
+mark.none = No marks set
+mark.invalid = Invalid mark
+mark.unset- = Mark not set: %S
+mark.noMatching = E283: No marks matching %S
+
+mow.noPreviousOutput = No previous command output
+
+plugin.searchingFor = Searching for %S
+plugin.searchingForIn = Searching for %S in %S
+
+print.toFile = Printing to file: %S
+print.sending = Sending to printer...
+print.sent = Print job sent.
+print.printed = Printed: %S
+
+quickmark.none = No QuickMarks set
+quickmark.noMatching = No QuickMarks matching %S
+quickmark.notSet = QuickMark not set
+quickmark.invalid = Argument must be an ASCII letter or digit
+
+save.invalidDestination = Invalid destination: %S
+
+status.link- = Link: %S
+
+time.total = Total time: %S
+
+window.cantAttachSame = Can't reattach to the same window
+window.noIndex = Window %S does not exist
+
+zoom.outOfRange = 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.interrupted = Interrupted
+error.invalidSort- = Invalid sort order: %S
+error.argRequired = Argument required
+
+error.trailing = Trailing characters
+error.invalidArgument = Invalid argument
+error.invalidArgument- = Invalid argument: %S
+error.argumentRequired = Argument required
+error.argumentOrBang = Argument or ! required
+
+# vim:se ft=jproperties tw=0:
diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm
new file mode 100644
index 00000000..836bc0fd
--- /dev/null
+++ b/common/modules/messages.jsm
@@ -0,0 +1,73 @@
+// Copyright (c) 2011 by Kris Maglione <maglione.k@gmail.com>
+//
+// This work is licensed for reuse under an MIT license. Details are
+// given in the LICENSE.txt file included with this file.
+"use strict";
+
+try {
+
+Components.utils.import("resource://dactyl/bootstrap.jsm");
+defineModule("messages", {
+ exports: ["Messages", "messages", "_"],
+ require: ["services", "util"]
+}, this);
+
+// TODO: Lazy instantiation
+var Messages = Module("messages", {
+
+ init: function init() {
+ let self = this;
+
+ this.bundle = services.stringBundle.createBundle(JSMLoader.getTarget("dactyl://locale/messages.properties"));
+
+ 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] = {
+ __noSuchMethod__: function __(prop, args) self._.apply(self, [prop].concat(args))
+ };
+ }
+ },
+
+ cleanup: function cleanup() {
+ 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) {
+ return arguments.length > 1 ? default_ : value;
+ }
+ },
+
+ format: function format(value, args, default_) {
+ try {
+ return this.bundle.formatStringFromName(value, args, args.length);
+ }
+ catch (e) {
+ return arguments.length > 2 ? default_ : value;
+ }
+ }
+
+}, {
+}, {
+});
+
+var { _ } = messages.closure;
+
+endModule();
+
+} catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
+
+// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm
index 518dbc29..368dfbfa 100644
--- a/common/modules/overlay.jsm
+++ b/common/modules/overlay.jsm
@@ -163,6 +163,7 @@ var Overlay = Module("Overlay", {
"highlight",
"io",
"javascript",
+ "messages",
"options",
"overlay",
"prefs",