diff options
Merge tag 'v4.5.5'
# Conflicts:
# app/_locales/ja/messages.json
# package-lock.json
messages.jsonのローカライズ
Diffstat (limited to 'ui/app/metamask-connect.js')
-rw-r--r-- | ui/app/metamask-connect.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ui/app/metamask-connect.js b/ui/app/metamask-connect.js new file mode 100644 index 000000000..8da594635 --- /dev/null +++ b/ui/app/metamask-connect.js @@ -0,0 +1,27 @@ +const connect = require('react-redux').connect +const t = require('../i18n-helper').getMessage + +const metamaskConnect = (mapStateToProps, mapDispatchToProps) => { + return connect( + _higherOrderMapStateToProps(mapStateToProps), + mapDispatchToProps + ) +} + +const _higherOrderMapStateToProps = (mapStateToProps) => { + let _t + let currentLocale + return (state, ownProps = {}) => { + const stateProps = mapStateToProps + ? mapStateToProps(state, ownProps) + : ownProps + if (currentLocale !== state.metamask.currentLocale) { + currentLocale = state.metamask.currentLocale + _t = t.bind(null, state.localeMessages) + } + stateProps.t = _t + return stateProps + } +} + +module.exports = metamaskConnect
\ No newline at end of file |