summaryrefslogtreecommitdiff
path: root/common/modules/messages.jsm
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-03-02 02:59:04 -0500
committerKris Maglione <maglione.k@gmail.com>2011-03-02 02:59:04 -0500
commite032a82d621c49ae2b733818165508392d27669c (patch)
treeeed258d3016972128be26846404ac9e18c2ce4b1 /common/modules/messages.jsm
parent28d1c1bcade5d1cff91bafc32f5b9a28b32a3fcd (diff)
downloadpentadactyl-e032a82d621c49ae2b733818165508392d27669c.tar.gz
Move some more strings to messages.properties and report (but don't throw) an error for unknown strings.
Diffstat (limited to 'common/modules/messages.jsm')
-rw-r--r--common/modules/messages.jsm24
1 files changed, 15 insertions, 9 deletions
diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm
index 836bc0fd..f8f079a1 100644
--- a/common/modules/messages.jsm
+++ b/common/modules/messages.jsm
@@ -20,11 +20,19 @@ var Messages = Module("messages", {
this.bundle = services.stringBundle.createBundle(JSMLoader.getTarget("dactyl://locale/messages.properties"));
+ this._ = function _(message) {
+ if (arguments.length > 1) {
+ let args = Array.slice(arguments, 1);
+ return this.format(message + "-" + args.length, args, null) || this.format(message, args);
+ }
+ return this.get(message);
+ };
+
let seen = {};
for (let prop in iter(this.bundle.getSimpleEnumeration())) {
let key = prop.QueryInterface(Ci.nsIPropertyElement).key.split(".")[0];
if (!set.add(seen, key))
- this[key] = {
+ this._[key] = this[key] = {
__noSuchMethod__: function __(prop, args) self._.apply(self, [prop].concat(args))
};
}
@@ -34,19 +42,14 @@ var Messages = Module("messages", {
services.stringBundle.flushBundles();
},
- _: function _(message) {
- if (arguments.length > 1) {
- let args = Array.slice(arguments, 1);
- return this.format(message + "-", args, null) || this.format(message, args);
- }
- return this.get(message);
- },
-
get: function get(value, default_) {
try {
return this.bundle.GetStringFromName(value);
}
catch (e) {
+ // Report error so tests fail, but don't throw
+ if (arguments.length < 2)
+ util.reportError(Error("Invalid locale string: " + value + ": " + e));
return arguments.length > 1 ? default_ : value;
}
},
@@ -56,6 +59,9 @@ var Messages = Module("messages", {
return this.bundle.formatStringFromName(value, args, args.length);
}
catch (e) {
+ // Report error so tests fail, but don't throw
+ if (arguments.length < 3)
+ util.reportError(Error("Invalid locale string: " + value + ": " + e));
return arguments.length > 2 ? default_ : value;
}
}