diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/helpers/higher-order-components/i18n-provider.js | 10 |
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, |