diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-08-01 10:21:25 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:44:44 +0800 |
commit | 01f00a9ca6807dd019a68bf2be8d99cee67a2738 (patch) | |
tree | 4d2d8258595f6b36753a10651e0918a9e9486bb6 | |
parent | 176fb89771f7e37f8bd1c847d44183d6143e7bd9 (diff) | |
download | tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.tar tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.tar.gz tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.tar.bz2 tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.tar.lz tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.tar.xz tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.tar.zst tangerine-wallet-browser-01f00a9ca6807dd019a68bf2be8d99cee67a2738.zip |
Add tOrKey function to I18nProvider
-rw-r--r-- | ui/app/i18n-provider.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ui/app/i18n-provider.js b/ui/app/i18n-provider.js index 936b185f7..3419474c4 100644 --- a/ui/app/i18n-provider.js +++ b/ui/app/i18n-provider.js @@ -6,6 +6,11 @@ const { compose } = require('recompose') const t = require('../i18n-helper').getMessage class I18nProvider extends Component { + tOrDefault = (key, defaultValue, ...args) => { + const { localeMessages: { current, en } = {} } = this.props + return t(current, key, ...args) || t(en, key, ...args) || defaultValue + } + getChildContext () { const { localeMessages } = this.props const { current, en } = localeMessages @@ -13,8 +18,9 @@ class I18nProvider extends Component { t (key, ...args) { return t(current, key, ...args) || t(en, key, ...args) || `[${key}]` }, - tOrDefault (key, ...args) { - return t(current, key, ...args) || t(en, key, ...args) || key + tOrDefault: this.tOrDefault, + tOrKey (key, ...args) { + return this.tOrDefault(key, key, ...args) }, } } @@ -32,6 +38,7 @@ I18nProvider.propTypes = { I18nProvider.childContextTypes = { t: PropTypes.func, tOrDefault: PropTypes.func, + tOrKey: PropTypes.func, } const mapStateToProps = state => { |