aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2019-05-07 01:34:16 +0800
committerDan J Miller <danjm.com@gmail.com>2019-05-07 01:34:16 +0800
commita58e549c3f6513d60b3b995598af14df7871546c (patch)
tree0237283d5dd93f7c5c5d3b688ac77e8d2b6974f0 /ui
parent64ae8131de78b2ac9198ced9e573bb4944a1f653 (diff)
downloadtangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.tar
tangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.tar.gz
tangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.tar.bz2
tangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.tar.lz
tangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.tar.xz
tangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.tar.zst
tangerine-wallet-browser-a58e549c3f6513d60b3b995598af14df7871546c.zip
Skip null and undefined keys when translating via context (#6543)
* i18n: Don't translate null or undefined keys * Add JSDoc for I18nProvider#t context fn
Diffstat (limited to 'ui')
-rw-r--r--ui/app/helpers/higher-order-components/i18n-provider.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/ui/app/helpers/higher-order-components/i18n-provider.js b/ui/app/helpers/higher-order-components/i18n-provider.js
index 298a12a28..5a6650147 100644
--- a/ui/app/helpers/higher-order-components/i18n-provider.js
+++ b/ui/app/helpers/higher-order-components/i18n-provider.js
@@ -15,7 +15,17 @@ class I18nProvider extends Component {
const { localeMessages } = this.props
const { current, en } = localeMessages
return {
+ /**
+ * Returns a localized message for the given key
+ * @param {string} key The message key
+ * @param {string[]} args A list of message substitution replacements
+ * @return {string|undefined|null} The localized message if available
+ */
t (key, ...args) {
+ if (key === undefined || key === null) {
+ return key
+ }
+
return t(current, key, ...args) || t(en, key, ...args) || `[${key}]`
},
tOrDefault: this.tOrDefault,