aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-03-30 00:37:29 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-03-30 00:37:29 +0800
commitef61ef2ce885635862bb242612dd821cb3a65b6b (patch)
tree0f128f8b56b57a1bbe96dcf5743d34b5f95dc4cc /ui
parent58f52b2b8de9efd43896e23ab0ac9972f45bb278 (diff)
parent8766420f19251b95211dd99ff9a45e60cf0177ad (diff)
downloadtangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.gz
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.bz2
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.lz
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.xz
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.tar.zst
tangerine-wallet-browser-ef61ef2ce885635862bb242612dd821cb3a65b6b.zip
Fix i18n merge conflicts
Diffstat (limited to 'ui')
-rw-r--r--ui/app/accounts/new-account/index.js9
-rw-r--r--ui/app/actions.js42
-rw-r--r--ui/app/app.js28
-rw-r--r--ui/app/components/account-dropdowns.js18
-rw-r--r--ui/app/components/account-export.js17
-rw-r--r--ui/app/components/account-menu/index.js17
-rw-r--r--ui/app/components/balance-component.js2
-rw-r--r--ui/app/components/bn-as-decimal-input.js12
-rw-r--r--ui/app/components/buy-button-subview.js17
-rw-r--r--ui/app/components/coinbase-form.js7
-rw-r--r--ui/app/components/copyButton.js6
-rw-r--r--ui/app/components/copyable.js6
-rw-r--r--ui/app/components/customize-gas-modal/index.js23
-rw-r--r--ui/app/components/dropdowns/components/account-dropdowns.js23
-rw-r--r--ui/app/components/dropdowns/network-dropdown.js30
-rw-r--r--ui/app/components/dropdowns/token-menu-dropdown.js6
-rw-r--r--ui/app/components/ens-input.js9
-rw-r--r--ui/app/components/hex-as-decimal-input.js12
-rw-r--r--ui/app/components/identicon.js2
-rw-r--r--ui/app/components/modals/account-details-modal.js7
-rw-r--r--ui/app/components/modals/account-modal-container.js5
-rw-r--r--ui/app/components/modals/buy-options-modal.js17
-rw-r--r--ui/app/components/modals/deposit-ether-modal.js51
-rw-r--r--ui/app/components/modals/edit-account-name-modal.js7
-rw-r--r--ui/app/components/modals/export-private-key-modal.js15
-rw-r--r--ui/app/components/modals/hide-token-confirmation-modal.js11
-rw-r--r--ui/app/components/modals/modal.js9
-rw-r--r--ui/app/components/modals/new-account-modal.js18
-rw-r--r--ui/app/components/modals/notification-modal.js7
-rw-r--r--ui/app/components/modals/notification-modals/confirm-reset-account.js2
-rw-r--r--ui/app/components/modals/shapeshift-deposit-tx-modal.js2
-rw-r--r--ui/app/components/network-display.js6
-rw-r--r--ui/app/components/network.js28
-rw-r--r--ui/app/components/notice.js6
-rw-r--r--ui/app/components/pages/add-token.js58
-rw-r--r--ui/app/components/pages/create-account/import-account/index.js38
-rw-r--r--ui/app/components/pages/create-account/import-account/json.js20
-rw-r--r--ui/app/components/pages/create-account/import-account/private-key.js9
-rw-r--r--ui/app/components/pages/create-account/import-account/seed.js7
-rw-r--r--ui/app/components/pages/create-account/new-account.js12
-rw-r--r--ui/app/components/pages/settings/info.js21
-rw-r--r--ui/app/components/pages/settings/settings.js103
-rw-r--r--ui/app/components/pending-msg-details.js6
-rw-r--r--ui/app/components/pending-msg.js14
-rw-r--r--ui/app/components/pending-tx/confirm-deploy-contract.js32
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js21
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js41
-rw-r--r--ui/app/components/pending-tx/index.js2
-rw-r--r--ui/app/components/qr-code.js2
-rw-r--r--ui/app/components/send/account-list-item.js2
-rw-r--r--ui/app/components/send/gas-fee-display-v2.js8
-rw-r--r--ui/app/components/send/gas-tooltip.js6
-rw-r--r--ui/app/components/send/send-v2-container.js2
-rw-r--r--ui/app/components/send/to-autocomplete.js6
-rw-r--r--ui/app/components/sender-to-recipient.js7
-rw-r--r--ui/app/components/shapeshift-form.js23
-rw-r--r--ui/app/components/shift-list-item.js17
-rw-r--r--ui/app/components/signature-request.js23
-rw-r--r--ui/app/components/token-balance.js2
-rw-r--r--ui/app/components/token-cell.js2
-rw-r--r--ui/app/components/token-list.js9
-rw-r--r--ui/app/components/tx-list-item.js21
-rw-r--r--ui/app/components/tx-list.js9
-rw-r--r--ui/app/components/tx-view.js9
-rw-r--r--ui/app/components/wallet-view.js11
-rw-r--r--ui/app/conf-tx.js2
-rw-r--r--ui/app/css/itcss/components/token-list.scss9
-rw-r--r--ui/app/first-time/init-menu.js21
-rw-r--r--ui/app/keychains/hd/create-vault-complete.js91
-rw-r--r--ui/app/keychains/hd/recover-seed/confirmation.js9
-rw-r--r--ui/app/keychains/hd/restore-vault.js27
-rw-r--r--ui/app/metamask-connect.js27
-rw-r--r--ui/app/new-keychain.js2
-rw-r--r--ui/app/reducers.js7
-rw-r--r--ui/app/reducers/locale.js17
-rw-r--r--ui/app/reducers/metamask.js6
-rw-r--r--ui/app/select-app.js2
-rw-r--r--ui/app/send-v2.js33
-rw-r--r--ui/app/unlock.js11
-rw-r--r--ui/i18n-helper.js45
-rw-r--r--ui/i18n.js33
-rw-r--r--ui/index.js20
82 files changed, 815 insertions, 567 deletions
diff --git a/ui/app/accounts/new-account/index.js b/ui/app/accounts/new-account/index.js
index 854568c77..584016974 100644
--- a/ui/app/accounts/new-account/index.js
+++ b/ui/app/accounts/new-account/index.js
@@ -1,9 +1,8 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
-const t = require('../../../i18n')
const { getCurrentViewContext } = require('../../selectors')
const classnames = require('classnames')
@@ -46,7 +45,7 @@ AccountDetailsModal.prototype.render = function () {
h('div.new-account__header', [
- h('div.new-account__title', t('newAccount')),
+ h('div.new-account__title', this.props.t('newAccount')),
h('div.new-account__tabs', [
@@ -56,7 +55,7 @@ AccountDetailsModal.prototype.render = function () {
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'CREATE',
}),
onClick: () => displayForm('CREATE'),
- }, t('createDen')),
+ }, this.props.t('createDen')),
h('div.new-account__tabs__tab', {
className: classnames('new-account__tabs__tab', {
@@ -64,7 +63,7 @@ AccountDetailsModal.prototype.render = function () {
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'IMPORT',
}),
onClick: () => displayForm('IMPORT'),
- }, t('import')),
+ }, this.props.t('import')),
]),
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 603261c0f..4550237d5 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -2,6 +2,7 @@ const abi = require('human-standard-token-abi')
const getBuyEthUrl = require('../../app/scripts/lib/buy-eth-url')
const { getTokenAddressFromTokenObject } = require('./util')
const ethUtil = require('ethereumjs-util')
+const { fetchLocale } = require('../i18n-helper')
var actions = {
_setBackgroundConnection: _setBackgroundConnection,
@@ -23,7 +24,7 @@ var actions = {
NETWORK_DROPDOWN_CLOSE: 'UI_NETWORK_DROPDOWN_CLOSE',
showNetworkDropdown: showNetworkDropdown,
hideNetworkDropdown: hideNetworkDropdown,
- // menu state
+ // menu state/
getNetworkStatus: 'getNetworkStatus',
// transition state
TRANSITION_FORWARD: 'TRANSITION_FORWARD',
@@ -254,6 +255,13 @@ var actions = {
SET_USE_BLOCKIE: 'SET_USE_BLOCKIE',
setUseBlockie,
+ // locale
+ SET_CURRENT_LOCALE: 'SET_CURRENT_LOCALE',
+ SET_LOCALE_MESSAGES: 'SET_LOCALE_MESSAGES',
+ setCurrentLocale,
+ updateCurrentLocale,
+ setLocaleMessages,
+ //
// Feature Flags
setFeatureFlag,
updateFeatureFlags,
@@ -1865,6 +1873,38 @@ function setUseBlockie (val) {
}
}
+function updateCurrentLocale (key) {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ fetchLocale(key)
+ .then((localeMessages) => {
+ log.debug(`background.setCurrentLocale`)
+ background.setCurrentLocale(key, (err) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ dispatch(actions.setCurrentLocale(key))
+ dispatch(actions.setLocaleMessages(localeMessages))
+ })
+ })
+ }
+}
+
+function setCurrentLocale (key) {
+ return {
+ type: actions.SET_CURRENT_LOCALE,
+ value: key,
+ }
+}
+
+function setLocaleMessages (localeMessages) {
+ return {
+ type: actions.SET_LOCALE_MESSAGES,
+ value: localeMessages,
+ }
+}
+
function setNetworkEndpoints (networkEndpointType) {
return dispatch => {
log.debug('background.setNetworkEndpoints')
diff --git a/ui/app/app.js b/ui/app/app.js
index 2b6d5fc62..719830fda 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -1,12 +1,11 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
-const { connect } = require('react-redux')
+const connect = require('./metamask-connect')
const { Route, Switch, Redirect, withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const h = require('react-hyperscript')
const actions = require('./actions')
const classnames = require('classnames')
-const t = require('../i18n')
// init
const InitializeScreen = require('../../mascara/src/app/first-time').default
@@ -297,7 +296,10 @@ class App extends Component {
}),
// metamask name
- h('h1', 'MetaMask'),
+ h('.flex-row', [
+ h('h1', this.props.t('appName')),
+ h('div.beta-label', this.props.t('beta')),
+ ]),
]),
@@ -602,15 +604,15 @@ class App extends Component {
let name
if (providerName === 'mainnet') {
- name = t('connectingToMainnet')
+ name = this.props.t('connectingToMainnet')
} else if (providerName === 'ropsten') {
- name = t('connectingToRopsten')
+ name = this.props.t('connectingToRopsten')
} else if (providerName === 'kovan') {
- name = t('connectingToRopsten')
+ name = this.props.t('connectingToRopsten')
} else if (providerName === 'rinkeby') {
- name = t('connectingToRinkeby')
+ name = this.props.t('connectingToRinkeby')
} else {
- name = t('connectingToUnknown')
+ name = this.props.t('connectingToUnknown')
}
return name
@@ -623,15 +625,15 @@ class App extends Component {
let name
if (providerName === 'mainnet') {
- name = 'Main Ethereum Network'
+ name = this.props.t('mainnet')
} else if (providerName === 'ropsten') {
- name = 'Ropsten Test Network'
+ name = this.props.t('ropsten')
} else if (providerName === 'kovan') {
- name = 'Kovan Test Network'
+ name = this.props.t('kovan')
} else if (providerName === 'rinkeby') {
- name = 'Rinkeby Test Network'
+ name = this.props.t('rinkeby')
} else {
- name = 'Unknown Private Network'
+ name = this.props.t('unknownNetwork')
}
return name
diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js
index 1612d7b6a..84678fee6 100644
--- a/ui/app/components/account-dropdowns.js
+++ b/ui/app/components/account-dropdowns.js
@@ -3,13 +3,12 @@ const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const actions = require('../actions')
const genAccountLink = require('etherscan-link').createAccountLink
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const Dropdown = require('./dropdown').Dropdown
const DropdownMenuItem = require('./dropdown').DropdownMenuItem
const Identicon = require('./identicon')
const ethUtil = require('ethereumjs-util')
const copyToClipboard = require('copy-to-clipboard')
-const t = require('../../i18n')
class AccountDropdowns extends Component {
constructor (props) {
@@ -80,7 +79,7 @@ class AccountDropdowns extends Component {
try { // Sometimes keyrings aren't loaded yet:
const type = keyring.type
const isLoose = type !== 'HD Key Tree'
- return isLoose ? h('.keyring-label.allcaps', t('loose')) : null
+ return isLoose ? h('.keyring-label.allcaps', this.props.t('loose')) : null
} catch (e) { return }
}
@@ -130,7 +129,7 @@ class AccountDropdowns extends Component {
diameter: 32,
},
),
- h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, t('createAccount')),
+ h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, this.props.t('createAccount')),
],
),
h(
@@ -155,7 +154,7 @@ class AccountDropdowns extends Component {
fontSize: '24px',
marginBottom: '5px',
},
- }, t('importAccount')),
+ }, this.props.t('importAccount')),
]
),
]
@@ -193,7 +192,7 @@ class AccountDropdowns extends Component {
global.platform.openWindow({ url })
},
},
- t('etherscanView'),
+ this.props.t('etherscanView'),
),
h(
DropdownMenuItem,
@@ -205,7 +204,7 @@ class AccountDropdowns extends Component {
actions.showQrView(selected, identity ? identity.name : '')
},
},
- t('showQRCode'),
+ this.props.t('showQRCode'),
),
h(
DropdownMenuItem,
@@ -217,7 +216,7 @@ class AccountDropdowns extends Component {
copyToClipboard(checkSumAddress)
},
},
- t('copyAddress'),
+ this.props.t('copyAddress'),
),
h(
DropdownMenuItem,
@@ -227,7 +226,7 @@ class AccountDropdowns extends Component {
actions.requestAccountExport()
},
},
- t('exportPrivateKey'),
+ this.props.t('exportPrivateKey'),
),
]
)
@@ -301,6 +300,7 @@ AccountDropdowns.propTypes = {
style: PropTypes.object,
enableAccountOptions: PropTypes.bool,
enableAccountsSelector: PropTypes.bool,
+ t: PropTypes.func,
}
const mapDispatchToProps = (dispatch) => {
diff --git a/ui/app/components/account-export.js b/ui/app/components/account-export.js
index 5637bc8d0..8889f88a7 100644
--- a/ui/app/components/account-export.js
+++ b/ui/app/components/account-export.js
@@ -5,8 +5,7 @@ const exportAsFile = require('../util').exportAsFile
const copyToClipboard = require('copy-to-clipboard')
const actions = require('../actions')
const ethUtil = require('ethereumjs-util')
-const connect = require('react-redux').connect
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
module.exports = connect(mapStateToProps)(ExportAccountView)
@@ -36,7 +35,7 @@ ExportAccountView.prototype.render = function () {
if (notExporting) return h('div')
if (exportRequested) {
- const warning = t('exportPrivateKeyWarning')
+ const warning = this.props.t('exportPrivateKeyWarning')
return (
h('div', {
style: {
@@ -54,7 +53,7 @@ ExportAccountView.prototype.render = function () {
h('p.error', warning),
h('input#exportAccount.sizing-input', {
type: 'password',
- placeholder: t('confirmPassword').toLowerCase(),
+ placeholder: this.props.t('confirmPassword').toLowerCase(),
onKeyPress: this.onExportKeyPress.bind(this),
style: {
position: 'relative',
@@ -75,10 +74,10 @@ ExportAccountView.prototype.render = function () {
style: {
marginRight: '10px',
},
- }, t('submit')),
+ }, this.props.t('submit')),
h('button', {
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)),
- }, t('cancel')),
+ }, this.props.t('cancel')),
]),
(this.props.warning) && (
h('span.error', {
@@ -99,7 +98,7 @@ ExportAccountView.prototype.render = function () {
margin: '0 20px',
},
}, [
- h('label', t('copyPrivateKey') + ':'),
+ h('label', this.props.t('copyPrivateKey') + ':'),
h('p.error.cursor-pointer', {
style: {
textOverflow: 'ellipsis',
@@ -113,13 +112,13 @@ ExportAccountView.prototype.render = function () {
}, plainKey),
h('button', {
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)),
- }, t('done')),
+ }, this.props.t('done')),
h('button', {
style: {
marginLeft: '10px',
},
onClick: () => exportAsFile(`MetaMask ${nickname} Private Key`, plainKey),
- }, t('saveAsFile')),
+ }, this.props.t('saveAsFile')),
])
}
}
diff --git a/ui/app/components/account-menu/index.js b/ui/app/components/account-menu/index.js
index 994be6a15..7927b80d5 100644
--- a/ui/app/components/account-menu/index.js
+++ b/ui/app/components/account-menu/index.js
@@ -1,6 +1,6 @@
const inherits = require('util').inherits
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const { compose } = require('recompose')
const { withRouter } = require('react-router-dom')
const h = require('react-hyperscript')
@@ -8,7 +8,6 @@ const actions = require('../../actions')
const { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu')
const Identicon = require('../identicon')
const { formatBalance } = require('../../util')
-const t = require('../../../i18n')
const {
SETTINGS_ROUTE,
INFO_ROUTE,
@@ -75,13 +74,13 @@ AccountMenu.prototype.render = function () {
h(Item, {
className: 'account-menu__header',
}, [
- t('myAccounts'),
+ this.props.t('myAccounts'),
h('button.account-menu__logout-button', {
onClick: () => {
lockMetamask()
history.push(DEFAULT_ROUTE)
},
- }, t('logout')),
+ }, this.props.t('logout')),
]),
h(Divider),
h('div.account-menu__accounts', this.renderAccounts()),
@@ -92,7 +91,7 @@ AccountMenu.prototype.render = function () {
history.push(NEW_ACCOUNT_ROUTE)
},
icon: h('img.account-menu__item-icon', { src: 'images/plus-btn-white.svg' }),
- text: t('createAccount'),
+ text: this.props.t('createAccount'),
}),
h(Item, {
onClick: () => {
@@ -100,7 +99,7 @@ AccountMenu.prototype.render = function () {
history.push(IMPORT_ACCOUNT_ROUTE)
},
icon: h('img.account-menu__item-icon', { src: 'images/import-account.svg' }),
- text: t('importAccount'),
+ text: this.props.t('importAccount'),
}),
h(Divider),
h(Item, {
@@ -109,7 +108,7 @@ AccountMenu.prototype.render = function () {
history.push(INFO_ROUTE)
},
icon: h('img', { src: 'images/mm-info-icon.svg' }),
- text: t('infoHelp'),
+ text: this.props.t('infoHelp'),
}),
h(Item, {
onClick: () => {
@@ -117,7 +116,7 @@ AccountMenu.prototype.render = function () {
history.push(SETTINGS_ROUTE)
},
icon: h('img.account-menu__item-icon', { src: 'images/settings.svg' }),
- text: t('settings'),
+ text: this.props.t('settings'),
}),
])
}
@@ -175,6 +174,6 @@ AccountMenu.prototype.indicateIfLoose = function (keyring) {
try { // Sometimes keyrings aren't loaded yet:
const type = keyring.type
const isLoose = type !== 'HD Key Tree'
- return isLoose ? h('.keyring-label.allcaps', t('imported')) : null
+ return isLoose ? h('.keyring-label.allcaps', this.props.t('imported')) : null
} catch (e) { return }
}
diff --git a/ui/app/components/balance-component.js b/ui/app/components/balance-component.js
index d591ab455..f6292e358 100644
--- a/ui/app/components/balance-component.js
+++ b/ui/app/components/balance-component.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const h = require('react-hyperscript')
const inherits = require('util').inherits
const TokenBalance = require('./token-balance')
diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js
index 70701b039..0ace2b840 100644
--- a/ui/app/components/bn-as-decimal-input.js
+++ b/ui/app/components/bn-as-decimal-input.js
@@ -4,9 +4,9 @@ const inherits = require('util').inherits
const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN
const extend = require('xtend')
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
-module.exports = BnAsDecimalInput
+module.exports = connect()(BnAsDecimalInput)
inherits(BnAsDecimalInput, Component)
function BnAsDecimalInput () {
@@ -137,13 +137,13 @@ BnAsDecimalInput.prototype.constructWarning = function () {
let message = name ? name + ' ' : ''
if (min && max) {
- message += t('betweenMinAndMax', [`${newMin} ${suffix}`, `${newMax} ${suffix}`])
+ message += this.props.t('betweenMinAndMax', [`${newMin} ${suffix}`, `${newMax} ${suffix}`])
} else if (min) {
- message += t('greaterThanMin', [`${newMin} ${suffix}`])
+ message += this.props.t('greaterThanMin', [`${newMin} ${suffix}`])
} else if (max) {
- message += t('lessThanMax', [`${newMax} ${suffix}`])
+ message += this.props.t('lessThanMax', [`${newMax} ${suffix}`])
} else {
- message += t('invalidInput')
+ message += this.props.t('invalidInput')
}
return message
diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js
index 1e277a94b..eafa2af91 100644
--- a/ui/app/components/buy-button-subview.js
+++ b/ui/app/components/buy-button-subview.js
@@ -1,7 +1,7 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const actions = require('../actions')
const CoinbaseForm = require('./coinbase-form')
const ShapeshiftForm = require('./shapeshift-form')
@@ -9,7 +9,6 @@ const Loading = require('./loading')
const AccountPanel = require('./account-panel')
const RadioList = require('./custom-radio-list')
const networkNames = require('../../../app/scripts/config.js').networkNames
-const t = require('../../i18n')
module.exports = connect(mapStateToProps)(BuyButtonSubview)
@@ -77,7 +76,7 @@ BuyButtonSubview.prototype.headerSubview = function () {
paddingTop: '4px',
paddingBottom: '4px',
},
- }, t('depositEth')),
+ }, this.props.t('depositEth')),
]),
// loading indication
@@ -119,7 +118,7 @@ BuyButtonSubview.prototype.headerSubview = function () {
paddingTop: '4px',
paddingBottom: '4px',
},
- }, t('selectService')),
+ }, this.props.t('selectService')),
]),
])
@@ -144,7 +143,7 @@ BuyButtonSubview.prototype.primarySubview = function () {
case '4':
case '42':
const networkName = networkNames[network]
- const label = `${networkName} ${t('testFaucet')}`
+ const label = `${networkName} ${this.props.t('testFaucet')}`
return (
h('div.flex-column', {
style: {
@@ -165,14 +164,14 @@ BuyButtonSubview.prototype.primarySubview = function () {
style: {
marginTop: '15px',
},
- }, t('borrowDharma'))
+ }, this.props.t('borrowDharma'))
) : null,
])
)
default:
return (
- h('h2.error', t('unknownNetworkId'))
+ h('h2.error', this.props.t('unknownNetworkId'))
)
}
@@ -204,8 +203,8 @@ BuyButtonSubview.prototype.mainnetSubview = function () {
'ShapeShift',
],
subtext: {
- 'Coinbase': `${t('crypto')}/${t('fiat')} (${t('usaOnly')})`,
- 'ShapeShift': t('crypto'),
+ 'Coinbase': `${this.props.t('crypto')}/${this.props.t('fiat')} (${this.props.t('usaOnly')})`,
+ 'ShapeShift': this.props.t('crypto'),
},
onClick: this.radioHandler.bind(this),
}),
diff --git a/ui/app/components/coinbase-form.js b/ui/app/components/coinbase-form.js
index e442b43d5..0f980fbd5 100644
--- a/ui/app/components/coinbase-form.js
+++ b/ui/app/components/coinbase-form.js
@@ -1,9 +1,8 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const actions = require('../actions')
-const t = require('../../i18n')
module.exports = connect(mapStateToProps)(CoinbaseForm)
@@ -38,11 +37,11 @@ CoinbaseForm.prototype.render = function () {
}, [
h('button.btn-green', {
onClick: this.toCoinbase.bind(this),
- }, t('continueToCoinbase')),
+ }, this.props.t('continueToCoinbase')),
h('button.btn-red', {
onClick: () => props.dispatch(actions.goHome()),
- }, t('cancel')),
+ }, this.props.t('cancel')),
]),
])
}
diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js
index 355f78d45..ea1c43d54 100644
--- a/ui/app/components/copyButton.js
+++ b/ui/app/components/copyButton.js
@@ -2,11 +2,11 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const copyToClipboard = require('copy-to-clipboard')
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
const Tooltip = require('./tooltip')
-module.exports = CopyButton
+module.exports = connect()(CopyButton)
inherits(CopyButton, Component)
function CopyButton () {
@@ -23,7 +23,7 @@ CopyButton.prototype.render = function () {
const value = props.value
const copied = state.copied
- const message = copied ? t('copiedButton') : props.title || t('copyButton')
+ const message = copied ? this.props.t('copiedButton') : props.title || this.props.t('copyButton')
return h('.copy-button', {
style: {
diff --git a/ui/app/components/copyable.js b/ui/app/components/copyable.js
index fca7d3863..28def9adb 100644
--- a/ui/app/components/copyable.js
+++ b/ui/app/components/copyable.js
@@ -4,9 +4,9 @@ const inherits = require('util').inherits
const Tooltip = require('./tooltip')
const copyToClipboard = require('copy-to-clipboard')
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
-module.exports = Copyable
+module.exports = connect()(Copyable)
inherits(Copyable, Component)
function Copyable () {
@@ -23,7 +23,7 @@ Copyable.prototype.render = function () {
const { copied } = state
return h(Tooltip, {
- title: copied ? t('copiedExclamation') : t('copy'),
+ title: copied ? this.props.t('copiedExclamation') : this.props.t('copy'),
position: 'bottom',
}, h('span', {
style: {
diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js
index 22ad98ce4..8234f8d19 100644
--- a/ui/app/components/customize-gas-modal/index.js
+++ b/ui/app/components/customize-gas-modal/index.js
@@ -1,9 +1,8 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
-const t = require('../../../i18n')
const GasModalCard = require('./gas-modal-card')
const ethUtil = require('ethereumjs-util')
@@ -150,7 +149,7 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) {
})
if (!balanceIsSufficient) {
- error = t('balanceIsInsufficientGas')
+ error = this.props.t('balanceIsInsufficientGas')
}
const gasLimitTooLow = gasLimit && conversionGreaterThan(
@@ -166,7 +165,7 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) {
)
if (gasLimitTooLow) {
- error = t('gasLimitTooLow')
+ error = this.props.t('gasLimitTooLow')
}
this.setState({ error })
@@ -259,7 +258,7 @@ CustomizeGasModal.prototype.render = function () {
}, [
h('div.send-v2__customize-gas__header', {}, [
- h('div.send-v2__customize-gas__title', t('customGas')),
+ h('div.send-v2__customize-gas__title', this.props.t('customGas')),
h('div.send-v2__customize-gas__close', {
onClick: hideModal,
@@ -275,8 +274,8 @@ CustomizeGasModal.prototype.render = function () {
// max: 1000,
step: multiplyCurrencies(MIN_GAS_PRICE_GWEI, 10),
onChange: value => this.convertAndSetGasPrice(value),
- title: t('gasPrice'),
- copy: t('gasPriceCalculation'),
+ title: this.props.t('gasPrice'),
+ copy: this.props.t('gasPriceCalculation'),
}),
h(GasModalCard, {
@@ -285,8 +284,8 @@ CustomizeGasModal.prototype.render = function () {
// max: 100000,
step: 1,
onChange: value => this.convertAndSetGasLimit(value),
- title: t('gasLimit'),
- copy: t('gasLimitCalculation'),
+ title: this.props.t('gasLimit'),
+ copy: this.props.t('gasLimitCalculation'),
}),
]),
@@ -299,7 +298,7 @@ CustomizeGasModal.prototype.render = function () {
h('div.send-v2__customize-gas__revert', {
onClick: () => this.revert(),
- }, [t('revert')]),
+ }, [this.props.t('revert')]),
h('div.send-v2__customize-gas__buttons', [
h('button.btn-secondary.send-v2__customize-gas__cancel', {
@@ -307,12 +306,12 @@ CustomizeGasModal.prototype.render = function () {
style: {
marginRight: '10px',
},
- }, [t('cancel')]),
+ }, [this.props.t('cancel')]),
h('button.btn-primary.send-v2__customize-gas__save', {
onClick: () => !error && this.save(newGasPrice, gasLimit, gasTotal),
className: error && 'btn-primary--disabled',
- }, [t('save')]),
+ }, [this.props.t('save')]),
]),
]),
diff --git a/ui/app/components/dropdowns/components/account-dropdowns.js b/ui/app/components/dropdowns/components/account-dropdowns.js
index e5359c1d6..5e7c0d554 100644
--- a/ui/app/components/dropdowns/components/account-dropdowns.js
+++ b/ui/app/components/dropdowns/components/account-dropdowns.js
@@ -3,14 +3,14 @@ const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const actions = require('../../../actions')
const genAccountLink = require('../../../../lib/account-link.js')
-const connect = require('react-redux').connect
+const connect = require('../../../metamask-connect')
const Dropdown = require('./dropdown').Dropdown
const DropdownMenuItem = require('./dropdown').DropdownMenuItem
const Identicon = require('../../identicon')
const ethUtil = require('ethereumjs-util')
const copyToClipboard = require('copy-to-clipboard')
const { formatBalance } = require('../../../util')
-const t = require('../../../../i18n')
+
class AccountDropdowns extends Component {
constructor (props) {
@@ -130,7 +130,7 @@ class AccountDropdowns extends Component {
actions.showEditAccountModal(identity)
},
}, [
- t('edit'),
+ this.props.t('edit'),
]),
]),
@@ -144,7 +144,7 @@ class AccountDropdowns extends Component {
try { // Sometimes keyrings aren't loaded yet:
const type = keyring.type
const isLoose = type !== 'HD Key Tree'
- return isLoose ? h('.keyring-label.allcaps', t('loose')) : null
+ return isLoose ? h('.keyring-label.allcaps', this.props.t('loose')) : null
} catch (e) { return }
}
@@ -202,7 +202,7 @@ class AccountDropdowns extends Component {
fontSize: '16px',
lineHeight: '23px',
},
- }, t('createAccount')),
+ }, this.props.t('createAccount')),
],
),
h(
@@ -236,7 +236,7 @@ class AccountDropdowns extends Component {
fontSize: '16px',
lineHeight: '23px',
},
- }, t('importAccount')),
+ }, this.props.t('importAccount')),
]
),
]
@@ -287,7 +287,7 @@ class AccountDropdowns extends Component {
menuItemStyles,
),
},
- t('accountDetails'),
+ this.props.t('accountDetails'),
),
h(
DropdownMenuItem,
@@ -303,7 +303,7 @@ class AccountDropdowns extends Component {
menuItemStyles,
),
},
- t('etherscanView'),
+ this.props.t('etherscanView'),
),
h(
DropdownMenuItem,
@@ -319,7 +319,7 @@ class AccountDropdowns extends Component {
menuItemStyles,
),
},
- t('copyAddress'),
+ this.props.t('copyAddress'),
),
h(
DropdownMenuItem,
@@ -331,7 +331,7 @@ class AccountDropdowns extends Component {
menuItemStyles,
),
},
- t('exportPrivateKey'),
+ this.props.t('exportPrivateKey'),
),
h(
DropdownMenuItem,
@@ -346,7 +346,7 @@ class AccountDropdowns extends Component {
menuItemStyles,
),
},
- t('addToken'),
+ this.props.t('addToken'),
),
]
@@ -425,6 +425,7 @@ AccountDropdowns.propTypes = {
enableAccountsSelector: PropTypes.bool,
enableAccountOption: PropTypes.bool,
enableAccountOptions: PropTypes.bool,
+ t: PropTypes.func,
}
const mapDispatchToProps = (dispatch) => {
diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js
index 5afe730c1..aac7a9ee5 100644
--- a/ui/app/components/dropdowns/network-dropdown.js
+++ b/ui/app/components/dropdowns/network-dropdown.js
@@ -1,14 +1,14 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const Dropdown = require('./components/dropdown').Dropdown
const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem
const NetworkDropdownIcon = require('./components/network-dropdown-icon')
-const t = require('../../../i18n')
const R = require('ramda')
+
// classes from nodes of the toggle element.
const notToggleElementClassnames = [
'menu-icon',
@@ -94,13 +94,13 @@ NetworkDropdown.prototype.render = function () {
}, [
h('div.network-dropdown-header', {}, [
- h('div.network-dropdown-title', {}, t('networks')),
+ h('div.network-dropdown-title', {}, this.props.t('networks')),
h('div.network-dropdown-divider'),
h('div.network-dropdown-content',
{},
- t('defaultNetwork')
+ this.props.t('defaultNetwork')
),
]),
@@ -122,7 +122,7 @@ NetworkDropdown.prototype.render = function () {
style: {
color: providerType === 'mainnet' ? '#ffffff' : '#9b9b9b',
},
- }, t('mainnet')),
+ }, this.props.t('mainnet')),
]
),
@@ -144,7 +144,7 @@ NetworkDropdown.prototype.render = function () {
style: {
color: providerType === 'ropsten' ? '#ffffff' : '#9b9b9b',
},
- }, t('ropsten')),
+ }, this.props.t('ropsten')),
]
),
@@ -166,7 +166,7 @@ NetworkDropdown.prototype.render = function () {
style: {
color: providerType === 'kovan' ? '#ffffff' : '#9b9b9b',
},
- }, t('kovan')),
+ }, this.props.t('kovan')),
]
),
@@ -188,7 +188,7 @@ NetworkDropdown.prototype.render = function () {
style: {
color: providerType === 'rinkeby' ? '#ffffff' : '#9b9b9b',
},
- }, t('rinkeby')),
+ }, this.props.t('rinkeby')),
]
),
@@ -210,7 +210,7 @@ NetworkDropdown.prototype.render = function () {
style: {
color: activeNetwork === 'http://localhost:8545' ? '#ffffff' : '#9b9b9b',
},
- }, t('localhost')),
+ }, this.props.t('localhost')),
]
),
@@ -234,7 +234,7 @@ NetworkDropdown.prototype.render = function () {
style: {
color: activeNetwork === 'custom' ? '#ffffff' : '#9b9b9b',
},
- }, t('customRPC')),
+ }, this.props.t('customRPC')),
]
),
@@ -249,15 +249,15 @@ NetworkDropdown.prototype.getNetworkName = function () {
let name
if (providerName === 'mainnet') {
- name = t('mainnet')
+ name = this.props.t('mainnet')
} else if (providerName === 'ropsten') {
- name = t('ropsten')
+ name = this.props.t('ropsten')
} else if (providerName === 'kovan') {
- name = t('kovan')
+ name = this.props.t('kovan')
} else if (providerName === 'rinkeby') {
- name = t('rinkeby')
+ name = this.props.t('rinkeby')
} else {
- name = t('unknownNetwork')
+ name = this.props.t('unknownNetwork')
}
return name
diff --git a/ui/app/components/dropdowns/token-menu-dropdown.js b/ui/app/components/dropdowns/token-menu-dropdown.js
index a4f93b505..630e1f99d 100644
--- a/ui/app/components/dropdowns/token-menu-dropdown.js
+++ b/ui/app/components/dropdowns/token-menu-dropdown.js
@@ -1,9 +1,9 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
-const t = require('../../../i18n')
+
module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)
@@ -44,7 +44,7 @@ TokenMenuDropdown.prototype.render = function () {
showHideTokenConfirmationModal(this.props.token)
this.props.onClose()
},
- }, t('hideToken')),
+ }, this.props.t('hideToken')),
]),
]),
diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js
index 1b2d4009d..922f24d40 100644
--- a/ui/app/components/ens-input.js
+++ b/ui/app/components/ens-input.js
@@ -8,11 +8,10 @@ const ENS = require('ethjs-ens')
const networkMap = require('ethjs-ens/lib/network-map.json')
const ensRE = /.+\..+$/
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
const ToAutoComplete = require('./send/to-autocomplete')
-
-module.exports = EnsInput
+module.exports = connect()(EnsInput)
inherits(EnsInput, Component)
function EnsInput () {
@@ -71,13 +70,13 @@ EnsInput.prototype.lookupEnsName = function (recipient) {
log.info(`ENS attempting to resolve name: ${recipient}`)
this.ens.lookup(recipient.trim())
.then((address) => {
- if (address === ZERO_ADDRESS) throw new Error(t('noAddressForName'))
+ if (address === ZERO_ADDRESS) throw new Error(this.props.t('noAddressForName'))
if (address !== ensResolution) {
this.setState({
loadingEns: false,
ensResolution: address,
nickname: recipient.trim(),
- hoverText: address + '\n' + t('clickCopy'),
+ hoverText: address + '\n' + this.props.t('clickCopy'),
ensFailure: false,
})
}
diff --git a/ui/app/components/hex-as-decimal-input.js b/ui/app/components/hex-as-decimal-input.js
index a43d44f89..be7ba4c9e 100644
--- a/ui/app/components/hex-as-decimal-input.js
+++ b/ui/app/components/hex-as-decimal-input.js
@@ -4,9 +4,9 @@ const inherits = require('util').inherits
const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN
const extend = require('xtend')
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
-module.exports = HexAsDecimalInput
+module.exports = connect()(HexAsDecimalInput)
inherits(HexAsDecimalInput, Component)
function HexAsDecimalInput () {
@@ -127,13 +127,13 @@ HexAsDecimalInput.prototype.constructWarning = function () {
let message = name ? name + ' ' : ''
if (min && max) {
- message += t('betweenMinAndMax', [min, max])
+ message += this.props.t('betweenMinAndMax', [min, max])
} else if (min) {
- message += t('greaterThanMin', [min])
+ message += this.props.t('greaterThanMin', [min])
} else if (max) {
- message += t('lessThanMax', [max])
+ message += this.props.t('lessThanMax', [max])
} else {
- message += t('invalidInput')
+ message += this.props.t('invalidInput')
}
return message
diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js
index b803b7ceb..6b2a1b428 100644
--- a/ui/app/components/identicon.js
+++ b/ui/app/components/identicon.js
@@ -1,7 +1,7 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const isNode = require('detect-node')
const findDOMNode = require('react-dom').findDOMNode
const jazzicon = require('jazzicon')
diff --git a/ui/app/components/modals/account-details-modal.js b/ui/app/components/modals/account-details-modal.js
index 927d73482..c43e3e3a5 100644
--- a/ui/app/components/modals/account-details-modal.js
+++ b/ui/app/components/modals/account-details-modal.js
@@ -1,14 +1,13 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const AccountModalContainer = require('./account-modal-container')
const { getSelectedIdentity } = require('../../selectors')
const genAccountLink = require('../../../lib/account-link.js')
const QrView = require('../qr-code')
const EditableLabel = require('../editable-label')
-const t = require('../../../i18n')
function mapStateToProps (state) {
return {
@@ -65,12 +64,12 @@ AccountDetailsModal.prototype.render = function () {
h('button.btn-primary.account-modal__button', {
onClick: () => global.platform.openWindow({ url: genAccountLink(address, network) }),
- }, t('etherscanView')),
+ }, this.props.t('etherscanView')),
// Holding on redesign for Export Private Key functionality
h('button.btn-primary.account-modal__button', {
onClick: () => showExportPrivateKeyModal(),
- }, t('exportPrivateKey')),
+ }, this.props.t('exportPrivateKey')),
])
}
diff --git a/ui/app/components/modals/account-modal-container.js b/ui/app/components/modals/account-modal-container.js
index 08540aa76..70efe16cb 100644
--- a/ui/app/components/modals/account-modal-container.js
+++ b/ui/app/components/modals/account-modal-container.js
@@ -1,11 +1,10 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const { getSelectedIdentity } = require('../../selectors')
const Identicon = require('../identicon')
-const t = require('../../../i18n')
function mapStateToProps (state) {
return {
@@ -60,7 +59,7 @@ AccountModalContainer.prototype.render = function () {
h('i.fa.fa-angle-left.fa-lg'),
- h('span.account-modal-back__text', ' ' + t('back')),
+ h('span.account-modal-back__text', ' ' + this.props.t('back')),
]),
diff --git a/ui/app/components/modals/buy-options-modal.js b/ui/app/components/modals/buy-options-modal.js
index 7eb73c3a6..c0ee3632e 100644
--- a/ui/app/components/modals/buy-options-modal.js
+++ b/ui/app/components/modals/buy-options-modal.js
@@ -1,10 +1,9 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const networkNames = require('../../../../app/scripts/config.js').networkNames
-const t = require('../../../i18n')
function mapStateToProps (state) {
return {
@@ -57,15 +56,15 @@ BuyOptions.prototype.render = function () {
}, [
h('div.buy-modal-content-title', {
style: {},
- }, t('transfers')),
- h('div', {}, t('howToDeposit')),
+ }, this.props.t('transfers')),
+ h('div', {}, this.props.t('howToDeposit')),
]),
h('div.buy-modal-content-options.flex-column.flex-center', {}, [
isTestNetwork
- ? this.renderModalContentOption(networkName, t('testFaucet'), () => toFaucet(network))
- : this.renderModalContentOption('Coinbase', t('depositFiat'), () => toCoinbase(address)),
+ ? this.renderModalContentOption(networkName, this.props.t('testFaucet'), () => toFaucet(network))
+ : this.renderModalContentOption('Coinbase', this.props.t('depositFiat'), () => toCoinbase(address)),
// h('div.buy-modal-content-option', {}, [
// h('div.buy-modal-content-option-title', {}, 'Shapeshift'),
@@ -73,8 +72,8 @@ BuyOptions.prototype.render = function () {
// ]),,
this.renderModalContentOption(
- t('directDeposit'),
- t('depositFromAccount'),
+ this.props.t('directDeposit'),
+ this.props.t('depositFromAccount'),
() => this.goToAccountDetailsModal()
),
@@ -85,7 +84,7 @@ BuyOptions.prototype.render = function () {
background: 'white',
},
onClick: () => { this.props.hideModal() },
- }, h('div.buy-modal-content-footer#buy-modal-content-footer-text', {}, t('cancel'))),
+ }, h('div.buy-modal-content-footer#buy-modal-content-footer-text', {}, this.props.t('cancel'))),
]),
])
}
diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js
index 2de1240fc..e38899d04 100644
--- a/ui/app/components/modals/deposit-ether-modal.js
+++ b/ui/app/components/modals/deposit-ether-modal.js
@@ -1,22 +1,18 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const networkNames = require('../../../../app/scripts/config.js').networkNames
const ShapeshiftForm = require('../shapeshift-form')
-const t = require('../../../i18n')
-
-const DIRECT_DEPOSIT_ROW_TITLE = t('directDepositEther')
-const DIRECT_DEPOSIT_ROW_TEXT = t('directDepositEtherExplainer')
-const COINBASE_ROW_TITLE = t('buyCoinbase')
-const COINBASE_ROW_TEXT = t('buyCoinbaseExplainer')
-const SHAPESHIFT_ROW_TITLE = t('depositShapeShift')
-const SHAPESHIFT_ROW_TEXT = t('depositShapeShiftExplainer')
-const FAUCET_ROW_TITLE = t('testFaucet')
-const facuetRowText = (networkName) => {
- return t('getEtherFromFaucet', [networkName])
-}
+
+let DIRECT_DEPOSIT_ROW_TITLE
+let DIRECT_DEPOSIT_ROW_TEXT
+let COINBASE_ROW_TITLE
+let COINBASE_ROW_TEXT
+let SHAPESHIFT_ROW_TITLE
+let SHAPESHIFT_ROW_TEXT
+let FAUCET_ROW_TITLE
function mapStateToProps (state) {
return {
@@ -44,9 +40,18 @@ function mapDispatchToProps (dispatch) {
}
inherits(DepositEtherModal, Component)
-function DepositEtherModal () {
+function DepositEtherModal (props) {
Component.call(this)
+ // need to set after i18n locale has loaded
+ DIRECT_DEPOSIT_ROW_TITLE = props.t('directDepositEther')
+ DIRECT_DEPOSIT_ROW_TEXT = props.t('directDepositEtherExplainer')
+ COINBASE_ROW_TITLE = props.t('buyCoinbase')
+ COINBASE_ROW_TEXT = props.t('buyCoinbaseExplainer')
+ SHAPESHIFT_ROW_TITLE = props.t('depositShapeShift')
+ SHAPESHIFT_ROW_TEXT = props.t('depositShapeShiftExplainer')
+ FAUCET_ROW_TITLE = props.t('testFaucet')
+
this.state = {
buyingWithShapeshift: false,
}
@@ -54,6 +59,10 @@ function DepositEtherModal () {
module.exports = connect(mapStateToProps, mapDispatchToProps)(DepositEtherModal)
+DepositEtherModal.prototype.facuetRowText = function (networkName) {
+ return this.props.t('getEtherFromFaucet', [networkName])
+}
+
DepositEtherModal.prototype.renderRow = function ({
logo,
title,
@@ -113,10 +122,10 @@ DepositEtherModal.prototype.render = function () {
h('div.page-container__header', [
- h('div.page-container__title', [t('depositEther')]),
+ h('div.page-container__title', [this.props.t('depositEther')]),
h('div.page-container__subtitle', [
- t('needEtherInWallet'),
+ this.props.t('needEtherInWallet'),
]),
h('div.page-container__header-close', {
@@ -139,7 +148,7 @@ DepositEtherModal.prototype.render = function () {
}),
title: DIRECT_DEPOSIT_ROW_TITLE,
text: DIRECT_DEPOSIT_ROW_TEXT,
- buttonLabel: t('viewAccount'),
+ buttonLabel: this.props.t('viewAccount'),
onButtonClick: () => this.goToAccountDetailsModal(),
hide: buyingWithShapeshift,
}),
@@ -147,8 +156,8 @@ DepositEtherModal.prototype.render = function () {
this.renderRow({
logo: h('i.fa.fa-tint.fa-2x'),
title: FAUCET_ROW_TITLE,
- text: facuetRowText(networkName),
- buttonLabel: t('getEther'),
+ text: this.facuetRowText(networkName),
+ buttonLabel: this.props.t('getEther'),
onButtonClick: () => toFaucet(network),
hide: !isTestNetwork || buyingWithShapeshift,
}),
@@ -162,7 +171,7 @@ DepositEtherModal.prototype.render = function () {
}),
title: COINBASE_ROW_TITLE,
text: COINBASE_ROW_TEXT,
- buttonLabel: t('continueToCoinbase'),
+ buttonLabel: this.props.t('continueToCoinbase'),
onButtonClick: () => toCoinbase(address),
hide: isTestNetwork || buyingWithShapeshift,
}),
@@ -175,7 +184,7 @@ DepositEtherModal.prototype.render = function () {
}),
title: SHAPESHIFT_ROW_TITLE,
text: SHAPESHIFT_ROW_TEXT,
- buttonLabel: t('shapeshiftBuy'),
+ buttonLabel: this.props.t('shapeshiftBuy'),
onButtonClick: () => this.setState({ buyingWithShapeshift: true }),
hide: isTestNetwork,
hideButton: buyingWithShapeshift,
diff --git a/ui/app/components/modals/edit-account-name-modal.js b/ui/app/components/modals/edit-account-name-modal.js
index 6efa8d476..4f5bc001a 100644
--- a/ui/app/components/modals/edit-account-name-modal.js
+++ b/ui/app/components/modals/edit-account-name-modal.js
@@ -1,10 +1,9 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const { getSelectedAccount } = require('../../selectors')
-const t = require('../../../i18n')
function mapStateToProps (state) {
return {
@@ -51,7 +50,7 @@ EditAccountNameModal.prototype.render = function () {
]),
h('div.edit-account-name-modal-title', {
- }, [t('editAccountName')]),
+ }, [this.props.t('editAccountName')]),
h('input.edit-account-name-modal-input', {
placeholder: identity.name,
@@ -70,7 +69,7 @@ EditAccountNameModal.prototype.render = function () {
},
disabled: this.state.inputText.length === 0,
}, [
- t('save'),
+ this.props.t('save'),
]),
]),
diff --git a/ui/app/components/modals/export-private-key-modal.js b/ui/app/components/modals/export-private-key-modal.js
index cf42e4fa2..d5a1ba7b8 100644
--- a/ui/app/components/modals/export-private-key-modal.js
+++ b/ui/app/components/modals/export-private-key-modal.js
@@ -1,13 +1,12 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const ethUtil = require('ethereumjs-util')
const actions = require('../../actions')
const AccountModalContainer = require('./account-modal-container')
const { getSelectedIdentity } = require('../../selectors')
const ReadOnlyInput = require('../readonly-input')
-const t = require('../../../i18n')
const copyToClipboard = require('copy-to-clipboard')
function mapStateToProps (state) {
@@ -49,8 +48,8 @@ ExportPrivateKeyModal.prototype.exportAccountAndGetPrivateKey = function (passwo
ExportPrivateKeyModal.prototype.renderPasswordLabel = function (privateKey) {
return h('span.private-key-password-label', privateKey
- ? t('copyPrivateKey')
- : t('typePassword')
+ ? this.props.t('copyPrivateKey')
+ : this.props.t('typePassword')
)
}
@@ -87,8 +86,8 @@ ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password,
),
(privateKey
- ? this.renderButton('btn-primary--lg export-private-key__button', () => hideModal(), t('done'))
- : this.renderButton('btn-primary--lg export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), t('confirm'))
+ ? this.renderButton('btn-primary--lg export-private-key__button', () => hideModal(), this.props.t('done'))
+ : this.renderButton('btn-primary--lg export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), this.props.t('confirm'))
),
])
@@ -121,7 +120,7 @@ ExportPrivateKeyModal.prototype.render = function () {
h('div.account-modal-divider'),
- h('span.modal-body-title', t('showPrivateKeys')),
+ h('span.modal-body-title', this.props.t('showPrivateKeys')),
h('div.private-key-password', {}, [
this.renderPasswordLabel(privateKey),
@@ -131,7 +130,7 @@ ExportPrivateKeyModal.prototype.render = function () {
!warning ? null : h('span.private-key-password-error', warning),
]),
- h('div.private-key-password-warning', t('privateKeyWarning')),
+ h('div.private-key-password-warning', this.props.t('privateKeyWarning')),
this.renderButtons(privateKey, this.state.password, address, hideModal),
diff --git a/ui/app/components/modals/hide-token-confirmation-modal.js b/ui/app/components/modals/hide-token-confirmation-modal.js
index 33d8062c6..5207b4c95 100644
--- a/ui/app/components/modals/hide-token-confirmation-modal.js
+++ b/ui/app/components/modals/hide-token-confirmation-modal.js
@@ -1,10 +1,9 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const Identicon = require('../identicon')
-const t = require('../../../i18n')
function mapStateToProps (state) {
return {
@@ -42,7 +41,7 @@ HideTokenConfirmationModal.prototype.render = function () {
h('div.hide-token-confirmation__container', {
}, [
h('div.hide-token-confirmation__title', {}, [
- t('hideTokenPrompt'),
+ this.props.t('hideTokenPrompt'),
]),
h(Identicon, {
@@ -55,19 +54,19 @@ HideTokenConfirmationModal.prototype.render = function () {
h('div.hide-token-confirmation__symbol', {}, symbol),
h('div.hide-token-confirmation__copy', {}, [
- t('readdToken'),
+ this.props.t('readdToken'),
]),
h('div.hide-token-confirmation__buttons', {}, [
h('button.btn-cancel.hide-token-confirmation__button.allcaps', {
onClick: () => hideModal(),
}, [
- t('cancel'),
+ this.props.t('cancel'),
]),
h('button.btn-clear.hide-token-confirmation__button.allcaps', {
onClick: () => hideToken(address),
}, [
- t('hide'),
+ this.props.t('hide'),
]),
]),
]),
diff --git a/ui/app/components/modals/modal.js b/ui/app/components/modals/modal.js
index 501b83430..9250cc77e 100644
--- a/ui/app/components/modals/modal.js
+++ b/ui/app/components/modals/modal.js
@@ -6,7 +6,6 @@ const FadeModal = require('boron').FadeModal
const actions = require('../../actions')
const isMobileView = require('../../../lib/is-mobile-view')
const isPopupOrNotification = require('../../../../app/scripts/lib/is-popup-or-notification')
-const t = require('../../../i18n')
// Modal Components
const BuyOptions = require('./buy-options-modal')
@@ -174,8 +173,8 @@ const MODALS = {
BETA_UI_NOTIFICATION_MODAL: {
contents: [
h(NotifcationModal, {
- header: t('uiWelcome'),
- message: t('uiWelcomeMessage'),
+ header: 'uiWelcome',
+ message: 'uiWelcomeMessage',
}),
],
mobileModalStyle: {
@@ -191,8 +190,8 @@ const MODALS = {
OLD_UI_NOTIFICATION_MODAL: {
contents: [
h(NotifcationModal, {
- header: t('oldUI'),
- message: t('oldUIMessage'),
+ header: 'oldUI',
+ message: 'oldUIMessage',
}),
],
mobileModalStyle: {
diff --git a/ui/app/components/modals/new-account-modal.js b/ui/app/components/modals/new-account-modal.js
index 298b76af4..372b65251 100644
--- a/ui/app/components/modals/new-account-modal.js
+++ b/ui/app/components/modals/new-account-modal.js
@@ -1,9 +1,8 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const { connect } = require('react-redux')
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
-const t = require('../../../i18n')
class NewAccountModal extends Component {
constructor (props) {
@@ -12,7 +11,7 @@ class NewAccountModal extends Component {
const newAccountNumber = numberOfExistingAccounts + 1
this.state = {
- newAccountName: `${t('account')} ${newAccountNumber}`,
+ newAccountName: `${props.t('account')} ${newAccountNumber}`,
}
}
@@ -23,7 +22,7 @@ class NewAccountModal extends Component {
h('div.new-account-modal-wrapper', {
}, [
h('div.new-account-modal-header', {}, [
- t('newAccount'),
+ this.props.t('newAccount'),
]),
h('div.modal-close-x', {
@@ -31,19 +30,19 @@ class NewAccountModal extends Component {
}),
h('div.new-account-modal-content', {}, [
- t('accountName'),
+ this.props.t('accountName'),
]),
h('div.new-account-input-wrapper', {}, [
h('input.new-account-input', {
value: this.state.newAccountName,
- placeholder: t('sampleAccountName'),
+ placeholder: this.props.t('sampleAccountName'),
onChange: event => this.setState({ newAccountName: event.target.value }),
}, []),
]),
h('div.new-account-modal-content.after-input', {}, [
- t('or'),
+ this.props.t('or'),
]),
h('div.new-account-modal-content.after-input.pointer', {
@@ -51,13 +50,13 @@ class NewAccountModal extends Component {
this.props.hideModal()
this.props.showImportPage()
},
- }, t('importAnAccount')),
+ }, this.props.t('importAnAccount')),
h('div.new-account-modal-content.button.allcaps', {}, [
h('button.btn-clear', {
onClick: () => this.props.createAccount(newAccountName),
}, [
- t('save'),
+ this.props.t('save'),
]),
]),
]),
@@ -70,6 +69,7 @@ NewAccountModal.propTypes = {
showImportPage: PropTypes.func,
createAccount: PropTypes.func,
numberOfExistingAccounts: PropTypes.number,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
diff --git a/ui/app/components/modals/notification-modal.js b/ui/app/components/modals/notification-modal.js
index 621a974d0..5d6dca177 100644
--- a/ui/app/components/modals/notification-modal.js
+++ b/ui/app/components/modals/notification-modal.js
@@ -1,7 +1,7 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const { connect } = require('react-redux')
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
class NotificationModal extends Component {
@@ -22,12 +22,12 @@ class NotificationModal extends Component {
}, [
h('div.notification-modal__header', {}, [
- header,
+ this.props.t(header),
]),
h('div.notification-modal__message-wrapper', {}, [
h('div.notification-modal__message', {}, [
- message,
+ this.props.t(message),
]),
]),
@@ -62,6 +62,7 @@ NotificationModal.propTypes = {
showCancelButton: PropTypes.bool,
showConfirmButton: PropTypes.bool,
onConfirm: PropTypes.func,
+ t: PropTypes.func,
}
const mapDispatchToProps = dispatch => {
diff --git a/ui/app/components/modals/notification-modals/confirm-reset-account.js b/ui/app/components/modals/notification-modals/confirm-reset-account.js
index e1bc91b24..94ee997ab 100644
--- a/ui/app/components/modals/notification-modals/confirm-reset-account.js
+++ b/ui/app/components/modals/notification-modals/confirm-reset-account.js
@@ -1,7 +1,7 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const { connect } = require('react-redux')
+const connect = require('../../../metamask-connect')
const actions = require('../../../actions')
const NotifcationModal = require('../notification-modal')
diff --git a/ui/app/components/modals/shapeshift-deposit-tx-modal.js b/ui/app/components/modals/shapeshift-deposit-tx-modal.js
index 24af5a0de..28dcb1902 100644
--- a/ui/app/components/modals/shapeshift-deposit-tx-modal.js
+++ b/ui/app/components/modals/shapeshift-deposit-tx-modal.js
@@ -1,7 +1,7 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const QrView = require('../qr-code')
const AccountModalContainer = require('./account-modal-container')
diff --git a/ui/app/components/network-display.js b/ui/app/components/network-display.js
index 9dc31b5c7..111a82be1 100644
--- a/ui/app/components/network-display.js
+++ b/ui/app/components/network-display.js
@@ -1,9 +1,8 @@
const { Component } = require('react')
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
-const { connect } = require('react-redux')
+const connect = require('../metamask-connect')
const NetworkDropdownIcon = require('./dropdowns/components/network-dropdown-icon')
-const t = require('../../i18n')
const networkToColorHash = {
1: '#038789',
@@ -31,7 +30,7 @@ class NetworkDisplay extends Component {
const { provider: { type } } = this.props
return h('.network-display__container', [
this.renderNetworkIcon(),
- h('.network-name', t(type)),
+ h('.network-name', this.props.t(type)),
])
}
}
@@ -39,6 +38,7 @@ class NetworkDisplay extends Component {
NetworkDisplay.propTypes = {
network: PropTypes.string,
provider: PropTypes.object,
+ t: PropTypes.func,
}
const mapStateToProps = ({ metamask: { network, provider } }) => {
diff --git a/ui/app/components/network.js b/ui/app/components/network.js
index f3df2242a..10961390e 100644
--- a/ui/app/components/network.js
+++ b/ui/app/components/network.js
@@ -1,11 +1,11 @@
const Component = require('react').Component
const h = require('react-hyperscript')
+const connect = require('../metamask-connect')
const classnames = require('classnames')
const inherits = require('util').inherits
const NetworkDropdownIcon = require('./dropdowns/components/network-dropdown-icon')
-const t = require('../../i18n')
-module.exports = Network
+module.exports = connect()(Network)
inherits(Network, Component)
@@ -34,7 +34,7 @@ Network.prototype.render = function () {
onClick: (event) => this.props.onClick(event),
}, [
h('img', {
- title: t('attemptingConnect'),
+ title: props.t('attemptingConnect'),
style: {
width: '27px',
},
@@ -42,22 +42,22 @@ Network.prototype.render = function () {
}),
])
} else if (providerName === 'mainnet') {
- hoverText = t('mainnet')
+ hoverText = props.t('mainnet')
iconName = 'ethereum-network'
} else if (providerName === 'ropsten') {
- hoverText = t('ropsten')
+ hoverText = props.t('ropsten')
iconName = 'ropsten-test-network'
} else if (parseInt(networkNumber) === 3) {
- hoverText = t('ropsten')
+ hoverText = props.t('ropsten')
iconName = 'ropsten-test-network'
} else if (providerName === 'kovan') {
- hoverText = t('kovan')
+ hoverText = props.t('kovan')
iconName = 'kovan-test-network'
} else if (providerName === 'rinkeby') {
- hoverText = t('rinkeby')
+ hoverText = props.t('rinkeby')
iconName = 'rinkeby-test-network'
} else {
- hoverText = t('unknownNetwork')
+ hoverText = props.t('unknownNetwork')
iconName = 'unknown-private-network'
}
@@ -85,7 +85,7 @@ Network.prototype.render = function () {
backgroundColor: '#038789', // $blue-lagoon
nonSelectBackgroundColor: '#15afb2',
}),
- h('.network-name', t('mainnet')),
+ h('.network-name', props.t('mainnet')),
h('i.fa.fa-chevron-down.fa-lg.network-caret'),
])
case 'ropsten-test-network':
@@ -94,7 +94,7 @@ Network.prototype.render = function () {
backgroundColor: '#e91550', // $crimson
nonSelectBackgroundColor: '#ec2c50',
}),
- h('.network-name', t('ropsten')),
+ h('.network-name', props.t('ropsten')),
h('i.fa.fa-chevron-down.fa-lg.network-caret'),
])
case 'kovan-test-network':
@@ -103,7 +103,7 @@ Network.prototype.render = function () {
backgroundColor: '#690496', // $purple
nonSelectBackgroundColor: '#b039f3',
}),
- h('.network-name', t('kovan')),
+ h('.network-name', props.t('kovan')),
h('i.fa.fa-chevron-down.fa-lg.network-caret'),
])
case 'rinkeby-test-network':
@@ -112,7 +112,7 @@ Network.prototype.render = function () {
backgroundColor: '#ebb33f', // $tulip-tree
nonSelectBackgroundColor: '#ecb23e',
}),
- h('.network-name', t('rinkeby')),
+ h('.network-name', props.t('rinkeby')),
h('i.fa.fa-chevron-down.fa-lg.network-caret'),
])
default:
@@ -124,7 +124,7 @@ Network.prototype.render = function () {
},
}),
- h('.network-name', t('privateNetwork')),
+ h('.network-name', props.t('privateNetwork')),
h('i.fa.fa-chevron-down.fa-lg.network-caret'),
])
}
diff --git a/ui/app/components/notice.js b/ui/app/components/notice.js
index 8b0ce1e8b..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')
+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('accept')),
+ }, this.props.t('accept')),
])
)
}
diff --git a/ui/app/components/pages/add-token.js b/ui/app/components/pages/add-token.js
index 3b7a65b21..b33373c19 100644
--- a/ui/app/components/pages/add-token.js
+++ b/ui/app/components/pages/add-token.js
@@ -2,7 +2,7 @@ const inherits = require('util').inherits
const Component = require('react').Component
const classnames = require('classnames')
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
+const connect = require('./metamask-connect')
const R = require('ramda')
const Fuse = require('fuse.js')
const contractMap = require('eth-contract-metadata')
@@ -25,7 +25,6 @@ const fuse = new Fuse(contractList, {
})
const actions = require('../../actions')
const ethUtil = require('ethereumjs-util')
-const t = require('../../../i18n')
const { tokenInfoGetter } = require('../../token-util')
const { DEFAULT_ROUTE } = require('../../routes')
@@ -140,28 +139,31 @@ AddTokenScreen.prototype.validate = function () {
if (customAddress) {
const validAddress = ethUtil.isValidAddress(customAddress)
if (!validAddress) {
- errors.customAddress = t('invalidAddress')
+ errors.customAddress = this.props.t('invalidAddress')
}
- const validDecimals = customDecimals !== null && customDecimals >= 0 && customDecimals < 36
+ const validDecimals = customDecimals !== null
+ && customDecimals !== ''
+ && customDecimals >= 0
+ && customDecimals < 36
if (!validDecimals) {
- errors.customDecimals = t('decimalsMustZerotoTen')
+ errors.customDecimals = this.props.t('decimalsMustZerotoTen')
}
const symbolLen = customSymbol.trim().length
const validSymbol = symbolLen > 0 && symbolLen < 10
if (!validSymbol) {
- errors.customSymbol = t('symbolBetweenZeroTen')
+ errors.customSymbol = this.props.t('symbolBetweenZeroTen')
}
const ownAddress = identitiesList.includes(standardAddress)
if (ownAddress) {
- errors.customAddress = t('personalAddressDetected')
+ errors.customAddress = this.props.t('personalAddressDetected')
}
const tokenAlreadyAdded = this.checkExistingAddresses(customAddress)
if (tokenAlreadyAdded) {
- errors.customAddress = t('tokenAlreadyAdded')
+ errors.customAddress = this.props.t('tokenAlreadyAdded')
}
} else if (
Object.entries(selectedTokens)
@@ -169,7 +171,7 @@ AddTokenScreen.prototype.validate = function () {
isEmpty && !isSelected
), true)
) {
- errors.tokenSelector = t('mustSelectOne')
+ errors.tokenSelector = this.props.t('mustSelectOne')
}
return {
@@ -199,7 +201,7 @@ AddTokenScreen.prototype.renderCustomForm = function () {
'add-token__add-custom-field--error': errors.customAddress,
}),
}, [
- h('div.add-token__add-custom-label', t('tokenAddress')),
+ h('div.add-token__add-custom-label', this.props.t('tokenAddress')),
h('input.add-token__add-custom-input', {
type: 'text',
onChange: this.tokenAddressDidChange,
@@ -212,7 +214,7 @@ AddTokenScreen.prototype.renderCustomForm = function () {
'add-token__add-custom-field--error': errors.customSymbol,
}),
}, [
- h('div.add-token__add-custom-label', t('tokenSymbol')),
+ h('div.add-token__add-custom-label', this.props.t('tokenSymbol')),
h('input.add-token__add-custom-input', {
type: 'text',
onChange: this.tokenSymbolDidChange,
@@ -226,7 +228,7 @@ AddTokenScreen.prototype.renderCustomForm = function () {
'add-token__add-custom-field--error': errors.customDecimals,
}),
}, [
- h('div.add-token__add-custom-label', t('decimal')),
+ h('div.add-token__add-custom-label', this.props.t('decimal')),
h('input.add-token__add-custom-input', {
type: 'number',
onChange: this.tokenDecimalsDidChange,
@@ -248,7 +250,7 @@ AddTokenScreen.prototype.renderTokenList = function () {
const results = [...addressSearchResult, ...fuseSearchResult]
return h('div', [
- results.length > 0 && h('div.add-token__token-icons-title', t('popularTokens')),
+ results.length > 0 && h('div.add-token__token-icons-title', this.props.t('popularTokens')),
h('div.add-token__token-icons-container', Array(6).fill(undefined)
.map((_, i) => {
const { logo, symbol, name, address } = results[i] || {}
@@ -303,10 +305,10 @@ AddTokenScreen.prototype.renderConfirmation = function () {
h('div.add-token', [
h('div.add-token__wrapper', [
h('div.add-token__title-container.add-token__confirmation-title', [
- h('div.add-token__description', t('likeToAddTokens')),
+ h('div.add-token__description', this.props.t('likeToAddTokens')),
]),
h('div.add-token__content-container.add-token__confirmation-content', [
- h('div.add-token__description.add-token__confirmation-description', t('balances')),
+ h('div.add-token__description.add-token__confirmation-description', this.props.t('balances')),
h('div.add-token__confirmation-token-list',
Object.entries(tokens)
.map(([ address, token ]) => (
@@ -325,10 +327,10 @@ AddTokenScreen.prototype.renderConfirmation = function () {
h('div.add-token__buttons', [
h('button.btn-secondary--lg.add-token__cancel-button', {
onClick: () => this.setState({ isShowingConfirmation: false }),
- }, t('back')),
+ }, this.props.t('back')),
h('button.btn-primary--lg', {
onClick: () => addTokens(tokens).then(() => history.push(DEFAULT_ROUTE)),
- }, t('addTokens')),
+ }, this.props.t('addTokens')),
]),
])
)
@@ -348,14 +350,14 @@ AddTokenScreen.prototype.renderTabs = function () {
h('div.add-token__content-container', [
h('div.add-token__info-box', [
h('div.add-token__info-box__close'),
- h('div.add-token__info-box__title', t('whatsThis')),
- h('div.add-token__info-box__copy', t('keepTrackTokens')),
- h('div.add-token__info-box__copy--blue', t('learnMore')),
+ h('div.add-token__info-box__title', this.props.t('whatsThis')),
+ h('div.add-token__info-box__copy', this.props.t('keepTrackTokens')),
+ h('div.add-token__info-box__copy--blue', this.props.t('learnMore')),
]),
h('div.add-token__input-container', [
h('input.add-token__input', {
type: 'text',
- placeholder: t('searchTokens'),
+ placeholder: this.props.t('searchTokens'),
onChange: e => this.setState({ searchQuery: e.target.value }),
}),
h('div.add-token__search-input-error-message', errors.tokenSelector),
@@ -379,9 +381,9 @@ AddTokenScreen.prototype.render = function () {
onClick: () => history.goBack(),
}, [
h('i.fa.fa-angle-left.fa-lg'),
- h('span', t('cancel')),
+ h('span', this.props.t('cancel')),
]),
- h('div.add-token__header__title', t('addTokens')),
+ h('div.add-token__header__title', this.props.t('addTokens')),
!isShowingConfirmation && h('div.add-token__header__tabs', [
h('div.add-token__header__tabs__tab', {
@@ -390,7 +392,7 @@ AddTokenScreen.prototype.render = function () {
'add-token__header__tabs__unselected cursor-pointer': displayedTab !== 'SEARCH',
}),
onClick: () => this.displayTab('SEARCH'),
- }, t('search')),
+ }, this.props.t('search')),
h('div.add-token__header__tabs__tab', {
className: classnames('add-token__header__tabs__tab', {
@@ -398,11 +400,11 @@ AddTokenScreen.prototype.render = function () {
'add-token__header__tabs__unselected cursor-pointer': displayedTab !== 'CUSTOM_TOKEN',
}),
onClick: () => this.displayTab('CUSTOM_TOKEN'),
- }, t('customToken')),
+ }, this.props.t('customToken')),
]),
]),
-//
+
isShowingConfirmation
? this.renderConfirmation()
: this.renderTabs(),
@@ -410,10 +412,10 @@ AddTokenScreen.prototype.render = function () {
!isShowingConfirmation && h('div.add-token__buttons', [
h('button.btn-secondary--lg.add-token__cancel-button', {
onClick: () => history.goBack(),
- }, t('cancel')),
+ }, this.props.t('cancel')),
h('button.btn-primary--lg.add-token__confirm-button', {
onClick: this.onNext,
- }, t('next')),
+ }, this.props.t('next')),
]),
])
}
diff --git a/ui/app/components/pages/create-account/import-account/index.js b/ui/app/components/pages/create-account/import-account/index.js
index 8031ea36d..26353b670 100644
--- a/ui/app/components/pages/create-account/import-account/index.js
+++ b/ui/app/components/pages/create-account/import-account/index.js
@@ -1,43 +1,38 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
-const t = require('../../../../../i18n')
+const connect = require('../../../../metamask-connect')
import Select from 'react-select'
// Subviews
const JsonImportView = require('./json.js')
const PrivateKeyImportView = require('./private-key.js')
-const menuItems = [
- t('privateKey'),
- t('jsonFile'),
-]
-module.exports = connect(mapStateToProps)(AccountImportSubview)
-
-function mapStateToProps (state) {
- return {
- menuItems,
- }
-}
+module.exports = connect()(AccountImportSubview)
inherits(AccountImportSubview, Component)
function AccountImportSubview () {
Component.call(this)
}
+AccountImportSubview.prototype.getMenuItemTexts = function () {
+ return [
+ this.props.t('privateKey'),
+ this.props.t('jsonFile'),
+ ]
+}
+
AccountImportSubview.prototype.render = function () {
- const props = this.props
const state = this.state || {}
- const { menuItems } = props
+ const menuItems = this.getMenuItemTexts()
const { type } = state
return (
h('div.new-account-import-form', [
h('.new-account-import-disclaimer', [
- h('span', t('importAccountMsg')),
+ h('span', this.props.t('importAccountMsg')),
h('span', {
style: {
cursor: 'pointer',
@@ -48,12 +43,12 @@ AccountImportSubview.prototype.render = function () {
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts',
})
},
- }, t('here')),
+ }, this.props.t('here')),
]),
h('div.new-account-import-form__select-section', [
- h('div.new-account-import-form__select-label', t('selectType')),
+ h('div.new-account-import-form__select-label', this.props.t('selectType')),
h(Select, {
className: 'new-account-import-form__select',
@@ -79,16 +74,15 @@ AccountImportSubview.prototype.render = function () {
}
AccountImportSubview.prototype.renderImportView = function () {
- const props = this.props
const state = this.state || {}
const { type } = state
- const { menuItems } = props
+ const menuItems = this.getMenuItemTexts()
const current = type || menuItems[0]
switch (current) {
- case t('privateKey'):
+ case this.props.t('privateKey'):
return h(PrivateKeyImportView)
- case t('jsonFile'):
+ case this.props.t('jsonFile'):
return h(JsonImportView)
default:
return h(JsonImportView)
diff --git a/ui/app/components/pages/create-account/import-account/json.js b/ui/app/components/pages/create-account/import-account/json.js
index 554a67df4..2e858a8f0 100644
--- a/ui/app/components/pages/create-account/import-account/json.js
+++ b/ui/app/components/pages/create-account/import-account/json.js
@@ -3,10 +3,9 @@ const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
-const { connect } = require('react-redux')
+const connect = require('../../../../metamask-connect')
const actions = require('../../../../actions')
const FileInput = require('react-simple-file-input').default
-const t = require('../../../../../i18n')
const { DEFAULT_ROUTE } = require('../../../../routes')
const HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts'
@@ -26,11 +25,11 @@ class JsonImportSubview extends Component {
return (
h('div.new-account-import-form__json', [
- h('p', t('usedByClients')),
+ h('p', this.props.t('usedByClients')),
h('a.warning', {
href: HELP_LINK,
target: '_blank',
- }, t('fileImportFail')),
+ }, this.props.t('fileImportFail')),
h(FileInput, {
readAs: 'text',
@@ -45,7 +44,7 @@ class JsonImportSubview extends Component {
h('input.new-account-import-form__input-password', {
type: 'password',
- placeholder: t('enterPassword'),
+ placeholder: this.props.t('enterPassword'),
id: 'json-password-box',
onKeyPress: this.createKeyringOnEnter.bind(this),
}),
@@ -55,13 +54,13 @@ class JsonImportSubview extends Component {
h('button.btn-secondary.new-account-create-form__button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, [
- t('cancel'),
+ this.props.t('cancel'),
]),
h('button.btn-primary.new-account-create-form__button', {
onClick: () => this.createNewKeychain(),
}, [
- t('import'),
+ this.props.t('import'),
]),
]),
@@ -86,14 +85,14 @@ class JsonImportSubview extends Component {
const state = this.state
if (!state) {
- const message = t('validFileImport')
+ const message = this.props.t('validFileImport')
return this.props.displayWarning(message)
}
const { fileContents } = state
if (!fileContents) {
- const message = t('needImportFile')
+ const message = this.props.t('needImportFile')
return this.props.displayWarning(message)
}
@@ -101,7 +100,7 @@ class JsonImportSubview extends Component {
const password = passwordInput.value
if (!password) {
- const message = t('needImportPassword')
+ const message = this.props.t('needImportPassword')
return this.props.displayWarning(message)
}
@@ -115,6 +114,7 @@ JsonImportSubview.propTypes = {
displayWarning: PropTypes.func,
importNewJsonAccount: PropTypes.func,
history: PropTypes.object,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
diff --git a/ui/app/components/pages/create-account/import-account/private-key.js b/ui/app/components/pages/create-account/import-account/private-key.js
index a30492e3b..17a32c10f 100644
--- a/ui/app/components/pages/create-account/import-account/private-key.js
+++ b/ui/app/components/pages/create-account/import-account/private-key.js
@@ -3,10 +3,9 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
-const { connect } = require('react-redux')
+const connect = require('../../../../metamask-connect')
const actions = require('../../../../actions')
const { DEFAULT_ROUTE } = require('../../../../routes')
-const t = require('../../../../../i18n')
module.exports = compose(
withRouter,
@@ -39,7 +38,7 @@ PrivateKeyImportView.prototype.render = function () {
return (
h('div.new-account-import-form__private-key', [
- h('span.new-account-create-form__instruction', t('pastePrivateKey')),
+ h('span.new-account-create-form__instruction', this.props.t('pastePrivateKey')),
h('div.new-account-import-form__private-key-password-container', [
@@ -56,13 +55,13 @@ PrivateKeyImportView.prototype.render = function () {
h('button.btn-secondary--lg.new-account-create-form__button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, [
- t('cancel'),
+ this.props.t('cancel'),
]),
h('button.btn-primary--lg.new-account-create-form__button', {
onClick: () => this.createNewKeychain(),
}, [
- t('import'),
+ this.props.t('import'),
]),
]),
diff --git a/ui/app/components/pages/create-account/import-account/seed.js b/ui/app/components/pages/create-account/import-account/seed.js
index 85fa93faa..15dd98c73 100644
--- a/ui/app/components/pages/create-account/import-account/seed.js
+++ b/ui/app/components/pages/create-account/import-account/seed.js
@@ -1,8 +1,7 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
-const t = require('../../../../../i18n')
+const connect = require('../../../../metamask-connect')
module.exports = connect(mapStateToProps)(SeedImportSubview)
@@ -21,10 +20,10 @@ SeedImportSubview.prototype.render = function () {
style: {
},
}, [
- t('pasteSeed'),
+ this.props.t('pasteSeed'),
h('textarea'),
h('br'),
- h('button', t('submit')),
+ h('button', this.props.t('submit')),
])
)
}
diff --git a/ui/app/components/pages/create-account/new-account.js b/ui/app/components/pages/create-account/new-account.js
index ceeb8a05b..dfe2a2ab1 100644
--- a/ui/app/components/pages/create-account/new-account.js
+++ b/ui/app/components/pages/create-account/new-account.js
@@ -1,10 +1,9 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const { connect } = require('react-redux')
+const connect = require('../../../metamask-connect')
const actions = require('../../../actions')
const { DEFAULT_ROUTE } = require('../../../routes')
-const t = require('../../../../i18n')
class NewAccountCreateForm extends Component {
constructor (props) {
@@ -15,7 +14,7 @@ class NewAccountCreateForm extends Component {
this.state = {
newAccountName: '',
- defaultAccountName: t('newAccountNumberName', [newAccountNumber]),
+ defaultAccountName: this.props.t('newAccountNumberName', [newAccountNumber]),
}
}
@@ -26,7 +25,7 @@ class NewAccountCreateForm extends Component {
return h('div.new-account-create-form', [
h('div.new-account-create-form__input-label', {}, [
- t('accountName'),
+ this.props.t('accountName'),
]),
h('div.new-account-create-form__input-wrapper', {}, [
@@ -42,7 +41,7 @@ class NewAccountCreateForm extends Component {
h('button.btn-secondary--lg.new-account-create-form__button', {
onClick: () => history.push(DEFAULT_ROUTE),
}, [
- t('cancel'),
+ this.props.t('cancel'),
]),
h('button.btn-primary--lg.new-account-create-form__button', {
@@ -51,7 +50,7 @@ class NewAccountCreateForm extends Component {
.then(() => history.push(DEFAULT_ROUTE))
},
}, [
- t('create'),
+ this.props.t('create'),
]),
]),
@@ -66,6 +65,7 @@ NewAccountCreateForm.propTypes = {
createAccount: PropTypes.func,
numberOfExistingAccounts: PropTypes.number,
history: PropTypes.object,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
diff --git a/ui/app/components/pages/settings/info.js b/ui/app/components/pages/settings/info.js
index cb1782562..adb2fdfcd 100644
--- a/ui/app/components/pages/settings/info.js
+++ b/ui/app/components/pages/settings/info.js
@@ -1,7 +1,7 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const t = require('../../../../i18n')
+const connect = require('../../../metamask-connect')
class Info extends Component {
renderLogo () {
@@ -15,13 +15,13 @@ class Info extends Component {
renderInfoLinks () {
return (
h('div.settings__content-item.settings__content-item--without-height', [
- h('div.settings__info-link-header', t('links')),
+ h('div.settings__info-link-header', this.props.t('links')),
h('div.settings__info-link-item', [
h('a', {
href: 'https://metamask.io/privacy.html',
target: '_blank',
}, [
- h('span.settings__info-link', t('privacyMsg')),
+ h('span.settings__info-link', this.props.t('privacyMsg')),
]),
]),
h('div.settings__info-link-item', [
@@ -29,7 +29,7 @@ class Info extends Component {
href: 'https://metamask.io/terms.html',
target: '_blank',
}, [
- h('span.settings__info-link', t('terms')),
+ h('span.settings__info-link', this.props.t('terms')),
]),
]),
h('div.settings__info-link-item', [
@@ -37,7 +37,7 @@ class Info extends Component {
href: 'https://metamask.io/attributions.html',
target: '_blank',
}, [
- h('span.settings__info-link', t('attributions')),
+ h('span.settings__info-link', this.props.t('attributions')),
]),
]),
h('hr.settings__info-separator'),
@@ -46,7 +46,7 @@ class Info extends Component {
href: 'https://support.metamask.io',
target: '_blank',
}, [
- h('span.settings__info-link', t('supportCenter')),
+ h('span.settings__info-link', this.props.t('supportCenter')),
]),
]),
h('div.settings__info-link-item', [
@@ -54,7 +54,7 @@ class Info extends Component {
href: 'https://metamask.io/',
target: '_blank',
}, [
- h('span.settings__info-link', t('visitWebSite')),
+ h('span.settings__info-link', this.props.t('visitWebSite')),
]),
]),
h('div.settings__info-link-item', [
@@ -62,7 +62,7 @@ class Info extends Component {
target: '_blank',
href: 'mailto:help@metamask.io?subject=Feedback',
}, [
- h('span.settings__info-link', t('emailUs')),
+ h('span.settings__info-link', this.props.t('emailUs')),
]),
]),
])
@@ -82,7 +82,7 @@ class Info extends Component {
h('div.settings__info-item', [
h(
'div.settings__info-about',
- t('builtInCalifornia')
+ this.props.t('builtInCalifornia')
),
]),
]),
@@ -103,6 +103,7 @@ Info.propTypes = {
warning: PropTypes.string,
location: PropTypes.object,
history: PropTypes.object,
+ t: PropTypes.func,
}
-module.exports = Info
+module.exports = connect()(Info)
diff --git a/ui/app/components/pages/settings/settings.js b/ui/app/components/pages/settings/settings.js
index 219ace651..7b3704c4d 100644
--- a/ui/app/components/pages/settings/settings.js
+++ b/ui/app/components/pages/settings/settings.js
@@ -3,7 +3,7 @@ const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const { connect } = require('react-redux')
+const connect = require('../../../metamask-connect')
const actions = require('../../../actions')
const infuraCurrencies = require('../../../infura-conversion.json')
const validUrl = require('valid-url')
@@ -11,8 +11,8 @@ const { exportAsFile } = require('../../../util')
const SimpleDropdown = require('../../dropdowns/simple-dropdown')
const ToggleButton = require('react-toggle-button')
const { REVEAL_SEED_ROUTE } = require('../../../routes')
+const locales = require('../../../../../app/_locales/index.json')
const { OLD_UI_NETWORK_TYPE } = require('../../../../../app/scripts/config').enums
-const t = require('../../../../i18n')
const getInfuraCurrencyOptions = () => {
const sortedCurrencies = infuraCurrencies.objects.sort((a, b) => {
@@ -28,6 +28,16 @@ const getInfuraCurrencyOptions = () => {
})
}
+const getLocaleOptions = () => {
+ return locales.map((locale) => {
+ return {
+ displayValue: `${locale.name}`,
+ key: locale.code,
+ value: locale.code,
+ }
+ })
+}
+
class Settings extends Component {
constructor (props) {
super(props)
@@ -42,7 +52,7 @@ class Settings extends Component {
return h('div.settings__content-row', [
h('div.settings__content-item', [
- h('span', t('blockiesIdenticon')),
+ h('span', this.props.t('blockiesIdenticon')),
]),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
@@ -62,13 +72,13 @@ class Settings extends Component {
return h('div.settings__content-row', [
h('div.settings__content-item', [
- h('span', t('currentConversion')),
+ h('span', this.props.t('currentConversion')),
h('span.settings__content-description', `Updated ${Date(conversionDate)}`),
]),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
h(SimpleDropdown, {
- placeholder: t('selectCurrency'),
+ placeholder: this.props.t('selectCurrency'),
options: getInfuraCurrencyOptions(),
selectedOption: currentCurrency,
onSelect: newCurrency => setCurrentCurrency(newCurrency),
@@ -78,6 +88,30 @@ class Settings extends Component {
])
}
+ renderCurrentLocale () {
+ const { updateCurrentLocale, currentLocale } = this.props
+ const currentLocaleMeta = locales.find(locale => locale.code === currentLocale)
+
+ return h('div.settings__content-row', [
+ h('div.settings__content-item', [
+ h('span', 'Current Language'),
+ h('span.settings__content-description', `${currentLocaleMeta.name}`),
+ ]),
+ h('div.settings__content-item', [
+ h('div.settings__content-item-col', [
+ h(SimpleDropdown, {
+ placeholder: 'Select Locale',
+ options: getLocaleOptions(),
+ selectedOption: currentLocale,
+ onSelect: async (newLocale) => {
+ updateCurrentLocale(newLocale)
+ },
+ }),
+ ]),
+ ]),
+ ])
+ }
+
renderCurrentProvider () {
const { metamask: { provider = {} } } = this.props
let title, value, color
@@ -85,31 +119,31 @@ class Settings extends Component {
switch (provider.type) {
case 'mainnet':
- title = t('currentNetwork')
- value = t('mainnet')
+ title = this.props.t('currentNetwork')
+ value = this.props.t('mainnet')
color = '#038789'
break
case 'ropsten':
- title = t('currentNetwork')
- value = t('ropsten')
+ title = this.props.t('currentNetwork')
+ value = this.props.t('ropsten')
color = '#e91550'
break
case 'kovan':
- title = t('currentNetwork')
- value = t('kovan')
+ title = this.props.t('currentNetwork')
+ value = this.props.t('kovan')
color = '#690496'
break
case 'rinkeby':
- title = t('currentNetwork')
- value = t('rinkeby')
+ title = this.props.t('currentNetwork')
+ value = this.props.t('rinkeby')
color = '#ebb33f'
break
default:
- title = t('currentRpc')
+ title = this.props.t('currentRpc')
value = provider.rpcTarget
}
@@ -130,12 +164,12 @@ class Settings extends Component {
return (
h('div.settings__content-row', [
h('div.settings__content-item', [
- h('span', t('newRPC')),
+ h('span', this.props.t('newRPC')),
]),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
h('input.settings__input', {
- placeholder: t('newRPC'),
+ placeholder: this.props.t('newRPC'),
onChange: event => this.setState({ newRpc: event.target.value }),
onKeyPress: event => {
if (event.key === 'Enter') {
@@ -148,7 +182,7 @@ class Settings extends Component {
event.preventDefault()
this.validateRpc(this.state.newRpc)
},
- }, t('save')),
+ }, this.props.t('save')),
]),
]),
])
@@ -164,9 +198,9 @@ class Settings extends Component {
const appendedRpc = `http://${newRpc}`
if (validUrl.isWebUri(appendedRpc)) {
- displayWarning(t('uriErrorMsg'))
+ displayWarning(this.props.t('uriErrorMsg'))
} else {
- displayWarning(t('invalidRPC'))
+ displayWarning(this.props.t('invalidRPC'))
}
}
}
@@ -175,10 +209,10 @@ class Settings extends Component {
return (
h('div.settings__content-row', [
h('div.settings__content-item', [
- h('div', t('stateLogs')),
+ h('div', this.props.t('stateLogs')),
h(
'div.settings__content-description',
- t('stateLogsDescription')
+ this.props.t('stateLogsDescription')
),
]),
h('div.settings__content-item', [
@@ -187,13 +221,13 @@ class Settings extends Component {
onClick (event) {
window.logStateString((err, result) => {
if (err) {
- this.state.dispatch(actions.displayWarning(t('stateLogError')))
+ this.state.dispatch(actions.displayWarning(this.props.t('stateLogError')))
} else {
exportAsFile('MetaMask State Logs.json', result)
}
})
},
- }, t('downloadStateLogs')),
+ }, this.props.t('downloadStateLogs')),
]),
]),
])
@@ -205,12 +239,15 @@ class Settings extends Component {
return (
h('div.settings__content-row', [
- h('div.settings__content-item', t('revealSeedWords')),
+ h('div.settings__content-item', this.props.t('revealSeedWords')),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button--red', {
- onClick: () => history.push(REVEAL_SEED_ROUTE),
- }, t('revealSeedWords')),
+ onClick: event => {
+ event.preventDefault()
+ history.push(REVEAL_SEED_ROUTE)
+ },
+ }, this.props.t('revealSeedWords')),
]),
]),
])
@@ -222,7 +259,7 @@ class Settings extends Component {
return (
h('div.settings__content-row', [
- h('div.settings__content-item', t('useOldUI')),
+ h('div.settings__content-item', this.props.t('useOldUI')),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button--orange', {
@@ -230,7 +267,7 @@ class Settings extends Component {
event.preventDefault()
setFeatureFlagToBeta()
},
- }, t('useOldUI')),
+ }, this.props.t('useOldUI')),
]),
]),
])
@@ -241,7 +278,7 @@ class Settings extends Component {
const { showResetAccountConfirmationModal } = this.props
return h('div.settings__content-row', [
- h('div.settings__content-item', t('resetAccount')),
+ h('div.settings__content-item', this.props.t('resetAccount')),
h('div.settings__content-item', [
h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button--orange', {
@@ -249,7 +286,7 @@ class Settings extends Component {
event.preventDefault()
showResetAccountConfirmationModal()
},
- }, t('resetAccount')),
+ }, this.props.t('resetAccount')),
]),
]),
])
@@ -262,6 +299,7 @@ class Settings extends Component {
h('div.settings__content', [
warning && h('div.settings__error', warning),
this.renderCurrentConversion(),
+ this.renderCurrentLocale(),
// this.renderCurrentProvider(),
this.renderNewRpcUrl(),
this.renderStateLogs(),
@@ -286,6 +324,9 @@ Settings.propTypes = {
warning: PropTypes.string,
history: PropTypes.object,
isMascara: PropTypes.bool,
+ updateCurrentLocale: PropTypes.func,
+ currentLocale: PropTypes.string,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
@@ -293,6 +334,7 @@ const mapStateToProps = state => {
metamask: state.metamask,
warning: state.appState.warning,
isMascara: state.metamask.isMascara,
+ currentLocale: state.metamask.currentLocale,
}
}
@@ -303,6 +345,7 @@ const mapDispatchToProps = dispatch => {
displayWarning: warning => dispatch(actions.displayWarning(warning)),
revealSeedConfirmation: () => dispatch(actions.revealSeedConfirmation()),
setUseBlockie: value => dispatch(actions.setUseBlockie(value)),
+ updateCurrentLocale: key => dispatch(actions.updateCurrentLocale(key)),
setFeatureFlagToBeta: () => {
return dispatch(actions.setFeatureFlag('betaUI', false, 'OLD_UI_NOTIFICATION_MODAL'))
.then(() => dispatch(actions.setNetworkEndpoints(OLD_UI_NETWORK_TYPE)))
diff --git a/ui/app/components/pending-msg-details.js b/ui/app/components/pending-msg-details.js
index 87e66855d..ddec8470d 100644
--- a/ui/app/components/pending-msg-details.js
+++ b/ui/app/components/pending-msg-details.js
@@ -1,11 +1,11 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
const AccountPanel = require('./account-panel')
-module.exports = PendingMsgDetails
+module.exports = connect()(PendingMsgDetails)
inherits(PendingMsgDetails, Component)
function PendingMsgDetails () {
@@ -40,7 +40,7 @@ PendingMsgDetails.prototype.render = function () {
// message data
h('.tx-data.flex-column.flex-justify-center.flex-grow.select-none', [
h('.flex-column.flex-space-between', [
- h('label.font-small.allcaps', t('message')),
+ h('label.font-small.allcaps', this.props.t('message')),
h('span.font-small', msgParams.data),
]),
]),
diff --git a/ui/app/components/pending-msg.js b/ui/app/components/pending-msg.js
index dc406b955..56e646a1c 100644
--- a/ui/app/components/pending-msg.js
+++ b/ui/app/components/pending-msg.js
@@ -2,9 +2,9 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const PendingTxDetails = require('./pending-msg-details')
-const t = require('../../i18n')
+const connect = require('../metamask-connect')
-module.exports = PendingMsg
+module.exports = connect()(PendingMsg)
inherits(PendingMsg, Component)
function PendingMsg () {
@@ -30,14 +30,14 @@ PendingMsg.prototype.render = function () {
fontWeight: 'bold',
textAlign: 'center',
},
- }, t('signMessage')),
+ }, this.props.t('signMessage')),
h('.error', {
style: {
margin: '10px',
},
}, [
- t('signNotice'),
+ this.props.t('signNotice'),
h('a', {
href: 'https://medium.com/metamask/the-new-secure-way-to-sign-data-in-your-browser-6af9dd2a1527',
style: { color: 'rgb(247, 134, 28)' },
@@ -46,7 +46,7 @@ PendingMsg.prototype.render = function () {
const url = 'https://medium.com/metamask/the-new-secure-way-to-sign-data-in-your-browser-6af9dd2a1527'
global.platform.openWindow({ url })
},
- }, t('readMore')),
+ }, this.props.t('readMore')),
]),
// message details
@@ -56,10 +56,10 @@ PendingMsg.prototype.render = function () {
h('.flex-row.flex-space-around', [
h('button', {
onClick: state.cancelMessage,
- }, t('cancel')),
+ }, this.props.t('cancel')),
h('button', {
onClick: state.signMessage,
- }, t('sign')),
+ }, this.props.t('sign')),
]),
])
diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js
index b75f3a964..f41fa51e6 100644
--- a/ui/app/components/pending-tx/confirm-deploy-contract.js
+++ b/ui/app/components/pending-tx/confirm-deploy-contract.js
@@ -1,5 +1,5 @@
const { Component } = require('react')
-const { connect } = require('react-redux')
+const connect = require('../../metamask-connect')
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
const actions = require('../../actions')
@@ -8,7 +8,6 @@ const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
const { conversionUtil } = require('../../conversion-util')
-const t = require('../../../i18n')
const SenderToRecipient = require('../sender-to-recipient')
const NetworkDisplay = require('../network-display')
@@ -33,7 +32,7 @@ class ConfirmDeployContract extends Component {
if (valid && this.verifyGasParams()) {
this.props.sendTransaction(txMeta, event)
} else {
- this.props.displayWarning('invalidGasParams')
+ this.props.displayWarning(this.props.t('invalidGasParams'))
this.setState({ submitting: false })
}
}
@@ -178,7 +177,7 @@ class ConfirmDeployContract extends Component {
return (
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('gasFee') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('gasFee') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency.toUpperCase()}`),
@@ -217,8 +216,8 @@ class ConfirmDeployContract extends Component {
return (
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
@@ -248,11 +247,11 @@ class ConfirmDeployContract extends Component {
h('.page-container__header-row', [
h('span.page-container__back-button', {
onClick: () => backToAccountDetail(selectedAddress),
- }, t('back')),
+ }, this.props.t('back')),
window.METAMASK_UI_TYPE === 'notification' && h(NetworkDisplay),
]),
- h('.page-container__title', t('confirmContract')),
- h('.page-container__subtitle', t('pleaseReviewTransaction')),
+ h('.page-container__title', this.props.t('confirmContract')),
+ h('.page-container__subtitle', this.props.t('pleaseReviewTransaction')),
]),
// Main Send token Card
h('.page-container__content', [
@@ -275,7 +274,7 @@ class ConfirmDeployContract extends Component {
h('div.confirm-screen-rows', [
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('from') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('from') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', fromName),
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
@@ -283,9 +282,9 @@ class ConfirmDeployContract extends Component {
]),
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('to') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('to') ]),
h('div.confirm-screen-section-column', [
- h('div.confirm-screen-row-info', t('newContract')),
+ h('div.confirm-screen-row-info', this.props.t('newContract')),
]),
]),
@@ -303,12 +302,12 @@ class ConfirmDeployContract extends Component {
// Cancel Button
h('button.btn-cancel.page-container__footer-button.allcaps', {
onClick: event => this.cancel(event, txMeta),
- }, t('cancel')),
+ }, this.props.t('cancel')),
// Accept Button
h('button.btn-confirm.page-container__footer-button.allcaps', {
onClick: event => this.onSubmit(event),
- }, t('confirm')),
+ }, this.props.t('confirm')),
]),
]),
])
@@ -325,6 +324,7 @@ ConfirmDeployContract.propTypes = {
conversionRate: PropTypes.number,
currentCurrency: PropTypes.string,
selectedAddress: PropTypes.string,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
@@ -347,8 +347,8 @@ const mapDispatchToProps = dispatch => {
return {
backToAccountDetail: address => dispatch(actions.backToAccountDetail(address)),
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
- displayWarning: warning => actions.displayWarning(t(warning)),
+ displayWarning: warning => actions.displayWarning(warning),
}
}
-module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract)
+module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract) \ No newline at end of file
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index f71b089ec..4ba0f55dc 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const { connect } = require('react-redux')
+const connect = require('../../metamask-connect')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const h = require('react-hyperscript')
@@ -15,7 +15,6 @@ const {
multiplyCurrencies,
} = require('../../conversion-util')
const GasFeeDisplay = require('../send/gas-fee-display-v2')
-const t = require('../../../i18n')
const SenderToRecipient = require('../sender-to-recipient')
const NetworkDisplay = require('../network-display')
@@ -202,7 +201,7 @@ ConfirmSendEther.prototype.getData = function () {
},
to: {
address: txParams.to,
- name: identities[txParams.to] ? identities[txParams.to].name : t('newRecipient'),
+ name: identities[txParams.to] ? identities[txParams.to].name : this.props.t('newRecipient'),
},
memo: txParams.memo || '',
gasFeeInFIAT,
@@ -309,7 +308,7 @@ ConfirmSendEther.prototype.render = function () {
h('div.confirm-screen-rows', [
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('from') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('from') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', fromName),
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
@@ -317,7 +316,7 @@ ConfirmSendEther.prototype.render = function () {
]),
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('to') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('to') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', toName),
h('div.confirm-screen-row-detail', `...${toAddress.slice(toAddress.length - 4)}`),
@@ -325,7 +324,7 @@ ConfirmSendEther.prototype.render = function () {
]),
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('gasFee') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('gasFee') ]),
h('div.confirm-screen-section-column', [
h(GasFeeDisplay, {
gasTotal: gasTotal || gasFeeInHex,
@@ -338,8 +337,8 @@ ConfirmSendEther.prototype.render = function () {
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
@@ -440,10 +439,10 @@ ConfirmSendEther.prototype.render = function () {
clearSend()
this.cancel(event, txMeta)
},
- }, t('cancel')),
+ }, this.props.t('cancel')),
// Accept Button
- h('button.btn-confirm.page-container__footer-button.allcaps', [t('confirm')]),
+ h('button.btn-confirm.page-container__footer-button.allcaps', [this.props.t('confirm')]),
]),
]),
])
@@ -459,7 +458,7 @@ ConfirmSendEther.prototype.onSubmit = function (event) {
if (valid && this.verifyGasParams()) {
this.props.sendTransaction(txMeta, event)
} else {
- this.props.dispatch(actions.displayWarning(t('invalidGasParams')))
+ this.props.dispatch(actions.displayWarning(this.props.t('invalidGasParams')))
this.setState({ submitting: false })
}
}
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index c8e51ccd2..9e30d9e3b 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const { connect } = require('react-redux')
+const connect = require('../../metamask-connect')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const h = require('react-hyperscript')
@@ -8,7 +8,6 @@ const tokenAbi = require('human-standard-token-abi')
const abiDecoder = require('abi-decoder')
abiDecoder.addABI(tokenAbi)
const actions = require('../../actions')
-const t = require('../../../i18n')
const clone = require('clone')
const Identicon = require('../identicon')
const GasFeeDisplay = require('../send/gas-fee-display-v2.js')
@@ -181,7 +180,7 @@ ConfirmSendToken.prototype.getAmount = function () {
? +(sendTokenAmount * tokenExchangeRate * conversionRate).toFixed(2)
: null,
token: typeof value === 'undefined'
- ? t('unknown')
+ ? this.props.t('unknown')
: +sendTokenAmount.toFixed(decimals),
}
@@ -253,7 +252,7 @@ ConfirmSendToken.prototype.getData = function () {
},
to: {
address: value,
- name: identities[value] ? identities[value].name : t('newRecipient'),
+ name: identities[value] ? identities[value].name : this.props.t('newRecipient'),
},
memo: txParams.memo || '',
}
@@ -299,7 +298,7 @@ ConfirmSendToken.prototype.renderGasFee = function () {
return (
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('gasFee') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('gasFee') ]),
h('div.confirm-screen-section-column', [
h(GasFeeDisplay, {
gasTotal: gasTotal || gasFeeInHex,
@@ -321,8 +320,8 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () {
? (
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
@@ -334,13 +333,13 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () {
: (
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', `${tokenAmount} ${symbol}`),
- h('div.confirm-screen-row-detail', `+ ${fiatGas} ${currentCurrency} ${t('gas')}`),
+ h('div.confirm-screen-row-detail', `+ ${fiatGas} ${currentCurrency} ${this.props.t('gas')}`),
]),
])
)
@@ -362,10 +361,11 @@ ConfirmSendToken.prototype.render = function () {
this.inputs = []
- const title = txMeta.lastGasPrice ? 'Reprice Transaction' : t('confirm')
- const subtitle = txMeta.lastGasPrice
- ? 'Increase your gas fee to attempt to overwrite and speed up your transaction'
- : t('pleaseReviewTransaction')
+ const isTxReprice = Boolean(txMeta.lastGasPrice)
+ const title = isTxReprice ? this.props.t('reprice_title') : this.props.t('confirm')
+ const subtitle = isTxReprice
+ ? this.props.t('reprice_subtitle')
+ : this.props.t('pleaseReviewTransaction')
return (
h('div.confirm-screen-container.confirm-send-token', [
@@ -374,7 +374,7 @@ ConfirmSendToken.prototype.render = function () {
h('div.page-container__header', [
!txMeta.lastGasPrice && h('button.confirm-screen-back-button', {
onClick: () => editTransaction(txMeta),
- }, t('edit')),
+ }, this.props.t('edit')),
h('div.page-container__title', title),
h('div.page-container__subtitle', subtitle),
]),
@@ -418,7 +418,7 @@ ConfirmSendToken.prototype.render = function () {
h('div.confirm-screen-rows', [
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('from') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('from') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', fromName),
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
@@ -426,7 +426,7 @@ ConfirmSendToken.prototype.render = function () {
]),
toAddress && h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ t('to') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('to') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', toName),
h('div.confirm-screen-row-detail', `...${toAddress.slice(toAddress.length - 4)}`),
@@ -440,6 +440,7 @@ ConfirmSendToken.prototype.render = function () {
]),
]),
+
h('form#pending-tx-form', {
onSubmit: this.onSubmit,
}, [
@@ -447,10 +448,10 @@ ConfirmSendToken.prototype.render = function () {
// Cancel Button
h('button.btn-cancel.page-container__footer-button.allcaps', {
onClick: (event) => this.cancel(event, txMeta),
- }, t('cancel')),
+ }, this.props.t('cancel')),
// Accept Button
- h('button.btn-confirm.page-container__footer-button.allcaps', [t('confirm')]),
+ h('button.btn-confirm.page-container__footer-button.allcaps', [this.props.t('confirm')]),
]),
]),
]),
@@ -467,7 +468,7 @@ ConfirmSendToken.prototype.onSubmit = function (event) {
if (valid && this.verifyGasParams()) {
this.props.sendTransaction(txMeta, event)
} else {
- this.props.dispatch(actions.displayWarning(t('invalidGasParams')))
+ this.props.dispatch(actions.displayWarning(this.props.t('invalidGasParams')))
this.setState({ submitting: false })
}
}
diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js
index 9c0453a3b..0a8813b03 100644
--- a/ui/app/components/pending-tx/index.js
+++ b/ui/app/components/pending-tx/index.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const { connect } = require('react-redux')
+const connect = require('../../metamask-connect')
const h = require('react-hyperscript')
const clone = require('clone')
const abi = require('human-standard-token-abi')
diff --git a/ui/app/components/qr-code.js b/ui/app/components/qr-code.js
index 83885539c..89504eca3 100644
--- a/ui/app/components/qr-code.js
+++ b/ui/app/components/qr-code.js
@@ -2,7 +2,7 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const qrCode = require('qrcode-npm').qrcode
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const isHexPrefixed = require('ethereumjs-util').isHexPrefixed
const ReadOnlyInput = require('./readonly-input')
diff --git a/ui/app/components/send/account-list-item.js b/ui/app/components/send/account-list-item.js
index 1ad3f69c1..749339694 100644
--- a/ui/app/components/send/account-list-item.js
+++ b/ui/app/components/send/account-list-item.js
@@ -1,7 +1,7 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const Identicon = require('../identicon')
const CurrencyDisplay = require('./currency-display')
const { conversionRateSelector, getCurrentCurrency } = require('../../selectors')
diff --git a/ui/app/components/send/gas-fee-display-v2.js b/ui/app/components/send/gas-fee-display-v2.js
index f6af13454..76ed1b5d4 100644
--- a/ui/app/components/send/gas-fee-display-v2.js
+++ b/ui/app/components/send/gas-fee-display-v2.js
@@ -2,9 +2,9 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const CurrencyDisplay = require('./currency-display')
-const t = require('../../../i18n')
+const connect = require('../../metamask-connect')
-module.exports = GasFeeDisplay
+module.exports = connect()(GasFeeDisplay)
inherits(GasFeeDisplay, Component)
function GasFeeDisplay () {
@@ -33,8 +33,8 @@ GasFeeDisplay.prototype.render = function () {
readOnly: true,
})
: gasLoadingError
- ? h('div..currency-display.currency-display--message', 'Set with the gas price customizer.')
- : h('div.currency-display', t('loading')),
+ ? h('div.currency-display.currency-display--message', this.props.t('setGasPrice'))
+ : h('div.currency-display', this.props.t('loading')),
h('button.sliders-icon-container', {
onClick,
diff --git a/ui/app/components/send/gas-tooltip.js b/ui/app/components/send/gas-tooltip.js
index d925d3ed8..607394c8b 100644
--- a/ui/app/components/send/gas-tooltip.js
+++ b/ui/app/components/send/gas-tooltip.js
@@ -2,9 +2,9 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const InputNumber = require('../input-number.js')
-const t = require('../../../i18n')
+const connect = require('../../metamask-connect')
-module.exports = GasTooltip
+module.exports = connect()(GasTooltip)
inherits(GasTooltip, Component)
function GasTooltip () {
@@ -82,7 +82,7 @@ GasTooltip.prototype.render = function () {
'marginTop': '81px',
},
}, [
- h('span.gas-tooltip-label', {}, [t('gasLimit')]),
+ h('span.gas-tooltip-label', {}, [this.props.t('gasLimit')]),
h('i.fa.fa-info-circle'),
]),
h(InputNumber, {
diff --git a/ui/app/components/send/send-v2-container.js b/ui/app/components/send/send-v2-container.js
index aca1a5a0a..e2c1dd49b 100644
--- a/ui/app/components/send/send-v2-container.js
+++ b/ui/app/components/send/send-v2-container.js
@@ -1,4 +1,4 @@
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const actions = require('../../actions')
const abi = require('ethereumjs-abi')
const SendEther = require('../../send-v2')
diff --git a/ui/app/components/send/to-autocomplete.js b/ui/app/components/send/to-autocomplete.js
index 72074229e..4c54701cb 100644
--- a/ui/app/components/send/to-autocomplete.js
+++ b/ui/app/components/send/to-autocomplete.js
@@ -2,9 +2,9 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const AccountListItem = require('./account-list-item')
-const t = require('../../../i18n')
+const connect = require('../../metamask-connect')
-module.exports = ToAutoComplete
+module.exports = connect()(ToAutoComplete)
inherits(ToAutoComplete, Component)
function ToAutoComplete () {
@@ -93,7 +93,7 @@ ToAutoComplete.prototype.render = function () {
return h('div.send-v2__to-autocomplete', {}, [
h('input.send-v2__to-autocomplete__input', {
- placeholder: t('recipientAddress'),
+ placeholder: this.props.t('recipientAddress'),
className: inError ? `send-v2__error-border` : '',
value: to,
onChange: event => onChange(event.target.value),
diff --git a/ui/app/components/sender-to-recipient.js b/ui/app/components/sender-to-recipient.js
index f35c353ad..4c3881668 100644
--- a/ui/app/components/sender-to-recipient.js
+++ b/ui/app/components/sender-to-recipient.js
@@ -1,7 +1,7 @@
const { Component } = require('react')
const h = require('react-hyperscript')
+const connect = require('../metamask-connect')
const PropTypes = require('prop-types')
-const t = require('../../i18n')
const Identicon = require('./identicon')
class SenderToRecipient extends Component {
@@ -21,7 +21,7 @@ class SenderToRecipient extends Component {
this.renderRecipientIcon(),
h(
'.sender-to-recipient__name.sender-to-recipient__recipient-name',
- recipientName || t('newContract')
+ recipientName || this.props.t('newContract')
),
])
)
@@ -61,6 +61,7 @@ SenderToRecipient.propTypes = {
senderAddress: PropTypes.string,
recipientName: PropTypes.string,
recipientAddress: PropTypes.string,
+ t: PropTypes.func,
}
-module.exports = SenderToRecipient
+module.exports = connect()(SenderToRecipient)
diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js
index 5729f893c..5f58527fe 100644
--- a/ui/app/components/shapeshift-form.js
+++ b/ui/app/components/shapeshift-form.js
@@ -1,13 +1,12 @@
const h = require('react-hyperscript')
const inherits = require('util').inherits
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const classnames = require('classnames')
const { qrcode } = require('qrcode-npm')
const { shapeShiftSubview, pairUpdate, buyWithShapeShift } = require('../actions')
const { isValidAddress } = require('../util')
const SimpleDropdown = require('./dropdowns/simple-dropdown')
-const t = require('../../i18n')
function mapStateToProps (state) {
const {
@@ -94,7 +93,7 @@ ShapeshiftForm.prototype.onBuyWithShapeShift = function () {
}))
.catch(() => this.setState({
showQrCode: false,
- errorMessage: t('invalidRequest'),
+ errorMessage: this.props.t('invalidRequest'),
isLoading: false,
}))
}
@@ -126,10 +125,10 @@ ShapeshiftForm.prototype.renderMarketInfo = function () {
return h('div.shapeshift-form__metadata', {}, [
- this.renderMetadata(t('status'), limit ? t('available') : t('unavailable')),
- this.renderMetadata(t('limit'), limit),
- this.renderMetadata(t('exchangeRate'), rate),
- this.renderMetadata(t('min'), minimum),
+ this.renderMetadata(this.props.t('status'), limit ? this.props.t('available') : this.props.t('unavailable')),
+ this.renderMetadata(this.props.t('limit'), limit),
+ this.renderMetadata(this.props.t('exchangeRate'), rate),
+ this.renderMetadata(this.props.t('min'), minimum),
])
}
@@ -143,7 +142,7 @@ ShapeshiftForm.prototype.renderQrCode = function () {
return h('div.shapeshift-form', {}, [
h('div.shapeshift-form__deposit-instruction', [
- t('depositCoin', [depositCoin.toUpperCase()]),
+ this.props.t('depositCoin', [depositCoin.toUpperCase()]),
]),
h('div', depositAddress),
@@ -180,7 +179,7 @@ ShapeshiftForm.prototype.render = function () {
h('div.shapeshift-form__selector', [
- h('div.shapeshift-form__selector-label', t('deposit')),
+ h('div.shapeshift-form__selector-label', this.props.t('deposit')),
h(SimpleDropdown, {
selectedOption: this.state.depositCoin,
@@ -200,7 +199,7 @@ ShapeshiftForm.prototype.render = function () {
h('div.shapeshift-form__selector', [
h('div.shapeshift-form__selector-label', [
- t('receive'),
+ this.props.t('receive'),
]),
h('div.shapeshift-form__selector-input', ['ETH']),
@@ -218,7 +217,7 @@ ShapeshiftForm.prototype.render = function () {
}, [
h('div.shapeshift-form__address-input-label', [
- t('refundAddress'),
+ this.props.t('refundAddress'),
]),
h('input.shapeshift-form__address-input', {
@@ -240,7 +239,7 @@ ShapeshiftForm.prototype.render = function () {
className: btnClass,
disabled: !token,
onClick: () => this.onBuyWithShapeShift(),
- }, [t('buy')]),
+ }, [this.props.t('buy')]),
])
}
diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js
index fddbc6821..d810eddc9 100644
--- a/ui/app/components/shift-list-item.js
+++ b/ui/app/components/shift-list-item.js
@@ -1,12 +1,11 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const vreme = new (require('vreme'))()
const explorerLink = require('etherscan-link').createExplorerLink
const actions = require('../actions')
const addressSummary = require('../util').addressSummary
-const t = require('../../i18n')
const CopyButton = require('./copyButton')
const EthBalance = require('./eth-balance')
@@ -76,7 +75,7 @@ ShiftListItem.prototype.renderUtilComponents = function () {
value: this.props.depositAddress,
}),
h(Tooltip, {
- title: t('qrCode'),
+ title: this.props.t('qrCode'),
}, [
h('i.fa.fa-qrcode.pointer.pop-hover', {
onClick: () => props.dispatch(actions.reshowQrCode(props.depositAddress, props.depositType)),
@@ -136,8 +135,8 @@ ShiftListItem.prototype.renderInfo = function () {
color: '#ABA9AA',
width: '100%',
},
- }, t('toETHviaShapeShift', [props.depositType])),
- h('div', t('noDeposits')),
+ }, this.props.t('toETHviaShapeShift', [props.depositType])),
+ h('div', this.props.t('noDeposits')),
h('div', {
style: {
fontSize: 'x-small',
@@ -159,8 +158,8 @@ ShiftListItem.prototype.renderInfo = function () {
color: '#ABA9AA',
width: '100%',
},
- }, t('toETHviaShapeShift', [props.depositType])),
- h('div', t('conversionProgress')),
+ }, this.props.t('toETHviaShapeShift', [props.depositType])),
+ h('div', this.props.t('conversionProgress')),
h('div', {
style: {
fontSize: 'x-small',
@@ -185,7 +184,7 @@ ShiftListItem.prototype.renderInfo = function () {
color: '#ABA9AA',
width: '100%',
},
- }, t('fromShapeShift')),
+ }, this.props.t('fromShapeShift')),
h('div', formatDate(props.time)),
h('div', {
style: {
@@ -197,7 +196,7 @@ ShiftListItem.prototype.renderInfo = function () {
])
case 'failed':
- return h('span.error', '(' + t('failed') + ')')
+ return h('span.error', '(' + this.props.t('failed') + ')')
default:
return ''
}
diff --git a/ui/app/components/signature-request.js b/ui/app/components/signature-request.js
index 810a52e55..b76c1e60f 100644
--- a/ui/app/components/signature-request.js
+++ b/ui/app/components/signature-request.js
@@ -2,14 +2,13 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const Identicon = require('./identicon')
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const ethUtil = require('ethereumjs-util')
const classnames = require('classnames')
const AccountDropdownMini = require('./dropdowns/account-dropdown-mini')
const actions = require('../actions')
-const t = require('../../i18n')
const { conversionUtil } = require('../conversion-util')
const {
@@ -55,7 +54,7 @@ SignatureRequest.prototype.renderHeader = function () {
h('div.request-signature__header-background'),
- h('div.request-signature__header__text', t('sigRequest')),
+ h('div.request-signature__header__text', this.props.t('sigRequest')),
h('div.request-signature__header__tip-container', [
h('div.request-signature__header__tip'),
@@ -76,7 +75,7 @@ SignatureRequest.prototype.renderAccountDropdown = function () {
return h('div.request-signature__account', [
- h('div.request-signature__account-text', [t('account') + ':']),
+ h('div.request-signature__account-text', [this.props.t('account') + ':']),
h(AccountDropdownMini, {
selectedAccount,
@@ -103,7 +102,7 @@ SignatureRequest.prototype.renderBalance = function () {
return h('div.request-signature__balance', [
- h('div.request-signature__balance-text', [t('balance')]),
+ h('div.request-signature__balance-text', [this.props.t('balance')]),
h('div.request-signature__balance-value', `${balanceInEther} ETH`),
@@ -137,7 +136,7 @@ SignatureRequest.prototype.renderRequestInfo = function () {
return h('div.request-signature__request-info', [
h('div.request-signature__headline', [
- t('yourSigRequested'),
+ this.props.t('yourSigRequested'),
]),
])
@@ -155,18 +154,18 @@ SignatureRequest.prototype.msgHexToText = function (hex) {
SignatureRequest.prototype.renderBody = function () {
let rows
- let notice = t('youSign') + ':'
+ let notice = this.props.t('youSign') + ':'
const { txData } = this.props
const { type, msgParams: { data } } = txData
if (type === 'personal_sign') {
- rows = [{ name: t('message'), value: this.msgHexToText(data) }]
+ rows = [{ name: this.props.t('message'), value: this.msgHexToText(data) }]
} else if (type === 'eth_signTypedData') {
rows = data
} else if (type === 'eth_sign') {
- rows = [{ name: t('message'), value: data }]
- notice = t('signNotice')
+ rows = [{ name: this.props.t('message'), value: data }]
+ notice = this.props.t('signNotice')
}
return h('div.request-signature__body', {}, [
@@ -225,10 +224,10 @@ SignatureRequest.prototype.renderFooter = function () {
return h('div.request-signature__footer', [
h('button.btn-secondary--lg.request-signature__footer__cancel-button', {
onClick: cancel,
- }, t('cancel')),
+ }, this.props.t('cancel')),
h('button.btn-primary--lg', {
onClick: sign,
- }, t('sign')),
+ }, this.props.t('sign')),
])
}
diff --git a/ui/app/components/token-balance.js b/ui/app/components/token-balance.js
index 2f71c0687..7d7744fe6 100644
--- a/ui/app/components/token-balance.js
+++ b/ui/app/components/token-balance.js
@@ -2,7 +2,7 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const TokenTracker = require('eth-token-tracker')
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const selectors = require('../selectors')
function mapStateToProps (state) {
diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js
index 0332fde88..a24781af1 100644
--- a/ui/app/components/token-cell.js
+++ b/ui/app/components/token-cell.js
@@ -1,7 +1,7 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const Identicon = require('./identicon')
const prefixForNetwork = require('../../lib/etherscan-prefix-for-network')
const selectors = require('../selectors')
diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js
index 01529aeda..ae22f3702 100644
--- a/ui/app/components/token-list.js
+++ b/ui/app/components/token-list.js
@@ -3,9 +3,8 @@ const h = require('react-hyperscript')
const inherits = require('util').inherits
const TokenTracker = require('eth-token-tracker')
const TokenCell = require('./token-cell.js')
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const selectors = require('../selectors')
-const t = require('../../i18n')
function mapStateToProps (state) {
return {
@@ -43,7 +42,7 @@ TokenList.prototype.render = function () {
const { tokens, isLoading, error } = state
if (isLoading) {
- return this.message(t('loadingTokens'))
+ return this.message(this.props.t('loadingTokens'))
}
if (error) {
@@ -53,7 +52,7 @@ TokenList.prototype.render = function () {
padding: '80px',
},
}, [
- t('troubleTokenBalances'),
+ this.props.t('troubleTokenBalances'),
h('span.hotFix', {
style: {
color: 'rgba(247, 134, 28, 1)',
@@ -64,7 +63,7 @@ TokenList.prototype.render = function () {
url: `https://ethplorer.io/address/${userAddress}`,
})
},
- }, t('here')),
+ }, this.props.t('here')),
])
}
diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js
index d104eda88..5e88d38d3 100644
--- a/ui/app/components/tx-list-item.js
+++ b/ui/app/components/tx-list-item.js
@@ -1,6 +1,6 @@
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const inherits = require('util').inherits
const classnames = require('classnames')
const abi = require('human-standard-token-abi')
@@ -14,7 +14,6 @@ const { conversionUtil, multiplyCurrencies } = require('../conversion-util')
const { calcTokenAmount } = require('../token-util')
const { getCurrentCurrency } = require('../selectors')
-const t = require('../../i18n')
module.exports = connect(mapStateToProps, mapDispatchToProps)(TxListItem)
@@ -75,7 +74,7 @@ TxListItem.prototype.getAddressText = function () {
default:
return address
? `${address.slice(0, 10)}...${address.slice(-4)}`
- : t('contractDeployment')
+ : this.props.t('contractDeployment')
}
}
@@ -307,21 +306,21 @@ TxListItem.prototype.txStatusIndicator = function () {
let name
if (transactionStatus === 'unapproved') {
- name = t('unapproved')
+ name = this.props.t('unapproved')
} else if (transactionStatus === 'rejected') {
- name = t('rejected')
+ name = this.props.t('rejected')
} else if (transactionStatus === 'approved') {
- name = t('approved')
+ name = this.props.t('approved')
} else if (transactionStatus === 'signed') {
- name = t('signed')
+ name = this.props.t('signed')
} else if (transactionStatus === 'submitted') {
- name = t('submitted')
+ name = this.props.t('submitted')
} else if (transactionStatus === 'confirmed') {
- name = t('confirmed')
+ name = this.props.t('confirmed')
} else if (transactionStatus === 'failed') {
- name = t('failed')
+ name = this.props.t('failed')
} else if (transactionStatus === 'dropped') {
- name = t('dropped')
+ name = this.props.t('dropped')
}
return name
}
diff --git a/ui/app/components/tx-list.js b/ui/app/components/tx-list.js
index 6236ddf49..ca683f764 100644
--- a/ui/app/components/tx-list.js
+++ b/ui/app/components/tx-list.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const h = require('react-hyperscript')
const inherits = require('util').inherits
const prefixForNetwork = require('../../lib/etherscan-prefix-for-network')
@@ -13,7 +13,6 @@ const { tokenInfoGetter } = require('../token-util')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const { CONFIRM_TRANSACTION_ROUTE } = require('../routes')
-const t = require('../../i18n')
module.exports = compose(
withRouter,
@@ -46,7 +45,7 @@ TxList.prototype.render = function () {
return h('div.flex-column', [
h('div.flex-row.tx-list-header-wrapper', [
h('div.flex-row.tx-list-header', [
- h('div', t('transactions')),
+ h('div', this.props.t('transactions')),
]),
]),
h('div.flex-column.tx-list-container', {}, [
@@ -63,7 +62,7 @@ TxList.prototype.renderTransaction = function () {
: [h(
'div.tx-list-item.tx-list-item--empty',
{ key: 'tx-list-none' },
- [ t('noTransactions') ],
+ [ this.props.t('noTransactions') ],
)]
}
@@ -117,7 +116,7 @@ TxList.prototype.renderTransactionListItem = function (transaction, conversionRa
if (isUnapproved) {
opts.onClick = () => history.push(CONFIRM_TRANSACTION_ROUTE)
- opts.transactionStatus = t('Not Started')
+ opts.transactionStatus = this.props.t('notStarted')
} else if (transactionHash) {
opts.onClick = () => this.view(transactionHash, transactionNetworkId)
}
diff --git a/ui/app/components/tx-view.js b/ui/app/components/tx-view.js
index 89d8d15df..a5f737d82 100644
--- a/ui/app/components/tx-view.js
+++ b/ui/app/components/tx-view.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const h = require('react-hyperscript')
const ethUtil = require('ethereumjs-util')
const inherits = require('util').inherits
@@ -8,7 +8,6 @@ const { compose } = require('recompose')
const actions = require('../actions')
const selectors = require('../selectors')
const { SEND_ROUTE } = require('../routes')
-const t = require('../../i18n')
const BalanceComponent = require('./balance-component')
const TxList = require('./tx-list')
@@ -79,21 +78,21 @@ TxView.prototype.renderButtons = function () {
onClick: () => showModal({
name: 'DEPOSIT_ETHER',
}),
- }, t('deposit')),
+ }, this.props.t('deposit')),
h('button.btn-primary.hero-balance-button', {
style: {
marginLeft: '0.8em',
},
onClick: () => history.push(SEND_ROUTE),
- }, t('send')),
+ }, this.props.t('send')),
])
)
: (
h('div.flex-row.flex-center.hero-balance-buttons', [
h('button.btn-primary.hero-balance-button', {
onClick: () => history.push(SEND_ROUTE),
- }, t('send')),
+ }, this.props.t('send')),
])
)
}
diff --git a/ui/app/components/wallet-view.js b/ui/app/components/wallet-view.js
index e7c7afc61..c0042614a 100644
--- a/ui/app/components/wallet-view.js
+++ b/ui/app/components/wallet-view.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../metamask-connect')
const h = require('react-hyperscript')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
@@ -14,7 +14,6 @@ const BalanceComponent = require('./balance-component')
const TokenList = require('./token-list')
const selectors = require('../selectors')
const { ADD_TOKEN_ROUTE } = require('../routes')
-const t = require('../../i18n')
module.exports = compose(
withRouter,
@@ -123,7 +122,7 @@ WalletView.prototype.render = function () {
onClick: hideSidebar,
}),
- h('div.wallet-view__keyring-label.allcaps', isLoose ? t('imported') : ''),
+ h('div.wallet-view__keyring-label.allcaps', isLoose ? this.props.t('imported') : ''),
h('div.flex-column.flex-center.wallet-view__name-container', {
style: { margin: '0 auto' },
@@ -140,13 +139,13 @@ WalletView.prototype.render = function () {
selectedIdentity.name,
]),
- h('button.btn-clear.wallet-view__details-button.allcaps', t('details')),
+ h('button.btn-clear.wallet-view__details-button.allcaps', this.props.t('details')),
]),
]),
h(Tooltip, {
position: 'bottom',
- title: this.state.hasCopied ? t('copiedExclamation') : t('copyToClipboard'),
+ title: this.state.hasCopied ? this.props.t('copiedExclamation') : this.props.t('copyToClipboard'),
wrapperClassName: 'wallet-view__tooltip',
}, [
h('button.wallet-view__address', {
@@ -176,7 +175,7 @@ WalletView.prototype.render = function () {
h('button.btn-primary.wallet-view__add-token-button', {
onClick: () => history.push(ADD_TOKEN_ROUTE),
- }, t('addToken')),
+ }, this.props.t('addToken')),
])
}
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index fbccfd6c5..57ae89dc6 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -1,7 +1,7 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
+const connect = require('./metamask-connect')
const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const actions = require('./actions')
diff --git a/ui/app/css/itcss/components/token-list.scss b/ui/app/css/itcss/components/token-list.scss
index 9dc4f1055..e8de317e3 100644
--- a/ui/app/css/itcss/components/token-list.scss
+++ b/ui/app/css/itcss/components/token-list.scss
@@ -10,9 +10,14 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
transition: linear 200ms;
background-color: rgba($wallet-balance-bg, 0);
position: relative;
+ flex: 1;
+ min-width: 0;
&__token-balance {
font-size: 1.5rem;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
@media #{$wallet-balance-breakpoint-range} {
font-size: 95%;
@@ -51,7 +56,8 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
&__balance-ellipsis {
display: flex;
align-items: center;
- width: 100%;
+ min-width: 0;
+ flex: 1;
}
&__ellipsis {
@@ -61,6 +67,7 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
&__balance-wrapper {
flex: 1 1 auto;
+ min-width: 0;
}
}
diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js
index 8d63d5970..014bc5906 100644
--- a/ui/app/first-time/init-menu.js
+++ b/ui/app/first-time/init-menu.js
@@ -1,12 +1,11 @@
const { EventEmitter } = require('events')
const { Component } = require('react')
-const { connect } = require('react-redux')
+const connect = require('../metamask-connect')
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
const Mascot = require('../components/mascot')
const actions = require('../actions')
const Tooltip = require('../components/tooltip')
-const t = require('../../i18n')
const getCaretCoordinates = require('textarea-caret')
const { RESTORE_VAULT_ROUTE, DEFAULT_ROUTE } = require('../routes')
const environmentType = require('../../../app/scripts/lib/environment-type')
@@ -50,7 +49,7 @@ class InitializeMenuScreen extends Component {
color: '#7F8082',
marginBottom: 10,
},
- }, t('appName')),
+ }, this.props.t('appName')),
h('div', [
h('h3', {
@@ -59,10 +58,10 @@ class InitializeMenuScreen extends Component {
color: '#7F8082',
display: 'inline',
},
- }, t('encryptNewDen')),
+ }, this.props.t('encryptNewDen')),
h(Tooltip, {
- title: t('denExplainer'),
+ title: this.props.t('denExplainer'),
}, [
h('i.fa.fa-question-circle.pointer', {
style: {
@@ -82,7 +81,7 @@ class InitializeMenuScreen extends Component {
h('input.large-input.letter-spacey', {
type: 'password',
id: 'password-box',
- placeholder: t('newPassword'),
+ placeholder: this.props.t('newPassword'),
onInput: this.inputChanged.bind(this),
style: {
width: 260,
@@ -94,7 +93,7 @@ class InitializeMenuScreen extends Component {
h('input.large-input.letter-spacey', {
type: 'password',
id: 'password-box-confirm',
- placeholder: t('confirmPassword'),
+ placeholder: this.props.t('confirmPassword'),
onKeyPress: this.createVaultOnEnter.bind(this),
onInput: this.inputChanged.bind(this),
style: {
@@ -109,7 +108,7 @@ class InitializeMenuScreen extends Component {
style: {
margin: 12,
},
- }, t('createDen')),
+ }, this.props.t('createDen')),
h('.flex-row.flex-center.flex-grow', [
h('p.pointer', {
@@ -119,7 +118,7 @@ class InitializeMenuScreen extends Component {
color: 'rgb(247, 134, 28)',
textDecoration: 'underline',
},
- }, t('importDen')),
+ }, this.props.t('importDen')),
]),
h('.flex-row.flex-center.flex-grow', [
@@ -155,12 +154,12 @@ class InitializeMenuScreen extends Component {
this.setState({ warning: null })
if (password.length < 8) {
- this.setState({ warning: t('passwordShort') })
+ this.setState({ warning: this.props.t('passwordShort') })
return
}
if (password !== passwordConfirm) {
- this.setState({ warning: t('passwordMismatch') })
+ this.setState({ warning: this.props.t('passwordMismatch') })
return
}
diff --git a/ui/app/keychains/hd/create-vault-complete.js b/ui/app/keychains/hd/create-vault-complete.js
new file mode 100644
index 000000000..9d99eeb0d
--- /dev/null
+++ b/ui/app/keychains/hd/create-vault-complete.js
@@ -0,0 +1,91 @@
+const inherits = require('util').inherits
+const Component = require('react').Component
+const connect = require('../../metamask-connect')
+const h = require('react-hyperscript')
+const actions = require('../../actions')
+const exportAsFile = require('../../util').exportAsFile
+
+module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen)
+
+inherits(CreateVaultCompleteScreen, Component)
+function CreateVaultCompleteScreen () {
+ Component.call(this)
+}
+
+function mapStateToProps (state) {
+ return {
+ seed: state.appState.currentView.seedWords,
+ cachedSeed: state.metamask.seedWords,
+ }
+}
+
+CreateVaultCompleteScreen.prototype.render = function () {
+ var state = this.props
+ var seed = state.seed || state.cachedSeed || ''
+
+ return (
+
+ h('.initialize-screen.flex-column.flex-center.flex-grow', [
+
+ // // subtitle and nav
+ // h('.section-title.flex-row.flex-center', [
+ // h('h2.page-subtitle', 'Vault Created'),
+ // ]),
+
+ h('h3.flex-center.text-transform-uppercase', {
+ style: {
+ background: '#EBEBEB',
+ color: '#AEAEAE',
+ marginTop: 36,
+ marginBottom: 8,
+ width: '100%',
+ fontSize: '20px',
+ padding: 6,
+ },
+ }, [
+ 'Vault Created',
+ ]),
+
+ h('div', {
+ style: {
+ fontSize: '1em',
+ marginTop: '10px',
+ textAlign: 'center',
+ },
+ }, [
+ h('span.error', 'These 12 words are the only way to restore your MetaMask accounts.\nSave them somewhere safe and secret.'),
+ ]),
+
+ h('textarea.twelve-word-phrase', {
+ readOnly: true,
+ value: seed,
+ }),
+
+ h('button.primary', {
+ onClick: () => this.confirmSeedWords()
+ .then(account => this.showAccountDetail(account)),
+ style: {
+ margin: '24px',
+ fontSize: '0.9em',
+ marginBottom: '10px',
+ },
+ }, 'I\'ve copied it somewhere safe'),
+
+ h('button.primary', {
+ onClick: () => exportAsFile(`MetaMask Seed Words`, seed),
+ style: {
+ margin: '10px',
+ fontSize: '0.9em',
+ },
+ }, 'Save Seed Words As File'),
+ ])
+ )
+}
+
+CreateVaultCompleteScreen.prototype.confirmSeedWords = function () {
+ return this.props.dispatch(actions.confirmSeedWords())
+}
+
+CreateVaultCompleteScreen.prototype.showAccountDetail = function (account) {
+ return this.props.dispatch(actions.showAccountDetail(account))
+}
diff --git a/ui/app/keychains/hd/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js
index bc5339549..f97ac66fe 100644
--- a/ui/app/keychains/hd/recover-seed/confirmation.js
+++ b/ui/app/keychains/hd/recover-seed/confirmation.js
@@ -1,10 +1,9 @@
const inherits = require('util').inherits
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('../../../metamask-connect')
const h = require('react-hyperscript')
const actions = require('../../../actions')
-const t = require('../../../../i18n')
module.exports = connect(mapStateToProps)(RevealSeedConfirmation)
@@ -50,13 +49,13 @@ RevealSeedConfirmation.prototype.render = function () {
},
}, [
- h('h4', t('revealSeedWordsWarning')),
+ h('h4', this.props.t('revealSeedWordsWarning')),
// confirmation
h('input.large-input.letter-spacey', {
type: 'password',
id: 'password-box',
- placeholder: t('enterPasswordConfirm'),
+ placeholder: this.props.t('enterPasswordConfirm'),
onKeyPress: this.checkConfirmation.bind(this),
style: {
width: 260,
@@ -92,7 +91,7 @@ RevealSeedConfirmation.prototype.render = function () {
),
props.inProgress && (
- h('span.in-progress-notification', t('generatingSeed'))
+ h('span.in-progress-notification', this.props.t('generatingSeed'))
),
]),
])
diff --git a/ui/app/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js
index 5e4e004cf..f47a2641a 100644
--- a/ui/app/keychains/hd/restore-vault.js
+++ b/ui/app/keychains/hd/restore-vault.js
@@ -1,8 +1,7 @@
const inherits = require('util').inherits
const PersistentForm = require('../../../lib/persistent-form')
-const connect = require('react-redux').connect
+const connect = require('../../metamask-connect')
const h = require('react-hyperscript')
-const t = require('../../../i18n')
const actions = require('../../actions')
module.exports = connect(mapStateToProps)(RestoreVaultScreen)
@@ -37,23 +36,23 @@ RestoreVaultScreen.prototype.render = function () {
padding: 6,
},
}, [
- t('restoreVault'),
+ this.props.t('restoreVault'),
]),
// wallet seed entry
- h('h3', t('walletSeed')),
+ h('h3', this.props.t('walletSeed')),
h('textarea.twelve-word-phrase.letter-spacey', {
dataset: {
persistentFormId: 'wallet-seed',
},
- placeholder: t('secretPhrase'),
+ placeholder: this.props.t('secretPhrase'),
}),
// password
h('input.large-input.letter-spacey', {
type: 'password',
id: 'password-box',
- placeholder: t('newPassword8Chars'),
+ placeholder: this.props.t('newPassword8Chars'),
dataset: {
persistentFormId: 'password',
},
@@ -67,7 +66,7 @@ RestoreVaultScreen.prototype.render = function () {
h('input.large-input.letter-spacey', {
type: 'password',
id: 'password-box-confirm',
- placeholder: t('confirmPassword'),
+ placeholder: this.props.t('confirmPassword'),
onKeyPress: this.createOnEnter.bind(this),
dataset: {
persistentFormId: 'password-confirmation',
@@ -97,7 +96,7 @@ RestoreVaultScreen.prototype.render = function () {
style: {
textTransform: 'uppercase',
},
- }, t('cancel')),
+ }, this.props.t('cancel')),
// submit
h('button.primary', {
@@ -105,7 +104,7 @@ RestoreVaultScreen.prototype.render = function () {
style: {
textTransform: 'uppercase',
},
- }, t('ok')),
+ }, this.props.t('ok')),
]),
])
)
@@ -136,13 +135,13 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () {
var passwordConfirmBox = document.getElementById('password-box-confirm')
var passwordConfirm = passwordConfirmBox.value
if (password.length < 8) {
- this.warning = t('passwordNotLongEnough')
+ this.warning = this.props.t('passwordNotLongEnough')
this.props.dispatch(actions.displayWarning(this.warning))
return
}
if (password !== passwordConfirm) {
- this.warning = t('passwordsDontMatch')
+ this.warning = this.props.t('passwordsDontMatch')
this.props.dispatch(actions.displayWarning(this.warning))
return
}
@@ -152,18 +151,18 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () {
// true if the string has more than a space between words.
if (seed.split(' ').length > 1) {
- this.warning = t('spaceBetween')
+ this.warning = this.props.t('spaceBetween')
this.props.dispatch(actions.displayWarning(this.warning))
return
}
// true if seed contains a character that is not between a-z or a space
if (!seed.match(/^[a-z ]+$/)) {
- this.warning = t('loweCaseWords')
+ this.warning = this.props.t('loweCaseWords')
this.props.dispatch(actions.displayWarning(this.warning))
return
}
if (seed.split(' ').length !== 12) {
- this.warning = t('seedPhraseReq')
+ this.warning = this.props.t('seedPhraseReq')
this.props.dispatch(actions.displayWarning(this.warning))
return
}
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
diff --git a/ui/app/new-keychain.js b/ui/app/new-keychain.js
index cc9633166..6337faa08 100644
--- a/ui/app/new-keychain.js
+++ b/ui/app/new-keychain.js
@@ -1,7 +1,7 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
+const connect = require('./metamask-connect')
module.exports = connect(mapStateToProps)(NewKeychain)
diff --git a/ui/app/reducers.js b/ui/app/reducers.js
index 70b7e71dc..f155b2bf3 100644
--- a/ui/app/reducers.js
+++ b/ui/app/reducers.js
@@ -7,6 +7,7 @@ const copyToClipboard = require('copy-to-clipboard')
const reduceIdentities = require('./reducers/identities')
const reduceMetamask = require('./reducers/metamask')
const reduceApp = require('./reducers/app')
+const reduceLocale = require('./reducers/locale')
window.METAMASK_CACHED_LOG_STATE = null
@@ -38,6 +39,12 @@ function rootReducer (state, action) {
state.appState = reduceApp(state, action)
+ //
+ // LocaleMessages
+ //
+
+ state.localeMessages = reduceLocale(state, action)
+
window.METAMASK_CACHED_LOG_STATE = state
return state
}
diff --git a/ui/app/reducers/locale.js b/ui/app/reducers/locale.js
new file mode 100644
index 000000000..bdd97acb4
--- /dev/null
+++ b/ui/app/reducers/locale.js
@@ -0,0 +1,17 @@
+const extend = require('xtend')
+const actions = require('../actions')
+
+module.exports = reduceMetamask
+
+function reduceMetamask (state, action) {
+ const localeMessagesState = extend({}, state.localeMessages)
+
+ switch (action.type) {
+ case actions.SET_LOCALE_MESSAGES:
+ return extend(localeMessagesState, {
+ current: action.value,
+ })
+ default:
+ return localeMessagesState
+ }
+}
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 9cba5e83b..6d0a5bb10 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -47,6 +47,7 @@ function reduceMetamask (state, action) {
networkEndpointType: OLD_UI_NETWORK_TYPE,
isRevealingSeedWords: false,
welcomeScreenSeen: false,
+ currentLocale: '',
}, state.metamask)
switch (action.type) {
@@ -357,6 +358,11 @@ function reduceMetamask (state, action) {
welcomeScreenSeen: true,
})
+ case action.SET_CURRENT_LOCALE:
+ return extend(metamaskState, {
+ currentLocale: action.value,
+ })
+
default:
return metamaskState
diff --git a/ui/app/select-app.js b/ui/app/select-app.js
index c6ef1abda..31fded715 100644
--- a/ui/app/select-app.js
+++ b/ui/app/select-app.js
@@ -1,6 +1,6 @@
const inherits = require('util').inherits
const Component = require('react').Component
-const connect = require('react-redux').connect
+const connect = require('./metamask-connect')
const h = require('react-hyperscript')
const { HashRouter } = require('react-router-dom')
const App = require('./app')
diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js
index 9e0ede720..011d99d31 100644
--- a/ui/app/send-v2.js
+++ b/ui/app/send-v2.js
@@ -1,7 +1,6 @@
const { inherits } = require('util')
const PersistentForm = require('../lib/persistent-form')
const h = require('react-hyperscript')
-const t = require('../i18n')
const ethAbi = require('ethereumjs-abi')
const ethUtil = require('ethereumjs-util')
@@ -190,9 +189,9 @@ SendTransactionScreen.prototype.renderHeader = function () {
return h('div.page-container__header', [
- h('div.page-container__title', selectedToken ? t('sendTokens') : t('sendETH')),
+ h('div.page-container__title', selectedToken ? this.props.t('sendTokens') : this.props.t('sendETH')),
- h('div.page-container__subtitle', t('onlySendToEtherAddress')),
+ h('div.page-container__subtitle', this.props.t('onlySendToEtherAddress')),
h('div.page-container__header-close', {
onClick: () => {
@@ -263,11 +262,11 @@ SendTransactionScreen.prototype.handleToChange = function (to, nickname = '') {
let toError = null
if (!to) {
- toError = t('required')
+ toError = this.props.t('required')
} else if (!isValidAddress(to)) {
- toError = t('invalidAddressRecipient')
+ toError = this.props.t('invalidAddressRecipient')
} else if (to === from) {
- toError = t('fromToSame')
+ toError = this.props.t('fromToSame')
}
updateSendTo(to, nickname)
@@ -283,9 +282,9 @@ SendTransactionScreen.prototype.renderToRow = function () {
h('div.send-v2__form-label', [
- t('to'),
+ this.props.t('to'),
- this.renderErrorMessage(t('to')),
+ this.renderErrorMessage(this.props.t('to')),
]),
@@ -386,11 +385,11 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
)
if (conversionRate && !sufficientBalance) {
- amountError = t('insufficientFunds')
+ amountError = this.props.t('insufficientFunds')
} else if (verifyTokenBalance && !sufficientTokens) {
- amountError = t('insufficientTokens')
+ amountError = this.props.t('insufficientTokens')
} else if (amountLessThanZero) {
- amountError = t('negativeETH')
+ amountError = this.props.t('negativeETH')
}
updateSendErrors({ amount: amountError })
@@ -420,7 +419,7 @@ SendTransactionScreen.prototype.renderAmountRow = function () {
setMaxModeTo(true)
this.setAmountToMax()
},
- }, [ !maxModeOn ? t('max') : '' ]),
+ }, [ !maxModeOn ? this.props.t('max') : '' ]),
]),
h('div.send-v2__form-field', [
@@ -519,11 +518,11 @@ SendTransactionScreen.prototype.renderFooter = function () {
clearSend()
history.goBack()
},
- }, t('cancel')),
+ }, this.props.t('cancel')),
h('button.btn-primary--lg.page-container__footer-button', {
disabled: !noErrors || !gasTotal || missingTokenBalance,
onClick: event => this.onSubmit(event),
- }, t('next')),
+ }, this.props.t('next')),
])
}
@@ -597,8 +596,8 @@ SendTransactionScreen.prototype.getEditedTx = function () {
SendTransactionScreen.prototype.onSubmit = function (event) {
event.preventDefault()
const {
- from: { address: from },
- to,
+ from: {address: from},
+ to: _to,
amount,
gasLimit: gas,
gasPrice,
@@ -617,6 +616,8 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
return
}
+ const to = ethUtil.addHexPrefix(_to)
+
this.addToAddressBookIfNew(to, toNickname)
if (editingTransactionId) {
diff --git a/ui/app/unlock.js b/ui/app/unlock.js
index 322808619..e8e1ba051 100644
--- a/ui/app/unlock.js
+++ b/ui/app/unlock.js
@@ -1,11 +1,10 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
-const connect = require('react-redux').connect
+const connect = require('./metamask-connect')
const actions = require('./actions')
const getCaretCoordinates = require('textarea-caret')
const EventEmitter = require('events').EventEmitter
-const t = require('../i18n')
const { OLD_UI_NETWORK_TYPE } = require('../../app/scripts/config').enums
const environmentType = require('../../app/scripts/lib/environment-type')
@@ -41,7 +40,7 @@ UnlockScreen.prototype.render = function () {
textTransform: 'uppercase',
color: '#7F8082',
},
- }, t('appName')),
+ }, this.props.t('appName')),
h('input.large-input', {
type: 'password',
@@ -67,7 +66,7 @@ UnlockScreen.prototype.render = function () {
style: {
margin: 10,
},
- }, t('login')),
+ }, this.props.t('login')),
h('p.pointer', {
onClick: () => {
@@ -81,7 +80,7 @@ UnlockScreen.prototype.render = function () {
color: 'rgb(247, 134, 28)',
textDecoration: 'underline',
},
- }, t('restoreFromSeed')),
+ }, this.props.t('restoreFromSeed')),
h('p.pointer', {
onClick: () => {
@@ -94,7 +93,7 @@ UnlockScreen.prototype.render = function () {
textDecoration: 'underline',
marginTop: '32px',
},
- }, t('classicInterface')),
+ }, this.props.t('classicInterface')),
])
)
}
diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js
new file mode 100644
index 000000000..3ce24ddfb
--- /dev/null
+++ b/ui/i18n-helper.js
@@ -0,0 +1,45 @@
+// cross-browser connection to extension i18n API
+const log = require('loglevel')
+
+const getMessage = (locale, key, substitutions) => {
+ // check locale is loaded
+ if (!locale) {
+ // throw new Error('Translator - has not loaded a locale yet.')
+ return ''
+ }
+ // check entry is present
+ const { current, en } = locale
+ const entry = current[key] || en[key]
+ if (!entry) {
+ log.error(`Translator - Unable to find value for "${key}"`)
+ // throw new Error(`Translator - Unable to find value for "${key}"`)
+ }
+ let phrase = entry.message
+ // perform substitutions
+ if (substitutions && substitutions.length) {
+ phrase = phrase.replace(/\$1/g, substitutions[0])
+ if (substitutions.length > 1) {
+ phrase = phrase.replace(/\$2/g, substitutions[1])
+ }
+ }
+ return phrase
+}
+
+function fetchLocale (localeName) {
+ return new Promise((resolve, reject) => {
+ return fetch(`/_locales/${localeName}/messages.json`)
+ .then(response => response.json())
+ .then(
+ locale => resolve(locale),
+ error => {
+ log.error(`failed to fetch ${localeName} locale because of ${error}`)
+ resolve({})
+ }
+ )
+ })
+}
+
+module.exports = {
+ getMessage,
+ fetchLocale,
+}
diff --git a/ui/i18n.js b/ui/i18n.js
deleted file mode 100644
index abfece426..000000000
--- a/ui/i18n.js
+++ /dev/null
@@ -1,33 +0,0 @@
-
-// cross-browser connection to extension i18n API
-
-const chrome = chrome || null
-const browser = browser || null
-const extension = require('extensionizer')
-var log = require('loglevel')
-window.log = log
-let getMessage
-
-if (extension.i18n && extension.i18n.getMessage) {
- getMessage = extension.i18n.getMessage
-} else {
- // fallback function
- log.warn('browser.i18n API not available, calling back to english.')
- const msg = require('../app/_locales/en/messages.json')
- getMessage = function (key, substitutions) {
- if (!msg[key]) {
- log.error(key)
- throw new Error(key)
- }
- let phrase = msg[key].message
- if (substitutions && substitutions.length) {
- phrase = phrase.replace(/\$1/g, substitutions[0])
- if (substitutions.length > 1) {
- phrase = phrase.replace(/\$2/g, substitutions[1])
- }
- }
- return phrase
- }
-}
-
-module.exports = getMessage
diff --git a/ui/index.js b/ui/index.js
index fdb2f23e0..1e0e9f1cc 100644
--- a/ui/index.js
+++ b/ui/index.js
@@ -4,6 +4,7 @@ const Root = require('./app/root')
const actions = require('./app/actions')
const configureStore = require('./app/store')
const txHelper = require('./lib/tx-helper')
+const { fetchLocale } = require('./i18n-helper')
const { OLD_UI_NETWORK_TYPE, BETA_UI_NETWORK_TYPE } = require('../app/scripts/config').enums
global.log = require('loglevel')
@@ -18,14 +19,22 @@ function launchMetamaskUi (opts, cb) {
// check if we are unlocked first
accountManager.getState(function (err, metamaskState) {
if (err) return cb(err)
- const store = startApp(metamaskState, accountManager, opts)
- cb(null, store)
+ startApp(metamaskState, accountManager, opts)
+ .then((store) => {
+ cb(null, store)
+ })
})
}
-function startApp (metamaskState, accountManager, opts) {
+async function startApp (metamaskState, accountManager, opts) {
// parse opts
if (!metamaskState.featureFlags) metamaskState.featureFlags = {}
+
+ const currentLocaleMessages = metamaskState.currentLocale
+ ? await fetchLocale(metamaskState.currentLocale)
+ : {}
+ const enLocaleMessages = await fetchLocale('en')
+
const store = configureStore({
// metamaskState represents the cross-tab state
@@ -34,6 +43,11 @@ function startApp (metamaskState, accountManager, opts) {
// appState represents the current tab's popup state
appState: {},
+ localeMessages: {
+ current: currentLocaleMessages,
+ en: enLocaleMessages,
+ },
+
// Which blockchain we are using:
networkVersion: opts.networkVersion,
})