From 624523168fcafe2cb0975f3d4658c07b73cbc765 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 23 Mar 2020 11:54:57 -0300 Subject: [PATCH] Remove fallback for missing localized messages (#8212) The translation helper function we use everywhere (`t`) would fallback to the message `[${key}]` for any key not found in the set of localized messages. Instead it how returns `undefined` in that case. `[${key}]` isn't something you'd typically want to show to users, so this fallback wasn't overly useful in practice. At best it served to hide errors. The falsey return value in the case where the message is missing makes it easier to implement a fallback for that case. Such a fallback is used in the `confirm-transaction-base` component, to restore the fallback behavior accidentally changed in #8211 --- ui/app/helpers/higher-order-components/i18n-provider.js | 2 +- .../confirm-transaction-base.component.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/app/helpers/higher-order-components/i18n-provider.js b/ui/app/helpers/higher-order-components/i18n-provider.js index 7a4df814d..bf61ed292 100644 --- a/ui/app/helpers/higher-order-components/i18n-provider.js +++ b/ui/app/helpers/higher-order-components/i18n-provider.js @@ -15,7 +15,7 @@ class I18nProvider extends Component { * @returns {string|undefined|null} - The localized message if available */ t (key, ...args) { - return getMessage(currentLocale, current, key, ...args) || getMessage(currentLocale, en, key, ...args) || `[${key}]` + return getMessage(currentLocale, current, key, ...args) || getMessage(currentLocale, en, key, ...args) }, } } diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js index 754c23b9b..e7217128f 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -661,9 +661,11 @@ export default class ConfirmTransactionBase extends Component { let functionType = getMethodName(name) if (!functionType) { - functionType = transactionCategory - ? t(transactionCategory) - : t('contractInteraction') + if (transactionCategory) { + functionType = t(transactionCategory) || transactionCategory + } else { + functionType = t('contractInteraction') + } } return (