1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-09 22:35:46 +01:00

Move some more message strings to the properties file.

This commit is contained in:
Doug Kearns
2011-03-06 03:15:01 +11:00
parent 87a756718d
commit cae269fd32
13 changed files with 85 additions and 54 deletions

View File

@@ -53,7 +53,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
this.remaining = addons;
this.upgrade = [];
this.dactyl.echomsg("Checking updates for addons: " + addons.map(function (a) a.name).join(", "));
this.dactyl.echomsg(_("addon.check", addons.map(function (a) a.name).join(", ")));
for (let addon in values(addons))
addon.findUpdates(this, AddonManager.UPDATE_WHEN_USER_REQUESTED, null, null);
@@ -391,9 +391,9 @@ var Addons = Module("addons", {
else if (file.isReadable() && file.isFile())
AddonManager.getInstallForFile(file, install, "application/x-xpinstall");
else if (file.isDirectory())
dactyl.echoerr("Cannot install a directory: " + file.path.quote());
dactyl.echoerr(_("addon.cantInstallDir", file.path.quote()));
else
dactyl.echoerr("E484: Can't open file " + file.path);
dactyl.echoerr(_("io.notReadable-1", file.path));
}, {
argCount: "1",
completer: function (context) {

View File

@@ -164,9 +164,9 @@ var Command = Class("Command", {
modifiers = modifiers || {};
if (args.count != null && !this.count)
throw FailedAssertion("E481: No range allowed");
throw FailedAssertion(_("command.noRange"));
if (args.bang && !this.bang)
throw FailedAssertion("E477: No ! allowed");
throw FailedAssertion(_("command.noBang"));
return !dactyl.trapErrors(function exec() {
let extra = this.hive.argsExtra(args);
@@ -635,7 +635,7 @@ var Commands = Module("commands", {
}
if (!this.userHives.some(function (h) h._list.length))
dactyl.echomsg("No user-defined commands found");
dactyl.echomsg(_("command.none"));
else
commandline.commandOutput(
<table>
@@ -1396,7 +1396,7 @@ var Commands = Module("commands", {
}
catch (e) {
dactyl.echo(":" + this.name + " ...");
dactyl.echoerr("E117: Unknown function: " + completer);
dactyl.echoerr(_("command.unknownCompleter", completer));
dactyl.log(e);
return undefined;
}
@@ -1433,7 +1433,7 @@ var Commands = Module("commands", {
}, args.bang);
if (!added)
dactyl.echoerr("E174: Command already exists: add ! to replace it");
dactyl.echoerr(_("command.exists"));
}
}, {
bang: true,
@@ -1598,7 +1598,7 @@ var Commands = Module("commands", {
dactyl.execute(commands.repeat);
}
else
dactyl.echoerr("E30: No previous command line");
dactyl.echoerr(_("command.noPrevious"));
},
{ count: true });
}

View File

@@ -7,7 +7,7 @@
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("finder", {
exports: ["RangeFind", "RangeFinder", "rangefinder"],
use: ["services", "util"]
use: ["messages", "services", "util"]
}, this);
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
@@ -93,7 +93,7 @@ var RangeFinder = Module("rangefinder", {
find: function (pattern, backwards) {
let str = this.bootstrap(pattern, backwards);
if (!this.rangeFind.find(str))
this.dactyl.echoerr("E486: Pattern not found: " + pattern,
this.dactyl.echoerr(_("finder.notFound", pattern),
this.commandline.FORCE_SINGLELINE);
return this.rangeFind.found;
@@ -103,11 +103,11 @@ var RangeFinder = Module("rangefinder", {
if (!this.rangeFind)
this.find(this.lastFindPattern);
else if (!this.rangeFind.find(null, reverse))
this.dactyl.echoerr("E486: Pattern not found: " + this.lastFindPattern,
this.dactyl.echoerr(_("finder.notFound", this.lastFindPattern),
this.commandline.FORCE_SINGLELINE);
else if (this.rangeFind.wrapped) {
let msg = this.rangeFind.backward ? "find hit TOP, continuing at BOTTOM"
: "find hit BOTTOM, continuing at TOP";
let msg = this.rangeFind.backward ? _("finder.atTop")
: _("finder.atBottom");
this.commandline.echo(msg, "WarningMsg", this.commandline.APPEND_TO_MESSAGES
| this.commandline.FORCE_SINGLELINE);
}

View File

@@ -158,7 +158,7 @@ var IO = Module("io", {
if (!file.exists() || !file.isReadable() || file.isDirectory()) {
if (!params.silent)
dactyl.echoerr("E484: Can't open file " + filename.quote());
dactyl.echoerr(_("io.notReadable", filename.quote()));
return;
}
@@ -430,7 +430,7 @@ var IO = Module("io", {
let file = this.pathSearch(program);
if (!file || !file.exists()) {
util.dactyl.echoerr("Command not found: " + program);
util.dactyl.echoerr(_("io.noCommand", program));
if (callable(blocking))
util.trapErrors(blocking);
return -1;
@@ -586,8 +586,8 @@ var IO = Module("io", {
}
}
dactyl.echoerr("E344: Can't find directory " + arg.quote() + " in cdpath");
dactyl.echoerr("E472: Command failed");
dactyl.echoerr(_("io.noSuchDir", arg.quote()));
dactyl.echoerr(_("io.commandFailed"));
}
}, {
argCount: "?",
@@ -603,12 +603,11 @@ var IO = Module("io", {
commands.add([config.name.replace(/(.)(.*)/, "mk$1[$2rc]")],
"Write current key mappings and changed options to the config file",
function (args) {
dactyl.assert(args.length <= 1, "E172: Only one file name allowed");
dactyl.assert(args.length <= 1, _("io.oneFileAllowed"));
let file = io.File(args[0] || io.getRCFile(null, true));
dactyl.assert(!file.exists() || args.bang,
"E189: " + file.path.quote() + " exists (add ! to override)");
dactyl.assert(!file.exists() || args.bang, _("io.exists", file.path.quote()));
// TODO: Use a set/specifiable list here:
let lines = [cmd.serialize().map(commands.commandToString, cmd) for (cmd in commands.iterator(true)) if (cmd.serialize)];
@@ -621,7 +620,7 @@ var IO = Module("io", {
file.write(lines.join("\n"));
}
catch (e) {
dactyl.echoerr("E190: Cannot open " + file.path.quote() + " for writing");
dactyl.echoerr(_("io.notWriteable"), file.path.quote());
dactyl.log("Could not write to " + file.path + ": " + e.message); // XXX
}
}, {
@@ -793,7 +792,7 @@ unlet s:cpo_save
"Read Ex commands from a file",
function (args) {
if (args.length > 1)
dactyl.echoerr("E172: Only one file name allowed");
dactyl.echoerr(_("io.oneFileAllowed"));
else
io.source(args[0], { silent: args.bang });
}, {

View File

@@ -237,8 +237,8 @@ var Option = Class("Option", {
*/
isValidValue: function isValidValue(values) this.validator(values),
invalidArgument: function invalidArgument(arg, op) "E474: Invalid argument: " +
this.name + (op || "").replace(/=?$/, "=") + arg,
invalidArgument: function invalidArgument(arg, op) _("error.invalidArgument",
this.name + (op || "").replace(/=?$/, "=") + arg),
/**
* Resets the option to its default value.
@@ -1066,7 +1066,7 @@ var Options = Module("options", {
else {
flushList();
if (opt.option.type === "boolean") {
util.assert(!opt.valueGiven, "E474: Invalid argument: " + arg);
util.assert(!opt.valueGiven, _("error.invalidArgument", arg));
opt.values = !opt.unsetBoolean;
}
else if (/^(string|number)$/.test(opt.option.type) && opt.invert)
@@ -1192,7 +1192,7 @@ var Options = Module("options", {
}
</table>;
if (str.text().length() == str.*.length())
dactyl.echomsg("No variables found");
dactyl.echomsg(_("variable.none"));
else
dactyl.echo(str, commandline.FORCE_MULTILINE);
return;
@@ -1204,9 +1204,9 @@ var Options = Module("options", {
let fullName = (scope || "") + name;
util.assert(scope == "g:" || scope == null,
"E461: Illegal variable name: " + scope + name);
_("command.let.illegalVar", scope + name));
util.assert(set.has(globalVariables, name) || (expr && !op),
"E121: Undefined variable: " + fullName);
_("command.let.undefinedVar", fullName));
if (!expr)
dactyl.echo(fullName + "\t\t" + fmt(globalVariables[name]));
@@ -1216,7 +1216,7 @@ var Options = Module("options", {
}
catch (e) {}
util.assert(newValue !== undefined,
"E15: Invalid expression: " + expr);
_("command.let.invalidExpression", expr));
let value = newValue;
if (op) {
@@ -1232,7 +1232,7 @@ var Options = Module("options", {
}
}
else
dactyl.echoerr("E18: Unexpected characters in :let");
dactyl.echoerr(_("command.let.unexpectedChar"));
},
{
deprecated: "the options system",
@@ -1305,7 +1305,7 @@ var Options = Module("options", {
name = name.replace(/^g:/, ""); // throw away the scope prefix
if (!set.has(dactyl._globalVariables, name)) {
if (!args.bang)
dactyl.echoerr("E108: No such variable: " + name);
dactyl.echoerr(_("command.let.noSuch", name));
return;
}

View File

@@ -12,7 +12,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("prefs", {
exports: ["Prefs", "localPrefs", "prefs"],
require: ["services", "util"],
use: ["config", "template"]
use: ["config", "messages", "template"]
}, this);
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
@@ -221,7 +221,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
util.assert(type === Ci.nsIPrefBranch.PREF_INVALID || type === needType,
type === Ci.nsIPrefBranch.PREF_INT
? "E521: Number required after =: " + name + "=" + value
: "E474: Invalid argument: " + name + "=" + value);
: _("error.invalidArgument", name + "=" + value));
let type = this.branch.getPrefType(name);
switch (typeof value) {
@@ -289,7 +289,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
*/
toggle: function (name) {
util.assert(this.branch.getPrefType(name) === Ci.nsIPrefBranch.PREF_BOOL,
"E488: Trailing characters: " + name + "!");
_("error.trailing", name + "!"));
this.set(name, !this.get(name));
},

View File

@@ -17,7 +17,8 @@ try {
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("sanitizer", {
exports: ["Range", "Sanitizer", "sanitizer"],
require: ["prefs", "services", "storage", "template", "util"]
require: ["prefs", "services", "storage", "template", "util"],
use: ["messages"]
}, this);
let tmp = {};
@@ -389,7 +390,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
}, window);
},
commands: function (dactyl, modules, window) {
const commands = modules.commands;
const { commands } = modules;
commands.add(["sa[nitize]"],
"Clear private data",
function (args) {
@@ -408,7 +409,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
args[0] = "all";
if (args.bang) {
dactyl.assert(args.length == 0, "E488: Trailing characters");
dactyl.assert(args.length == 0, _("error.trailing"));
items = Object.keys(sanitizer.itemMap).filter(
function (k) modules.options.get("sanitizeitems").has(k));
}
@@ -509,7 +510,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
for (c in Sanitizer.iterCookies(host)))));
return;
default:
util.assert(cmd in Sanitizer.PERMS, "Invalid argument");
util.assert(cmd in Sanitizer.PERMS, _("error.invalidArgument"));
setPerms(host, cmd);
}
}, {

View File

@@ -337,7 +337,7 @@ var Styles = Module("Styles", {
// TODO: Move this to an ItemList to show this automatically
if (list.*.length() === list.text().length() + 2)
dactyl.echomsg("No mapping found");
dactyl.echomsg(_("style.none"));
else
commandline.commandOutput(list);
},