From 5b2f24f84233c6674e5fd7fbf801b837e0b9bdd1 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 17 Jan 2019 14:42:16 +0000 Subject: [PATCH] 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. --- .../@node-red/editor-client/src/js/i18n.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/i18n.js b/packages/node_modules/@node-red/editor-client/src/js/i18n.js index 9e9695163..a2b962246 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/i18n.js +++ b/packages/node_modules/@node-red/editor-client/src/js/i18n.js @@ -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]; + } } },