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
1 changed files with 8 additions and 2 deletions

View File

@ -30,12 +30,18 @@ RED.i18n = (function() {
defaultNs: "editor"
},
fallbackLng: ['en-US'],
useCookie: false
useCookie: false,
returnObjectTrees: true
},function() {
done();
});
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];
}
}
},