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
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent c167fbf903
commit 624523168f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ui/app/helpers/higher-order-components/i18n-provider.js
  2. 8
      ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js

@ -15,7 +15,7 @@ class I18nProvider extends Component {
* @returns {string|undefined|null} - The localized message if available * @returns {string|undefined|null} - The localized message if available
*/ */
t (key, ...args) { 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)
}, },
} }
} }

@ -661,9 +661,11 @@ export default class ConfirmTransactionBase extends Component {
let functionType = getMethodName(name) let functionType = getMethodName(name)
if (!functionType) { if (!functionType) {
functionType = transactionCategory if (transactionCategory) {
? t(transactionCategory) functionType = t(transactionCategory) || transactionCategory
: t('contractInteraction') } else {
functionType = t('contractInteraction')
}
} }
return ( return (

Loading…
Cancel
Save