1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle i18n properly when key is a valid sub-identifier

Fixes #2028
The i18n library will, be default, return a string containing
an error message about the key resolving to an object. We cannot
distinguish that string from others to handle ourselves.

The `returnObjectTrees` option will cause it to return the object
rather than error. We can then test for that and return the original
key if the object is returned - which is the desired result.
This commit is contained in:
Nick O'Leary 2019-01-17 14:42:16 +00:00
parent bb73e30909
commit 5b2f24f842
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -30,12 +30,18 @@ RED.i18n = (function() {
defaultNs: "editor" defaultNs: "editor"
}, },
fallbackLng: ['en-US'], fallbackLng: ['en-US'],
useCookie: false useCookie: false,
returnObjectTrees: true
},function() { },function() {
done(); done();
}); });
RED["_"] = function() { RED["_"] = function() {
return i18n.t.apply(null,arguments); var v = i18n.t.apply(null,arguments);
if (typeof v === 'string') {
return v;
} else {
return arguments[0];
}
} }
}, },