1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 18:54:12 +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

@@ -475,7 +475,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let res = true;
for (let [command, args] in commands.parseCommands(str.replace(/^'(.*)'$/, "$1"))) {
if (command === null)
throw FailedAssertion("E492: Not a " + config.appName + " command: " + args.commandString);
throw FailedAssertion(_("dactyl.notCommand", config.appName, args.commandString));
res = res && command.execute(args, modifiers);
}

View File

@@ -1,6 +1,12 @@
# TODO: normalise this debacle of Vim legacy messages
# : are we losing the error code prefixes? --djk
abbrev.noSuch = No such abbreviation
abbrev.none = No abbreviations found
addon.check-1 = Checking updates for addons: %S
addon.cantInstallDir-1 = Cannot install a directory: %S
autocmd.executing-2 = Executing %S Auto commands for %S
autocmd.autocommand-1 = autocommand %S
autocmd.noMatching = No matching autocommands
@@ -36,12 +42,24 @@ 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.none = No user-defined commands found
command.unknownCompleter-1 = E117: Unknown function: %S
command.exists = E174: Command already exists: add ! to replace it
command.noPrevious = E30: No previous command line
command.noRange = E481: No range allowed
command.noRange = E477: No ! allowed
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
commmand.let.noSuch-1 = E108: No such variable: %S
command.let.unexpectedChar = E18: Unexpected characters in :let
command.let.illegalVar-1 = E461: Illegal variable name: %S
command.let.undefinedVar-1 = E121: Undefined variable: %S
command.let.invalidExpression-1 = E15: Invalid expression: %S
dactyl.parsingCommandLine-1 = Parsing command line options: %S
dactyl.notCommand-2 = E492: Not a %S command: %S
dialog.notAvailable-1 = Dialog %S not available
@@ -59,6 +77,10 @@ emenu.notFound-1 = Menu not found: %S
event.error-2 = Processing %S event: %S
event.nothingToPass = No events to pass
finder.notFound-1 = E486: Pattern not found: %S
finder.atTop = find hit TOP, continuing at BOTTOM
finder.atBottom = find hit BOTTOM, continuing at TOP
help.dontPanic = E478: Don't panic!
help.noFile-1 = Sorry, help file %S not found
help.noTopic-1 = Sorry, no help for %S
@@ -72,8 +94,12 @@ history.noURL = URL not found in history
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.notWriteable-1 = Can't open file %S for writing
io.exists = File exists (add ! to override)
io.exists-1 = File %S exists (add ! to override)
io.noCommand-1 = Command not found: %S
io.commandFailed = E472: Command failed
io.oneFileAllowed = E172: Only one file name allowed
macro.canceled-1 = Canceled playback of macro '%S'
macro.recorded-1 = Recorded macro '%S'
@@ -115,8 +141,12 @@ save.invalidDestination-1 = Invalid destination: %S
status.link-1 = Link: %S
style.none = No mapping found
time.total = Total time: %S
variable.none = No variables found
window.cantAttachSame = Can't reattach to the same window
window.noIndex-1 = Window %S does not exist
@@ -131,6 +161,7 @@ error.invalidSort-1 = Invalid sort order: %S
error.argRequired = Argument required
error.trailing = Trailing characters
error.trailing-1 = Trailing characters: %S
error.invalid-1 = Invalid %S
error.invalidArgument = Invalid argument
error.invalidArgument-1 = Invalid argument: %S

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);
},

View File

@@ -237,7 +237,7 @@ const Config = Module("config", ConfigBase, {
"Close a display pane",
function (args) {
let arg = args.literalArg;
dactyl.assert(arg in Config.displayPanes, "E475: Invalid argument: " + arg);
dactyl.assert(arg in Config.displayPanes, _("error.invalidArgument", arg));
config.closeDisplayPane(Config.displayPanes[arg]);
},
{
@@ -251,7 +251,7 @@ const Config = Module("config", ConfigBase, {
"Open a display pane",
function (args) {
let arg = args.literalArg;
dactyl.assert(arg in Config.displayPanes, "E475: Invalid argument: " + arg);
dactyl.assert(arg in Config.displayPanes, _("error.invalidArgument", arg));
// TODO: focus when we have better key handling of these extended modes
config.openDisplayPane(Config.displayPanes[arg]);
},

View File

@@ -264,7 +264,7 @@ const Player = Module("player", {
this.focusTrack(searchView.getItemByIndex(this._lastSearchIndex));
}
else
dactyl.echoerr("E486 Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
dactyl.echoerr(_("finder.notFound", searchString), commandline.FORCE_SINGLELINE);
},
/**
@@ -283,7 +283,7 @@ const Player = Module("player", {
if (reverse) {
if (this._lastSearchIndex == 0) {
this._lastSearchIndex = this._lastSearchView.length - 1;
echo("Search hit TOP, continuing at BOTTOM");
echo(_("finder.atTop"));
}
else
this._lastSearchIndex = this._lastSearchIndex - 1;
@@ -291,7 +291,7 @@ const Player = Module("player", {
else {
if (this._lastSearchIndex == (this._lastSearchView.length - 1)) {
this._lastSearchIndex = 0;
echo("Search hit BOTTOM, continuing at TOP");
echo(_("finder.atBottom"));
}
else
this._lastSearchIndex = this._lastSearchIndex + 1;
@@ -504,7 +504,7 @@ const Player = Module("player", {
return;
}
}
dactyl.echoerr("E475: Invalid argument: " + arg);
dactyl.echoerr(_("error.invalidArgument", arg));
}
else {
// load main library if there are no args
@@ -547,7 +547,7 @@ const Player = Module("player", {
// intentionally supports 999:99:99
dactyl.assert(/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg),
"E475: Invalid argument: " + arg);
_("error.invalidArgument", arg));
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
@@ -588,7 +588,7 @@ const Player = Module("player", {
return;
}
}
dactyl.echoerr("E475: Invalid argument: " + arg);
dactyl.echoerr(_("error.invalidArgument", arg));
}
},
{
@@ -659,8 +659,8 @@ const Player = Module("player", {
function (args) {
let arg = args[0];
dactyl.assert(arg, "E471: Argument required");
dactyl.assert(/^[+-]?\d+$/.test(arg), "E488: Trailing characters");
dactyl.assert(arg, _("error.argumentRequired"));
dactyl.assert(/^[+-]?\d+$/.test(arg), _("error.trailing"));
let level = parseInt(arg, 10) / 100;

View File

@@ -695,7 +695,7 @@ const Mail = Module("mail", {
let newPos = mail._getCurrentFolderIndex() + Math.max(1, args.count);
if (newPos >= gFolderTreeView.rowCount) {
newPos = newPos % gFolderTreeView.rowCount;
commandline.echo("search hit BOTTOM, continuing at TOP", commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
commandline.echo(_("finder.atBottom"), commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
}
gFolderTreeView.selection.timedSelect(newPos, 500);
},
@@ -714,7 +714,7 @@ const Mail = Module("mail", {
let newPos = mail._getCurrentFolderIndex() - Math.max(1, args.count);
if (newPos < 0) {
newPos = (newPos % gFolderTreeView.rowCount) + gFolderTreeView.rowCount;
commandline.echo("search hit TOP, continuing at BOTTOM", commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
commandline.echo(_("finder.atTop"), commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
}
gFolderTreeView.selection.timedSelect(newPos, 500);
},