1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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
This commit is contained in:
Mark Stacey 2020-03-23 11:54:57 -03:00 committed by GitHub
parent c167fbf903
commit 624523168f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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)
},
}
}

View File

@ -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 (