mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
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
This commit is contained in:
parent
64ae8131de
commit
a58e549c3f
@ -15,7 +15,17 @@ class I18nProvider extends Component {
|
|||||||
const { localeMessages } = this.props
|
const { localeMessages } = this.props
|
||||||
const { current, en } = localeMessages
|
const { current, en } = localeMessages
|
||||||
return {
|
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) {
|
t (key, ...args) {
|
||||||
|
if (key === undefined || key === null) {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
return t(current, key, ...args) || t(en, key, ...args) || `[${key}]`
|
return t(current, key, ...args) || t(en, key, ...args) || `[${key}]`
|
||||||
},
|
},
|
||||||
tOrDefault: this.tOrDefault,
|
tOrDefault: this.tOrDefault,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user