From 5fe0be722b6514692a68e920ee8058c5d572237d Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 15 Mar 2018 21:59:45 -0230 Subject: Handle i18n with redux. --- ui/app/components/notice.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/app/components/notice.js') diff --git a/ui/app/components/notice.js b/ui/app/components/notice.js index 8b0ce1e8b..ffc5ec6f1 100644 --- a/ui/app/components/notice.js +++ b/ui/app/components/notice.js @@ -4,7 +4,7 @@ const h = require('react-hyperscript') const ReactMarkdown = require('react-markdown') const linker = require('extension-link-enabler') const findDOMNode = require('react-dom').findDOMNode -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = Notice @@ -111,7 +111,7 @@ Notice.prototype.render = function () { style: { marginTop: '18px', }, - }, t('accept')), + }, t(this.props.localeMessages, 'accept')), ]) ) } -- cgit From d24a0590d363dbe88d383c8faec8eb28809242f0 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 22:11:47 -0230 Subject: i18n redux solution doesn't require importing t() and passing state to each t() call; t is just available on props. --- ui/app/components/notice.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui/app/components/notice.js') diff --git a/ui/app/components/notice.js b/ui/app/components/notice.js index ffc5ec6f1..a999ffd88 100644 --- a/ui/app/components/notice.js +++ b/ui/app/components/notice.js @@ -4,9 +4,9 @@ const h = require('react-hyperscript') const ReactMarkdown = require('react-markdown') const linker = require('extension-link-enabler') const findDOMNode = require('react-dom').findDOMNode -const t = require('../../i18n-helper').getMessage +const connect = require('../metamask-connect') -module.exports = Notice +module.exports = connect()(Notice) inherits(Notice, Component) function Notice () { @@ -111,7 +111,7 @@ Notice.prototype.render = function () { style: { marginTop: '18px', }, - }, t(this.props.localeMessages, 'accept')), + }, this.props.t('accept')), ]) ) } -- cgit From 0a711f0de0e342b24988a5da4ca5c64342153210 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 29 Mar 2018 12:30:44 -0230 Subject: Removes t from props via metamask-connect and instead places it on context via a provider. --- ui/app/components/notice.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ui/app/components/notice.js') diff --git a/ui/app/components/notice.js b/ui/app/components/notice.js index a999ffd88..bb7e0814c 100644 --- a/ui/app/components/notice.js +++ b/ui/app/components/notice.js @@ -1,13 +1,19 @@ const inherits = require('util').inherits const Component = require('react').Component +const PropTypes = require('prop-types') const h = require('react-hyperscript') const ReactMarkdown = require('react-markdown') const linker = require('extension-link-enabler') const findDOMNode = require('react-dom').findDOMNode -const connect = require('../metamask-connect') +const connect = require('react-redux').connect + +Notice.contextTypes = { + t: PropTypes.func, +} module.exports = connect()(Notice) + inherits(Notice, Component) function Notice () { Component.call(this) @@ -111,7 +117,7 @@ Notice.prototype.render = function () { style: { marginTop: '18px', }, - }, this.props.t('accept')), + }, this.context.t('accept')), ]) ) } -- cgit