From 34aeef50a0519576da64f23d65afdfbfa278273d Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 14 Mar 2018 16:31:45 -0700 Subject: [PATCH 01/38] i18n - load locales manually --- app/scripts/popup.js | 115 ++++++++++-------- package-lock.json | 10 ++ ui/app/accounts/import/index.js | 10 +- ui/app/accounts/import/json.js | 5 +- ui/app/accounts/import/private-key.js | 2 +- ui/app/accounts/import/seed.js | 2 +- ui/app/accounts/new-account/create-form.js | 4 +- ui/app/accounts/new-account/index.js | 2 +- ui/app/app.js | 2 +- ui/app/components/account-dropdowns.js | 1 - ui/app/components/account-export.js | 2 +- ui/app/components/account-menu/index.js | 2 +- ui/app/components/bn-as-decimal-input.js | 2 +- ui/app/components/coinbase-form.js | 2 +- ui/app/components/copyButton.js | 2 +- ui/app/components/copyable.js | 2 +- .../components/customize-gas-modal/index.js | 2 +- .../dropdowns/components/account-dropdowns.js | 3 +- .../components/dropdowns/network-dropdown.js | 3 +- .../dropdowns/token-menu-dropdown.js | 3 +- ui/app/components/ens-input.js | 2 +- .../modals/account-details-modal.js | 2 +- .../modals/account-modal-container.js | 2 +- ui/app/components/modals/buy-options-modal.js | 2 +- .../components/modals/deposit-ether-modal.js | 32 +++-- .../modals/edit-account-name-modal.js | 2 +- .../modals/export-private-key-modal.js | 2 +- .../modals/hide-token-confirmation-modal.js | 2 +- ui/app/components/modals/modal.js | 9 +- ui/app/components/modals/new-account-modal.js | 2 +- .../components/modals/notification-modal.js | 5 +- .../pending-tx/confirm-deploy-contract.js | 2 +- .../pending-tx/confirm-send-ether.js | 2 +- .../pending-tx/confirm-send-token.js | 2 +- ui/app/components/send-token/index.js | 2 +- ui/app/components/send/gas-fee-display-v2.js | 2 +- ui/app/components/send/gas-tooltip.js | 2 +- ui/app/components/send/to-autocomplete.js | 2 +- ui/create-i18n.js | 43 +++++++ 39 files changed, 187 insertions(+), 108 deletions(-) create mode 100644 ui/create-i18n.js diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 11d50ee87..0677311da 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -1,3 +1,9 @@ +// setup i18n +const Translator = require('../../ui/create-i18n') +const translator = new Translator() +global.translator = translator +global.getMessage = translator.getMessage.bind(translator) + const injectCss = require('inject-css') const OldMetaMaskUiCss = require('../../old-ui/css') const NewMetaMaskUiCss = require('../../ui/css') @@ -10,68 +16,77 @@ const NotificationManager = require('./lib/notification-manager') const notificationManager = new NotificationManager() const setupRaven = require('./lib/setupRaven') -// create platform global -global.platform = new ExtensionPlatform() +start().catch(log.error) -// setup sentry error reporting -const release = global.platform.getVersion() -setupRaven({ release }) +async function start() { -// inject css -// const css = MetaMaskUiCss() -// injectCss(css) + // create platform global + global.platform = new ExtensionPlatform() -// identify window type (popup, notification) -const windowType = isPopupOrNotification() -global.METAMASK_UI_TYPE = windowType -closePopupIfOpen(windowType) + // setup sentry error reporting + const release = global.platform.getVersion() + setupRaven({ release }) -// setup stream to background -const extensionPort = extension.runtime.connect({ name: windowType }) -const connectionStream = new PortStream(extensionPort) + // Load translator + await translator.setLocale('ja') -// start ui -const container = document.getElementById('app-content') -startPopup({ container, connectionStream }, (err, store) => { - if (err) return displayCriticalError(err) + // inject css + // const css = MetaMaskUiCss() + // injectCss(css) - // Code commented out until we begin auto adding users to NewUI - // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask - // const firstTime = Object.keys(identities).length === 0 - const { isMascara, featureFlags = {} } = store.getState().metamask - let betaUIState = featureFlags.betaUI + // identify window type (popup, notification) + const windowType = isPopupOrNotification() + global.METAMASK_UI_TYPE = windowType + closePopupIfOpen(windowType) - // Code commented out until we begin auto adding users to NewUI - // const useBetaCss = isMascara || firstTime || betaUIState - const useBetaCss = isMascara || betaUIState + // setup stream to background + const extensionPort = extension.runtime.connect({ name: windowType }) + const connectionStream = new PortStream(extensionPort) - let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss() - let deleteInjectedCss = injectCss(css) - let newBetaUIState + // start ui + const container = document.getElementById('app-content') + startPopup({ container, connectionStream }, (err, store) => { + if (err) return displayCriticalError(err) - store.subscribe(() => { - const state = store.getState() - newBetaUIState = state.metamask.featureFlags.betaUI - if (newBetaUIState !== betaUIState) { - deleteInjectedCss() - betaUIState = newBetaUIState - css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() - deleteInjectedCss = injectCss(css) - } - if (state.appState.shouldClose) notificationManager.closePopup() + // Code commented out until we begin auto adding users to NewUI + // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask + // const firstTime = Object.keys(identities).length === 0 + const { isMascara, featureFlags = {} } = store.getState().metamask + let betaUIState = featureFlags.betaUI + + // Code commented out until we begin auto adding users to NewUI + // const useBetaCss = isMascara || firstTime || betaUIState + const useBetaCss = isMascara || betaUIState + + let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + let deleteInjectedCss = injectCss(css) + let newBetaUIState + + store.subscribe(() => { + const state = store.getState() + newBetaUIState = state.metamask.featureFlags.betaUI + if (newBetaUIState !== betaUIState) { + deleteInjectedCss() + betaUIState = newBetaUIState + css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + deleteInjectedCss = injectCss(css) + } + if (state.appState.shouldClose) notificationManager.closePopup() + }) }) -}) -function closePopupIfOpen (windowType) { - if (windowType !== 'notification') { - notificationManager.closePopup() + function closePopupIfOpen (windowType) { + if (windowType !== 'notification') { + notificationManager.closePopup() + } + } + + function displayCriticalError (err) { + container.innerHTML = '
The MetaMask app failed to load: please open and close MetaMask again to restart.
' + container.style.height = '80px' + log.error(err.stack) + throw err } -} -function displayCriticalError (err) { - container.innerHTML = '
The MetaMask app failed to load: please open and close MetaMask again to restart.
' - container.style.height = '80px' - log.error(err.stack) - throw err } diff --git a/package-lock.json b/package-lock.json index bd3026816..d1c488b09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3929,6 +3929,16 @@ "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.1.0.tgz", "integrity": "sha512-ZQVKfRVlwRfD150ndzEK8M90ABT+Y/JQKs4Y7U4MXdpuoUkkrr4DwKbVux3YjylA5bUMUj0Nc3pMxPJX6N2QQQ==" }, + "debounce-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/debounce-stream/-/debounce-stream-2.0.0.tgz", + "integrity": "sha1-HjNADM/wFavY7DMGYaVitoQQsI8=", + "requires": { + "debounce": "1.1.0", + "duplexer": "0.1.1", + "through": "2.3.8" + } + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index c1b190e3d..9c4a79bec 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.js @@ -2,23 +2,21 @@ 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') 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, + menuItems: [ + t('privateKey'), + t('jsonFile'), + ], } } diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js index 1b5e485d7..187abcc6a 100644 --- a/ui/app/accounts/import/json.js +++ b/ui/app/accounts/import/json.js @@ -4,7 +4,8 @@ const h = require('react-hyperscript') const connect = require('react-redux').connect const actions = require('../../actions') const FileInput = require('react-simple-file-input').default -const t = require('../../../i18n') +const t = global.getMessage + const HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts' @@ -102,7 +103,7 @@ class JsonImportSubview extends Component { const message = t('needImportPassword') return this.props.displayWarning(message) } - + this.props.importNewJsonAccount([ fileContents, password ]) } } diff --git a/ui/app/accounts/import/private-key.js b/ui/app/accounts/import/private-key.js index bc9e9384e..01a43afba 100644 --- a/ui/app/accounts/import/private-key.js +++ b/ui/app/accounts/import/private-key.js @@ -3,7 +3,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const connect = require('react-redux').connect const actions = require('../../actions') -const t = require('../../../i18n') +const t = global.getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView) diff --git a/ui/app/accounts/import/seed.js b/ui/app/accounts/import/seed.js index 9ffc669a2..da70a9cb5 100644 --- a/ui/app/accounts/import/seed.js +++ b/ui/app/accounts/import/seed.js @@ -2,7 +2,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 t = global.getMessage module.exports = connect(mapStateToProps)(SeedImportSubview) diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js index 8ef842a2a..78802d35a 100644 --- a/ui/app/accounts/new-account/create-form.js +++ b/ui/app/accounts/new-account/create-form.js @@ -3,7 +3,7 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const { connect } = require('react-redux') const actions = require('../../actions') -const t = require('../../../i18n') +const t = global.getMessage class NewAccountCreateForm extends Component { constructor (props) { @@ -20,7 +20,7 @@ class NewAccountCreateForm extends Component { render () { const { newAccountName, defaultAccountName } = this.state - + return h('div.new-account-create-form', [ diff --git a/ui/app/accounts/new-account/index.js b/ui/app/accounts/new-account/index.js index 854568c77..a4535ec83 100644 --- a/ui/app/accounts/new-account/index.js +++ b/ui/app/accounts/new-account/index.js @@ -3,7 +3,7 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../../actions') -const t = require('../../../i18n') +const t = global.getMessage const { getCurrentViewContext } = require('../../selectors') const classnames = require('classnames') diff --git a/ui/app/app.js b/ui/app/app.js index 9708a2485..f7fea0c22 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -4,7 +4,7 @@ const connect = require('react-redux').connect const h = require('react-hyperscript') const actions = require('./actions') const classnames = require('classnames') -const t = require('../i18n') +const t = global.getMessage // mascara const MascaraFirstTime = require('../../mascara/src/app/first-time').default diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index 1612d7b6a..500c794e3 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -9,7 +9,6 @@ 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) { diff --git a/ui/app/components/account-export.js b/ui/app/components/account-export.js index 5637bc8d0..41dc887a0 100644 --- a/ui/app/components/account-export.js +++ b/ui/app/components/account-export.js @@ -6,7 +6,7 @@ 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 t = global.getMessage module.exports = connect(mapStateToProps)(ExportAccountView) diff --git a/ui/app/components/account-menu/index.js b/ui/app/components/account-menu/index.js index e838e8916..09d002597 100644 --- a/ui/app/components/account-menu/index.js +++ b/ui/app/components/account-menu/index.js @@ -6,7 +6,7 @@ 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 t = global.getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountMenu) diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index 70701b039..2abdebeb9 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const extend = require('xtend') -const t = require('../../i18n') +const t = global.getMessage module.exports = BnAsDecimalInput diff --git a/ui/app/components/coinbase-form.js b/ui/app/components/coinbase-form.js index e442b43d5..b9ef143e6 100644 --- a/ui/app/components/coinbase-form.js +++ b/ui/app/components/coinbase-form.js @@ -3,7 +3,7 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../actions') -const t = require('../../i18n') +const t = global.getMessage module.exports = connect(mapStateToProps)(CoinbaseForm) diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js index 355f78d45..610d5b6a8 100644 --- a/ui/app/components/copyButton.js +++ b/ui/app/components/copyButton.js @@ -2,7 +2,7 @@ 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 t = global.getMessage const Tooltip = require('./tooltip') diff --git a/ui/app/components/copyable.js b/ui/app/components/copyable.js index fca7d3863..e0bf66f7e 100644 --- a/ui/app/components/copyable.js +++ b/ui/app/components/copyable.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const Tooltip = require('./tooltip') const copyToClipboard = require('copy-to-clipboard') -const t = require('../../i18n') +const t = global.getMessage module.exports = Copyable diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js index 920dfeab6..ac8f3b842 100644 --- a/ui/app/components/customize-gas-modal/index.js +++ b/ui/app/components/customize-gas-modal/index.js @@ -3,8 +3,8 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../../actions') -const t = require('../../../i18n') const GasModalCard = require('./gas-modal-card') +const t = global.getMessage const ethUtil = require('ethereumjs-util') diff --git a/ui/app/components/dropdowns/components/account-dropdowns.js b/ui/app/components/dropdowns/components/account-dropdowns.js index e5359c1d6..0cdc2c0ae 100644 --- a/ui/app/components/dropdowns/components/account-dropdowns.js +++ b/ui/app/components/dropdowns/components/account-dropdowns.js @@ -10,7 +10,8 @@ const Identicon = require('../../identicon') const ethUtil = require('ethereumjs-util') const copyToClipboard = require('copy-to-clipboard') const { formatBalance } = require('../../../util') -const t = require('../../../../i18n') +const t = global.getMessage + class AccountDropdowns extends Component { constructor (props) { diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js index 5afe730c1..a7acc7bb9 100644 --- a/ui/app/components/dropdowns/network-dropdown.js +++ b/ui/app/components/dropdowns/network-dropdown.js @@ -6,8 +6,9 @@ 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') +const t = global.getMessage + // classes from nodes of the toggle element. const notToggleElementClassnames = [ diff --git a/ui/app/components/dropdowns/token-menu-dropdown.js b/ui/app/components/dropdowns/token-menu-dropdown.js index a4f93b505..392f43c35 100644 --- a/ui/app/components/dropdowns/token-menu-dropdown.js +++ b/ui/app/components/dropdowns/token-menu-dropdown.js @@ -3,7 +3,8 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../../actions') -const t = require('../../../i18n') +const t = global.getMessage + module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown) diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index add67ea35..4f6b3afe4 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -8,7 +8,7 @@ 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 t = global.getMessage module.exports = EnsInput diff --git a/ui/app/components/modals/account-details-modal.js b/ui/app/components/modals/account-details-modal.js index 75f989e86..c6a3111b1 100644 --- a/ui/app/components/modals/account-details-modal.js +++ b/ui/app/components/modals/account-details-modal.js @@ -8,7 +8,7 @@ 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') +const t = global.getMessage function mapStateToProps (state) { return { diff --git a/ui/app/components/modals/account-modal-container.js b/ui/app/components/modals/account-modal-container.js index 08540aa76..964677244 100644 --- a/ui/app/components/modals/account-modal-container.js +++ b/ui/app/components/modals/account-modal-container.js @@ -5,7 +5,7 @@ const connect = require('react-redux').connect const actions = require('../../actions') const { getSelectedIdentity } = require('../../selectors') const Identicon = require('../identicon') -const t = require('../../../i18n') +const t = global.getMessage function mapStateToProps (state) { return { diff --git a/ui/app/components/modals/buy-options-modal.js b/ui/app/components/modals/buy-options-modal.js index 7eb73c3a6..33f8f6682 100644 --- a/ui/app/components/modals/buy-options-modal.js +++ b/ui/app/components/modals/buy-options-modal.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../../actions') const networkNames = require('../../../../app/scripts/config.js').networkNames -const t = require('../../../i18n') +const t = global.getMessage function mapStateToProps (state) { return { diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js index 26ff3ea03..03304207e 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -5,15 +5,16 @@ const connect = require('react-redux').connect const actions = require('../../actions') const networkNames = require('../../../../app/scripts/config.js').networkNames const ShapeshiftForm = require('../shapeshift-form') -const t = require('../../../i18n') +const t = global.getMessage + +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 -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]) } @@ -47,6 +48,15 @@ inherits(DepositEtherModal, Component) function DepositEtherModal () { Component.call(this) + // need to set after i18n locale has loaded + DIRECT_DEPOSIT_ROW_TITLE = t('directDepositEther') + DIRECT_DEPOSIT_ROW_TEXT = t('directDepositEtherExplainer') + COINBASE_ROW_TITLE = t('buyCoinbase') + COINBASE_ROW_TEXT = t('buyCoinbaseExplainer') + SHAPESHIFT_ROW_TITLE = t('depositShapeShift') + SHAPESHIFT_ROW_TEXT = t('depositShapeShiftExplainer') + FAUCET_ROW_TITLE = t('testFaucet') + this.state = { buyingWithShapeshift: false, } @@ -128,9 +138,9 @@ DepositEtherModal.prototype.render = function () { }), ]), - + h('.page-container__content', {}, [ - + h('div.deposit-ether-modal__buy-rows', [ this.renderRow({ @@ -164,7 +174,7 @@ DepositEtherModal.prototype.render = function () { onButtonClick: () => toCoinbase(address), hide: isTestNetwork || buyingWithShapeshift, }), - + this.renderRow({ logo: h('div.deposit-ether-modal__logo', { style: { diff --git a/ui/app/components/modals/edit-account-name-modal.js b/ui/app/components/modals/edit-account-name-modal.js index 6efa8d476..79d6109cc 100644 --- a/ui/app/components/modals/edit-account-name-modal.js +++ b/ui/app/components/modals/edit-account-name-modal.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../../actions') const { getSelectedAccount } = require('../../selectors') -const t = require('../../../i18n') +const t = global.getMessage function mapStateToProps (state) { return { diff --git a/ui/app/components/modals/export-private-key-modal.js b/ui/app/components/modals/export-private-key-modal.js index 017177cfd..3fc93b4f5 100644 --- a/ui/app/components/modals/export-private-key-modal.js +++ b/ui/app/components/modals/export-private-key-modal.js @@ -7,7 +7,7 @@ const actions = require('../../actions') const AccountModalContainer = require('./account-modal-container') const { getSelectedIdentity } = require('../../selectors') const ReadOnlyInput = require('../readonly-input') -const t = require('../../../i18n') +const t = global.getMessage const copyToClipboard = require('copy-to-clipboard') function mapStateToProps (state) { diff --git a/ui/app/components/modals/hide-token-confirmation-modal.js b/ui/app/components/modals/hide-token-confirmation-modal.js index 33d8062c6..efd472cf3 100644 --- a/ui/app/components/modals/hide-token-confirmation-modal.js +++ b/ui/app/components/modals/hide-token-confirmation-modal.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const connect = require('react-redux').connect const actions = require('../../actions') const Identicon = require('../identicon') -const t = require('../../../i18n') +const t = global.getMessage function mapStateToProps (state) { return { 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..7fe367f3f 100644 --- a/ui/app/components/modals/new-account-modal.js +++ b/ui/app/components/modals/new-account-modal.js @@ -3,7 +3,7 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const { connect } = require('react-redux') const actions = require('../../actions') -const t = require('../../../i18n') +const t = global.getMessage class NewAccountModal extends Component { constructor (props) { diff --git a/ui/app/components/modals/notification-modal.js b/ui/app/components/modals/notification-modal.js index 621a974d0..071d7ffd5 100644 --- a/ui/app/components/modals/notification-modal.js +++ b/ui/app/components/modals/notification-modal.js @@ -3,6 +3,7 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const { connect } = require('react-redux') const actions = require('../../actions') +const t = global.getMessage class NotificationModal extends Component { render () { @@ -22,12 +23,12 @@ class NotificationModal extends Component { }, [ h('div.notification-modal__header', {}, [ - header, + t(header), ]), h('div.notification-modal__message-wrapper', {}, [ h('div.notification-modal__message', {}, [ - message, + t(message), ]), ]), diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index 49fbe6387..b6bfb9afe 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -9,7 +9,7 @@ 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 t = global.getMessage const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index 4d4732bdb..7e1b25bb7 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -9,7 +9,7 @@ const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const hexToBn = require('../../../../app/scripts/lib/hex-to-bn') const { conversionUtil, addCurrencies } = require('../../conversion-util') -const t = require('../../../i18n') +const t = global.getMessage const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index 69afa8094..3a7678aa3 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -6,7 +6,7 @@ const tokenAbi = require('human-standard-token-abi') const abiDecoder = require('abi-decoder') abiDecoder.addABI(tokenAbi) const actions = require('../../actions') -const t = require('../../../i18n') +const t = global.getMessage const clone = require('clone') const Identicon = require('../identicon') const ethUtil = require('ethereumjs-util') diff --git a/ui/app/components/send-token/index.js b/ui/app/components/send-token/index.js index 58743b641..4519f469b 100644 --- a/ui/app/components/send-token/index.js +++ b/ui/app/components/send-token/index.js @@ -7,7 +7,7 @@ const inherits = require('util').inherits const actions = require('../../actions') const selectors = require('../../selectors') const { isValidAddress, allNull } = require('../../util') -const t = require('../../../i18n') +const t = global.getMessage // const BalanceComponent = require('./balance-component') const Identicon = require('../identicon') diff --git a/ui/app/components/send/gas-fee-display-v2.js b/ui/app/components/send/gas-fee-display-v2.js index 0c6f76303..2aaa43350 100644 --- a/ui/app/components/send/gas-fee-display-v2.js +++ b/ui/app/components/send/gas-fee-display-v2.js @@ -2,7 +2,7 @@ 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 t = global.getMessage module.exports = GasFeeDisplay diff --git a/ui/app/components/send/gas-tooltip.js b/ui/app/components/send/gas-tooltip.js index d925d3ed8..246c25152 100644 --- a/ui/app/components/send/gas-tooltip.js +++ b/ui/app/components/send/gas-tooltip.js @@ -2,7 +2,7 @@ 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 t = global.getMessage module.exports = GasTooltip diff --git a/ui/app/components/send/to-autocomplete.js b/ui/app/components/send/to-autocomplete.js index 72074229e..1b0a1064a 100644 --- a/ui/app/components/send/to-autocomplete.js +++ b/ui/app/components/send/to-autocomplete.js @@ -2,7 +2,7 @@ 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 t = global.getMessage module.exports = ToAutoComplete diff --git a/ui/create-i18n.js b/ui/create-i18n.js new file mode 100644 index 000000000..c80f5351a --- /dev/null +++ b/ui/create-i18n.js @@ -0,0 +1,43 @@ +// cross-browser connection to extension i18n API +const extension = require('extensionizer') +const log = require('loglevel') + + +class Translator { + + async setLocale(localeName) { + this.localeName = localeName + this.locale = await fetchLocale(localeName) + } + + getMessage (key, substitutions) { + // check locale is loaded + if (!this.locale) { + throw new Error('Translator - has not loaded a locale yet') + } + // check entry is present + const entry = this.locale[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 + } + +} + +async function fetchLocale (localeName) { + const response = await fetch(`/_locales/${localeName}/messages.json`) + const locale = await response.json() + return locale +} + +module.exports = Translator From e781ba2c55be14e7332c7a471560b203bf8e2125 Mon Sep 17 00:00:00 2001 From: Mami Mordovets Date: Wed, 14 Mar 2018 14:33:26 +0900 Subject: [PATCH 02/38] Translation to Japanese --- app/_locales/ja/messages.json | 605 +++++++++++++++++++++++++++++++++- 1 file changed, 602 insertions(+), 3 deletions(-) diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index f15d06ff4..bab8d3b95 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -1,10 +1,609 @@ { + "accept": { + "message": "承認" + }, + "account": { + "message": "アカウント" + }, + "accountDetails": { + "message": "アカウント詳細" + }, + "accountName": { + "message": "アカウント名" + }, + "address": { + "message": "アドレス" + }, + "addToken": { + "message": "トークンを追加" + }, + "amount": { + "message": "金額" + }, + "amountPlusGas": { + "message": "金額 + ガス" + }, + "appDescription": { + "message": "Ethereumのブラウザ・エクステンション", + "description": "The description of the application" + }, "appName": { "message": "MetaMask", "description": "The name of the application" }, - "appDescription": { - "message": "EthereumのID管理", - "description": "The description of the application" + "attemptingConnect": { + "message": "ブロックチェーンに接続中" + }, + "available": { + "message": "有効" + }, + "back": { + "message": "戻る" + }, + "balance": { + "message": "残高:" + }, + "balanceIsInsufficientGas": { + "message": "現在のガス総量に対して残高が不足しています" + }, + "beta": { + "message": "ベータ版" + }, + "betweenMinAndMax": { + "message": " $1以上 $2以下にして下さい。", + "description": "helper for inputting hex as decimal input" + }, + "borrowDharma": { + "message": "Dharmaで借りる(ベータ版)" + }, + "buy": { + "message": "購入" + }, + "buyCoinbase": { + "message": "Coinbaseで購入" + }, + "buyCoinbaseExplainer": { + "message": "Coinbaseは、世界で最もポピュラーなBitcoin、Ethereum、そしてLitecoinの取引所です。" + }, + "cancel": { + "message": "キャンセル" + }, + "clickCopy": { + "message": "クリックしてコピー" + }, + "confirm": { + "message": "確認" + }, + "confirmContract": { + "message": "コントラクトの確認" + }, + "confirmPassword": { + "message": "パスワードの確認" + }, + "confirmTransaction": { + "message": "トランザクションの確認" + }, + "continueToCoinbase": { + "message": "Coinbaseで続行" + }, + "contractDeployment": { + "message": "コントラクトのデプロイ" + }, + "conversionProgress": { + "message": "変換中" + }, + "copiedButton": { + "message": "コピー完了" + }, + "copiedClipboard": { + "message": "クリップボードへコピー済み" + }, + "copiedExclamation": { + "message": "コピー完了!" + }, + "copy": { + "message": "コピー" + }, + "copyToClipboard": { + "message": "クリップボードへコピー" + }, + "copyButton": { + "message": " コピー " + }, + "copyPrivateKey": { + "message": "これはあなたの秘密鍵です(クリックでコピー)" + }, + "create": { + "message": "作成" + }, + "createAccount": { + "message": "アカウント作成" + }, + "createDen": { + "message": "作成" + }, + "crypto": { + "message": "暗号通貨", + "description": "Exchange type (cryptocurrencies)" + }, + "customGas": { + "message": "ガスのカスタマイズ" + }, + "customize": { + "message": "カスタマイズ" + }, + "customRPC": { + "message": "カスタムRPC" + }, + "defaultNetwork": { + "message": "Etherトランザクションのデフォルトのネットワークはメインネットです。" + }, + "denExplainer": { + "message": "DENとは、あなたのパスワードが暗号化されたMetaMask内のストレージです。" + }, + "deposit": { + "message": "デポジット" + }, + "depositBTC": { + "message": "あなたのBTCを次のアドレスへデポジット:" + }, + "depositCoin": { + "message": "あなたの $1を次のアドレスへデポジット", + "description": "Tells the user what coin they have selected to deposit with shapeshift" + }, + "depositEth": { + "message": "ETHをデポジット" + }, + "depositEther": { + "message": "Etherをデポジット" + }, + "depositFiat": { + "message": "法定通貨でデポジット" + }, + "depositFromAccount": { + "message": "別のアカウントからデポジット" + }, + "depositShapeShift": { + "message": "ShapeShiftでデポジット" + }, + "depositShapeShiftExplainer": { + "message": "あなたが他の暗号通貨を持っているなら、Etherにトレードしてダイレクトにメタマスクウォレットへのデポジットが可能です。アカウント作成は不要。" + }, + "details": { + "message": "詳細" + }, + "directDeposit": { + "message": "ダイレクトデポジット" + }, + "directDepositEther": { + "message": "Etherをダイレクトデポジット" + }, + "directDepositEtherExplainer": { + "message": "あなたがEtherをすでにお持ちなら、ダイレクトデポジットは新しいウォレットにEtherを入手する最も迅速な方法です。" + }, + "done": { + "message": "完了" + }, + "edit": { + "message": "編集" + }, + "editAccountName": { + "message": "アカウント名を編集" + }, + "encryptNewDen": { + "message": "新しいDENを暗号化する" + }, + "enterPassword": { + "message": "パスワードを入力" + }, + "etherscanView": { + "message": "Etherscanでアカウントを見る" + }, + "exchangeRate": { + "message": "交換レート" + }, + "exportPrivateKey": { + "message": "秘密鍵のエクスポート" + }, + "exportPrivateKeyWarning": { + "message": "あなた自身の責任で秘密鍵をエクスポート" + }, + "failed": { + "message": "失敗" + }, + "fiat": { + "message": "法定通貨", + "description": "Exchange type" + }, + "fileImportFail": { + "message": "ファイルがインポートされなければ、ここをクリック!", + "description": "Helps user import their account from a JSON file" + }, + "from": { + "message": "送信元" + }, + "fromShapeShift": { + "message": "ShapeShiftから" + }, + "gas": { + "message": "ガス", + "description": "Short indication of gas cost" + }, + "gasFee": { + "message": "ガス料金" + }, + "gasLimit": { + "message": "ガスリミット" + }, + "gasLimitCalculation": { + "message": "ネットワークの成功率を基にして、ガスリミットを提案しています。" + }, + "gasLimitRequired": { + "message": "必要ガスリミット" + }, + "gasLimitTooLow": { + "message": "ガスリミットは最低21000です。" + }, + "gasPrice": { + "message": "ガスプライス (GWEI)" + }, + "gasPriceCalculation": { + "message": "ネットワークの成功率を基にして、ガスプライスを提案しています。" + }, + "gasPriceRequired": { + "message": "必要ガスプライス" + }, + "getEther": { + "message": "Etherをゲット" + }, + "getEtherFromFaucet": { + "message": "フォーセットで $1のEtherをゲット", + "description": "Displays network name for Ether faucet" + }, + "greaterThanMin": { + "message": " $1以上にして下さい。", + "description": "helper for inputting hex as decimal input" + }, + "here": { + "message": "ここ", + "description": "as in -click here- for more information (goes with troubleTokenBalances)" + }, + "hide": { + "message": "隠す" + }, + "hideToken": { + "message": "トークンを隠す" + }, + "hideTokenPrompt": { + "message": "トークンを隠しますか??" + }, + "howToDeposit": { + "message": "どのようにEtherをデポジットしますか?" + }, + "import": { + "message": "インポート", + "description": "Button to import an account from a selected file" + }, + "importAccount": { + "message": "アカウントのインポート" + }, + "importAnAccount": { + "message": "アカウントをインポート" + }, + "importDen": { + "message": "既存のDENをインポート" + }, + "imported": { + "message": "インポート完了", + "description": "status showing that an account has been fully loaded into the keyring" + }, + "infoHelp": { + "message": "インフォメーションとヘルプ" + }, + "invalidAddress": { + "message": "アドレスが無効です。" + }, + "invalidGasParams": { + "message": "ガスのパラメーターが無効です。" + }, + "invalidInput": { + "message": "インプットが無効です。" + }, + "invalidRequest": { + "message": "リクエストが無効です。" + }, + "jsonFile": { + "message": "JSONファイル", + "description": "format for importing an account" + }, + "kovan": { + "message": "Kovanテストネットワーク" + }, + "lessThanMax": { + "message": " $1以下にして下さい。", + "description": "helper for inputting hex as decimal input" + }, + "limit": { + "message": "リミット" + }, + "loading": { + "message": "ロード中..." + }, + "loadingTokens": { + "message": "トークンをロード中..." + }, + "localhost": { + "message": "Localhost 8545" + }, + "logout": { + "message": "ログアウト" + }, + "loose": { + "message": "外部秘密鍵" + }, + "mainnet": { + "message": "Ethereumメインネットワーク" + }, + "message": { + "message": "メッセージ" + }, + "min": { + "message": "ミニマム" + }, + "myAccounts": { + "message": "マイアカウント" + }, + "needEtherInWallet": { + "message": "MetaMaskを使って分散型アプリケーションと対話するためには、あなたのウォレットにEtherが必要になります。" + }, + "needImportFile": { + "message": "インポートするファイルを選択してください。", + "description": "User is important an account and needs to add a file to continue" + }, + "needImportPassword": { + "message": "選択したファイルのパスワードを入力してください。", + "description": "Password and file needed to import an account" + }, + "networks": { + "message": "ネットワーク" + }, + "newAccount": { + "message": "新規アカウント" + }, + "newAccountNumberName": { + "message": "アカウント $1", + "description": "Default name of next account to be created on create account screen" + }, + "newContract": { + "message": "新規コントラクト" + }, + "newPassword": { + "message": "新規パスワード(最低8文字)" + }, + "newRecipient": { + "message": "新規受取人" + }, + "next": { + "message": "次へ" + }, + "noAddressForName": { + "message": "この名前にはアドレスが設定されていません。" + }, + "noDeposits": { + "message": "デポジットがありません。" + }, + "noTransactionHistory": { + "message": "トランザクション履歴がありません。" + }, + "noTransactions": { + "message": "トランザクションがありません。" + }, + "notStarted": { + "message": "スタートしていません。" + }, + "oldUI": { + "message": "旧UI" + }, + "oldUIMessage": { + "message": "旧UIを表示しています。右上のドロップダウンメニューのオプションより、新UIへ切り替えが可能です。" + }, + "or": { + "message": "または", + "description": "choice between creating or importing a new account" + }, + "passwordMismatch": { + "message": "パスワードが一致しません。", + "description": "in password creation process, the two new password fields did not match" + }, + "passwordShort": { + "message": "パスワードが短すぎます。", + "description": "in password creation process, the password is not long enough to be secure" + }, + "pastePrivateKey": { + "message": "秘密鍵をここにペーストして下さい:", + "description": "For importing an account from a private key" + }, + "pasteSeed": { + "message": "シードをここにペーストして下さい!" + }, + "pleaseReviewTransaction": { + "message": "トランザクションをレビューして下さい。" + }, + "privateKey": { + "message": "秘密鍵", + "description": "select this type of file to use to import an account" + }, + "privateKeyWarning": { + "message": "警告: この鍵は絶対に公開しないで下さい。公開すると、誰でもあなたのアカウント内の資産を盗むことができてしまいます。" + }, + "privateNetwork": { + "message": "プライベート・ネットワーク" + }, + "qrCode": { + "message": "QRコードを表示" + }, + "readdToken": { + "message": "アカウントのオプションメニューから「トークンを追加」すれば、将来このトークンを追加し直すことができます。" + }, + "readMore": { + "message": "もっと読む" + }, + "receive": { + "message": "受け取る" + }, + "recipientAddress": { + "message": "受取人アドレス" + }, + "refundAddress": { + "message": "あなたの返金先アドレス" + }, + "rejected": { + "message": "拒否されました" + }, + "required": { + "message": "必要です。" + }, + "retryWithMoreGas": { + "message": "より高いガスプライスで再度試して下さい。" + }, + "revert": { + "message": "元に戻す" + }, + "rinkeby": { + "message": "Rinkebyテストネットワーク" + }, + "ropsten": { + "message": "Ropstenテストネットワーク" + }, + "sampleAccountName": { + "message": "例.新しいマイアカウント", + "description": "Help user understand concept of adding a human-readable name to their account" + }, + "save": { + "message": "保存" + }, + "saveAsFile": { + "message": "ファイルとして保存", + "description": "Account export process" + }, + "selectService": { + "message": "サービスを選択" + }, + "send": { + "message": "送信" + }, + "sendTokens": { + "message": "トークンを送る" + }, + "sendTokensAnywhere": { + "message": "イーサリアムのアカウントを持っている人にトークンを送る" + }, + "settings": { + "message": "設定" + }, + "shapeshiftBuy": { + "message": "Shapeshiftで買う" + }, + "showPrivateKeys": { + "message": "秘密鍵を表示" + }, + "showQRCode": { + "message": "QRコードを表示" + }, + "sign": { + "message": "署名" + }, + "signMessage": { + "message": "メッセージに署名" + }, + "signNotice": { + "message": "このメッセージへの署名は危険となる可能性があります。\n完全に信頼するサイトからのメッセージのみ、\nあなたのアカウントで署名して下さい。今後のバージョンでは、\nこの危険なメソッドは削除される予定です。" + }, + "sigRequest": { + "message": "署名リクエスト" + }, + "sigRequested": { + "message": "署名がリクエストされました" + }, + "status": { + "message": "ステータス" + }, + "submit": { + "message": "送信" + }, + "takesTooLong": { + "message": "長くかかりすぎていますか?" + }, + "testFaucet": { + "message": "Faucetをテスト" + }, + "to": { + "message": "宛先" + }, + "toETHviaShapeShift": { + "message": "ShapeShiftで $1をETHにする", + "description": "system will fill in deposit type in start of message" + }, + "tokenBalance": { + "message": "あなたのトークン残高:" + }, + "total": { + "message": "合計" + }, + "transactionMemo": { + "message": "トランザクションメモ (オプション)" + }, + "transactionNumber": { + "message": "トランザクション番号" + }, + "transfers": { + "message": "トランスファー" + }, + "troubleTokenBalances": { + "message": "トークン残高を取得できません。こちらでご確認ください。", + "description": "Followed by a link (here) to view token balances" + }, + "typePassword": { + "message": "パスワードタイプ" + }, + "uiWelcome": { + "message": "新UIへようこそ!(ベータ版)" + }, + "uiWelcomeMessage": { + "message": "現在Metamaskの新しいUIをお使いになっています。トークン送信など、新たな機能を試してみましょう!何か問題があればご報告ください。" + }, + "unavailable": { + "message": "有効ではありません。" + }, + "unknown": { + "message": "不明" + }, + "unknownNetwork": { + "message": "不明なプライベートネットワーク" + }, + "unknownNetworkId": { + "message": "不明なネットワークID" + }, + "usaOnly": { + "message": "米国居住者のみ", + "description": "Using this exchange is limited to people inside the USA" + }, + "usedByClients": { + "message": "様々なクライアントによって使用されています。" + }, + "viewAccount": { + "message": "アカウントを見る" + }, + "warning": { + "message": "警告" + }, + "whatsThis": { + "message": "これは何でしょう?" + }, + "yourSigRequested": { + "message": "あなたの署名がリクエストされています。" + }, + "youSign": { + "message": "署名しています。" } } From eb5a84975b490664aa6238be6ceab3d4749167ee Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 14 Mar 2018 17:11:41 -0700 Subject: [PATCH 03/38] ui - settings - add option to set current locale --- ui/app/settings.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ui/app/settings.js b/ui/app/settings.js index 466f739d5..95b69e46e 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -25,6 +25,23 @@ const getInfuraCurrencyOptions = () => { }) } +const locales = [ + { name: 'English', code: 'en' }, + { name: 'Japanese', code: 'ja' }, + { name: 'French', code: 'fr' }, + { name: 'Spanish', code: 'es' }, +] + +const getLocaleOptions = () => { + return locales.map((locale) => { + return { + displayValue: `${locale.name}`, + key: locale.code, + value: locale.code, + } + }) +} + class Settings extends Component { constructor (props) { super(props) @@ -94,6 +111,33 @@ class Settings extends Component { ]) } + renderCurrentLocale () { + const { setCurrentLocale } = this.props + const currentLocaleName = global.translator.localeName + const currentLocale = locales.find(locale => locale.code === currentLocaleName) + + return h('div.settings__content-row', [ + h('div.settings__content-item', [ + h('span', 'Current Language'), + h('span.settings__content-description', `${currentLocale.name}`), + ]), + h('div.settings__content-item', [ + h('div.settings__content-item-col', [ + h(SimpleDropdown, { + placeholder: 'Select Locale', + options: getLocaleOptions(), + selectedOption: currentLocaleName, + onSelect: async (newLocale) => { + log('set new locale', newLocale) + await global.translator.setLocale(newLocale) + log('did set new locale', newLocale) + }, + }), + ]), + ]), + ]) + } + renderCurrentProvider () { const { metamask: { provider = {} } } = this.props let title, value, color @@ -281,6 +325,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(), From 5fe0be722b6514692a68e920ee8058c5d572237d Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 15 Mar 2018 21:59:45 -0230 Subject: [PATCH 04/38] Handle i18n with redux. --- app/scripts/controllers/preferences.js | 5 +++ app/scripts/metamask-controller.js | 10 +++++ app/scripts/popup-core.js | 4 +- app/scripts/popup.js | 14 +++--- ui/app/account-detail.js | 2 +- ui/app/accounts/import/index.js | 10 ++--- ui/app/accounts/import/json.js | 18 ++++---- ui/app/accounts/import/private-key.js | 10 ++--- ui/app/accounts/import/seed.js | 8 ++-- ui/app/accounts/new-account/create-form.js | 12 +++--- ui/app/accounts/new-account/index.js | 10 ++--- ui/app/actions.js | 43 ++++++++++++++++++- ui/app/add-token.js | 2 +- ui/app/app.js | 8 ++-- ui/app/components/account-dropdowns.js | 16 +++---- ui/app/components/account-export.js | 18 ++++---- ui/app/components/account-menu/index.js | 18 ++++---- ui/app/components/balance-component.js | 2 +- ui/app/components/bn-as-decimal-input.js | 10 ++--- ui/app/components/buy-button-subview.js | 14 +++--- ui/app/components/coinbase-form.js | 8 ++-- ui/app/components/copyButton.js | 4 +- ui/app/components/copyable.js | 4 +- .../components/customize-gas-modal/index.js | 18 ++++---- .../dropdowns/components/account-dropdowns.js | 22 +++++----- .../components/dropdowns/network-dropdown.js | 30 ++++++------- .../dropdowns/token-menu-dropdown.js | 6 +-- ui/app/components/ens-input.js | 6 +-- ui/app/components/hex-as-decimal-input.js | 10 ++--- ui/app/components/identicon.js | 2 +- .../modals/account-details-modal.js | 8 ++-- .../modals/account-modal-container.js | 6 +-- ui/app/components/modals/buy-options-modal.js | 18 ++++---- .../components/modals/deposit-ether-modal.js | 30 ++++++------- .../modals/edit-account-name-modal.js | 6 +-- .../modals/export-private-key-modal.js | 16 +++---- .../modals/hide-token-confirmation-modal.js | 12 +++--- ui/app/components/modals/modal.js | 2 +- ui/app/components/modals/new-account-modal.js | 14 +++--- .../components/modals/notification-modal.js | 2 +- .../modals/shapeshift-deposit-tx-modal.js | 2 +- ui/app/components/network.js | 26 +++++------ ui/app/components/notice.js | 4 +- ui/app/components/pending-msg-details.js | 4 +- ui/app/components/pending-msg.js | 12 +++--- .../pending-personal-msg-details.js | 4 +- .../pending-tx/confirm-deploy-contract.js | 24 +++++------ .../pending-tx/confirm-send-ether.js | 18 ++++---- .../pending-tx/confirm-send-token.js | 30 ++++++------- .../components/pending-typed-msg-details.js | 4 +- ui/app/components/pending-typed-msg.js | 8 ++-- ui/app/components/qr-code.js | 2 +- ui/app/components/send-token/index.js | 18 ++++---- ui/app/components/send/account-list-item.js | 2 +- ui/app/components/send/gas-fee-display-v2.js | 4 +- ui/app/components/send/gas-tooltip.js | 2 +- ui/app/components/send/send-v2-container.js | 2 +- ui/app/components/send/to-autocomplete.js | 4 +- ui/app/components/shapeshift-form.js | 22 +++++----- ui/app/components/shift-list-item.js | 18 ++++---- ui/app/components/signature-request.js | 20 ++++----- ui/app/components/token-balance.js | 2 +- ui/app/components/token-cell.js | 2 +- ui/app/components/token-list.js | 10 ++--- ui/app/components/transaction-list-item.js | 20 ++++----- ui/app/components/transaction-list.js | 4 +- ui/app/components/tx-list-item.js | 6 +-- ui/app/components/tx-list.js | 8 ++-- ui/app/components/tx-view.js | 10 ++--- ui/app/components/wallet-view.js | 12 +++--- ui/app/conf-tx.js | 2 +- ui/app/first-time/init-menu.js | 22 +++++----- ui/app/info.js | 2 +- ui/app/keychains/hd/create-vault-complete.js | 2 +- .../keychains/hd/recover-seed/confirmation.js | 2 +- ui/app/keychains/hd/restore-vault.js | 2 +- ui/app/metamask-connect.js | 18 ++++++++ ui/app/new-keychain.js | 2 +- ui/app/reducers.js | 7 +++ ui/app/reducers/locale.js | 18 ++++++++ ui/app/reducers/metamask.js | 6 +++ ui/app/select-app.js | 2 +- ui/app/send.js | 2 +- ui/app/settings.js | 17 +++++--- ui/app/template.js | 2 +- ui/app/unlock.js | 6 +-- ui/i18n-helper.js | 37 ++++++++++++++++ ui/index.js | 12 ++++-- 88 files changed, 538 insertions(+), 385 deletions(-) create mode 100644 ui/app/metamask-connect.js create mode 100644 ui/app/reducers/locale.js create mode 100644 ui/i18n-helper.js diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 39d15fd83..dc7da90d0 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -11,6 +11,7 @@ class PreferencesController { tokens: [], useBlockie: false, featureFlags: {}, + currentLocale: 'ja', }, opts.initState) this.store = new ObservableStore(initState) } @@ -24,6 +25,10 @@ class PreferencesController { return this.store.getState().useBlockie } + setCurrentLocale (key) { + this.store.updateState({ currentLocale: key }) + } + setSelectedAddress (_address) { return new Promise((resolve, reject) => { const address = normalizeAddress(_address) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 0a5c1d36f..4ff08e029 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -333,6 +333,7 @@ module.exports = class MetamaskController extends EventEmitter { getState: (cb) => cb(null, this.getState()), setCurrentCurrency: this.setCurrentCurrency.bind(this), setUseBlockie: this.setUseBlockie.bind(this), + setCurrentLocale: this.setCurrentLocale.bind(this), markAccountsFound: this.markAccountsFound.bind(this), markPasswordForgotten: this.markPasswordForgotten.bind(this), unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this), @@ -920,6 +921,15 @@ module.exports = class MetamaskController extends EventEmitter { } } + setCurrentLocale (key, cb) { + try { + this.preferencesController.setCurrentLocale(key) + cb(null) + } catch (err) { + cb(err) + } + } + recordFirstTimeInfo (initState) { if (!('firstTimeInfo' in initState)) { initState.firstTimeInfo = { diff --git a/app/scripts/popup-core.js b/app/scripts/popup-core.js index 2e4334bb1..5af913e98 100644 --- a/app/scripts/popup-core.js +++ b/app/scripts/popup-core.js @@ -11,11 +11,11 @@ const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex module.exports = initializePopup -function initializePopup ({ container, connectionStream }, cb) { +function initializePopup ({ container, connectionStream, localeMessages }, cb) { // setup app async.waterfall([ (cb) => connectToAccountManager(connectionStream, cb), - (accountManager, cb) => launchMetamaskUi({ container, accountManager }, cb), + (accountManager, cb) => launchMetamaskUi({ container, accountManager, localeMessages }, cb), ], cb) } diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 0677311da..fe6aae799 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -1,8 +1,8 @@ // setup i18n -const Translator = require('../../ui/create-i18n') -const translator = new Translator() -global.translator = translator -global.getMessage = translator.getMessage.bind(translator) +// const Translator = require('../../ui/create-i18n') +// const translator = new Translator() +// global.translator = translator +// global.getMessage = translator.getMessage.bind(translator) const injectCss = require('inject-css') const OldMetaMaskUiCss = require('../../old-ui/css') @@ -15,6 +15,7 @@ const ExtensionPlatform = require('./platforms/extension') const NotificationManager = require('./lib/notification-manager') const notificationManager = new NotificationManager() const setupRaven = require('./lib/setupRaven') +const { fetchLocale } = require('../../ui/i18n-helper.js') start().catch(log.error) @@ -28,7 +29,8 @@ async function start() { setupRaven({ release }) // Load translator - await translator.setLocale('ja') + // await translator.setLocale('ja') + const localeMessages = await fetchLocale('ja') // inject css // const css = MetaMaskUiCss() @@ -45,7 +47,7 @@ async function start() { // start ui const container = document.getElementById('app-content') - startPopup({ container, connectionStream }, (err, store) => { + startPopup({ container, connectionStream, localeMessages }, (err, store) => { if (err) return displayCriticalError(err) // Code commented out until we begin auto adding users to NewUI diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 0da435298..c67ccb647 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -2,7 +2,7 @@ const inherits = require('util').inherits const extend = require('xtend') 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 valuesFor = require('./util').valuesFor const TransactionList = require('./components/transaction-list') diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index 9c4a79bec..ab5344dc6 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.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') import Select from 'react-select' // Subviews @@ -14,8 +14,8 @@ module.exports = connect(mapStateToProps)(AccountImportSubview) function mapStateToProps (state) { return { menuItems: [ - t('privateKey'), - t('jsonFile'), + t(this.props.localeMessages, 'privateKey'), + t(this.props.localeMessages, 'jsonFile'), ], } } @@ -84,9 +84,9 @@ AccountImportSubview.prototype.renderImportView = function () { const current = type || menuItems[0] switch (current) { - case t('privateKey'): + case t(this.props.localeMessages, 'privateKey'): return h(PrivateKeyImportView) - case t('jsonFile'): + case t(this.props.localeMessages, 'jsonFile'): return h(JsonImportView) default: return h(JsonImportView) diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js index 187abcc6a..b3f412e98 100644 --- a/ui/app/accounts/import/json.js +++ b/ui/app/accounts/import/json.js @@ -1,10 +1,10 @@ const Component = require('react').Component const PropTypes = require('prop-types') const h = require('react-hyperscript') -const connect = require('react-redux').connect +const connect = require('../../metamask-connect') const actions = require('../../actions') const FileInput = require('react-simple-file-input').default -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage const HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts' @@ -25,11 +25,11 @@ class JsonImportSubview extends Component { return ( h('div.new-account-import-form__json', [ - h('p', t('usedByClients')), + h('p', t(this.props.localeMessages, 'usedByClients')), h('a.warning', { href: HELP_LINK, target: '_blank', - }, t('fileImportFail')), + }, t(this.props.localeMessages, 'fileImportFail')), h(FileInput, { readAs: 'text', @@ -44,7 +44,7 @@ class JsonImportSubview extends Component { h('input.new-account-import-form__input-password', { type: 'password', - placeholder: t('enterPassword'), + placeholder: t(this.props.localeMessages, 'enterPassword'), id: 'json-password-box', onKeyPress: this.createKeyringOnEnter.bind(this), }), @@ -54,13 +54,13 @@ class JsonImportSubview extends Component { h('button.new-account-create-form__button-cancel', { onClick: () => this.props.goHome(), }, [ - t('cancel'), + t(this.props.localeMessages, 'cancel'), ]), h('button.new-account-create-form__button-create', { onClick: () => this.createNewKeychain(), }, [ - t('import'), + t(this.props.localeMessages, 'import'), ]), ]), @@ -92,7 +92,7 @@ class JsonImportSubview extends Component { const { fileContents } = state if (!fileContents) { - const message = t('needImportFile') + const message = t(this.props.localeMessages, 'needImportFile') return this.props.displayWarning(message) } @@ -100,7 +100,7 @@ class JsonImportSubview extends Component { const password = passwordInput.value if (!password) { - const message = t('needImportPassword') + const message = t(this.props.localeMessages, 'needImportPassword') return this.props.displayWarning(message) } diff --git a/ui/app/accounts/import/private-key.js b/ui/app/accounts/import/private-key.js index 01a43afba..9a23b791a 100644 --- a/ui/app/accounts/import/private-key.js +++ b/ui/app/accounts/import/private-key.js @@ -1,9 +1,9 @@ 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 t = global.getMessage +const t = require('../../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView) @@ -34,7 +34,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', t(this.props.localeMessages, 'pastePrivateKey')), h('div.new-account-import-form__private-key-password-container', [ @@ -51,13 +51,13 @@ PrivateKeyImportView.prototype.render = function () { h('button.new-account-create-form__button-cancel.allcaps', { onClick: () => goHome(), }, [ - t('cancel'), + t(this.props.localeMessages, 'cancel'), ]), h('button.new-account-create-form__button-create.allcaps', { onClick: () => this.createNewKeychain(), }, [ - t('import'), + t(this.props.localeMessages, 'import'), ]), ]), diff --git a/ui/app/accounts/import/seed.js b/ui/app/accounts/import/seed.js index da70a9cb5..d701feedc 100644 --- a/ui/app/accounts/import/seed.js +++ b/ui/app/accounts/import/seed.js @@ -1,8 +1,8 @@ const inherits = require('util').inherits const Component = require('react').Component const h = require('react-hyperscript') -const connect = require('react-redux').connect -const t = global.getMessage +const connect = require('../../metamask-connect') +const t = require('../../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(SeedImportSubview) @@ -21,10 +21,10 @@ SeedImportSubview.prototype.render = function () { style: { }, }, [ - t('pasteSeed'), + t(this.props.localeMessages, 'pasteSeed'), h('textarea'), h('br'), - h('button', t('submit')), + h('button', t(this.props.localeMessages, 'submit')), ]) ) } diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js index 78802d35a..38cffec64 100644 --- a/ui/app/accounts/new-account/create-form.js +++ b/ui/app/accounts/new-account/create-form.js @@ -1,9 +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 t = global.getMessage +const t = require('../../../i18n-helper').getMessage class NewAccountCreateForm extends Component { constructor (props) { @@ -14,7 +14,7 @@ class NewAccountCreateForm extends Component { this.state = { newAccountName: '', - defaultAccountName: t('newAccountNumberName', [newAccountNumber]), + defaultAccountName: t(this.props.localeMessages, 'newAccountNumberName', [newAccountNumber]), } } @@ -25,7 +25,7 @@ class NewAccountCreateForm extends Component { return h('div.new-account-create-form', [ h('div.new-account-create-form__input-label', {}, [ - t('accountName'), + t(this.props.localeMessages, 'accountName'), ]), h('div.new-account-create-form__input-wrapper', {}, [ @@ -41,13 +41,13 @@ class NewAccountCreateForm extends Component { h('button.new-account-create-form__button-cancel.allcaps', { onClick: () => this.props.goHome(), }, [ - t('cancel'), + t(this.props.localeMessages, 'cancel'), ]), h('button.new-account-create-form__button-create.allcaps', { onClick: () => this.props.createAccount(newAccountName || defaultAccountName), }, [ - t('create'), + t(this.props.localeMessages, 'create'), ]), ]), diff --git a/ui/app/accounts/new-account/index.js b/ui/app/accounts/new-account/index.js index a4535ec83..8c305bfae 100644 --- a/ui/app/accounts/new-account/index.js +++ b/ui/app/accounts/new-account/index.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 = global.getMessage +const t = require('../../../i18n-helper').getMessage const { getCurrentViewContext } = require('../../selectors') const classnames = require('classnames') @@ -46,7 +46,7 @@ AccountDetailsModal.prototype.render = function () { h('div.new-account__header', [ - h('div.new-account__title', t('newAccount')), + h('div.new-account__title', t(this.props.localeMessages, 'newAccount')), h('div.new-account__tabs', [ @@ -56,7 +56,7 @@ AccountDetailsModal.prototype.render = function () { 'new-account__tabs__unselected cursor-pointer': displayedForm !== 'CREATE', }), onClick: () => displayForm('CREATE'), - }, t('createDen')), + }, t(this.props.localeMessages, 'createDen')), h('div.new-account__tabs__tab', { className: classnames('new-account__tabs__tab', { @@ -64,7 +64,7 @@ AccountDetailsModal.prototype.render = function () { 'new-account__tabs__unselected cursor-pointer': displayedForm !== 'IMPORT', }), onClick: () => displayForm('IMPORT'), - }, t('import')), + }, t(this.props.localeMessages, 'import')), ]), diff --git a/ui/app/actions.js b/ui/app/actions.js index 092af080b..4749d0735 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, @@ -1790,6 +1798,39 @@ function setUseBlockie (val) { } } +function updateCurrentLocale (key) { + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + log.debug(`background.updateCurrentLocale`) + console.log(`fetchLocale`, fetchLocale); + fetchLocale(key) + .then((localeMessages) => { + 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/add-token.js b/ui/app/add-token.js index b8878b772..917a7c9fb 100644 --- a/ui/app/add-token.js +++ b/ui/app/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') diff --git a/ui/app/app.js b/ui/app/app.js index f7fea0c22..34dd3d868 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -1,10 +1,10 @@ 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 classnames = require('classnames') -const t = global.getMessage +const t = require('../i18n-helper').getMessage // mascara const MascaraFirstTime = require('../../mascara/src/app/first-time').default @@ -294,8 +294,8 @@ App.prototype.renderAppBar = function () { // metamask name h('.flex-row', [ - h('h1', t('appName')), - h('div.beta-label', t('beta')), + h('h1', t(this.props.localeMessages, 'appName')), + h('div.beta-label', t(this.props.localeMessages, 'beta')), ]), ]), diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index 500c794e3..1f870a27c 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -3,7 +3,7 @@ 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') @@ -79,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', t(this.props.localeMessages, 'loose')) : null } catch (e) { return } } @@ -129,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' } }, t(this.props.localeMessages, 'createAccount')), ], ), h( @@ -154,7 +154,7 @@ class AccountDropdowns extends Component { fontSize: '24px', marginBottom: '5px', }, - }, t('importAccount')), + }, t(this.props.localeMessages, 'importAccount')), ] ), ] @@ -192,7 +192,7 @@ class AccountDropdowns extends Component { global.platform.openWindow({ url }) }, }, - t('etherscanView'), + t(this.props.localeMessages, 'etherscanView'), ), h( DropdownMenuItem, @@ -204,7 +204,7 @@ class AccountDropdowns extends Component { actions.showQrView(selected, identity ? identity.name : '') }, }, - t('showQRCode'), + t(this.props.localeMessages, 'showQRCode'), ), h( DropdownMenuItem, @@ -216,7 +216,7 @@ class AccountDropdowns extends Component { copyToClipboard(checkSumAddress) }, }, - t('copyAddress'), + t(this.props.localeMessages, 'copyAddress'), ), h( DropdownMenuItem, @@ -226,7 +226,7 @@ class AccountDropdowns extends Component { actions.requestAccountExport() }, }, - t('exportPrivateKey'), + t(this.props.localeMessages, 'exportPrivateKey'), ), ] ) diff --git a/ui/app/components/account-export.js b/ui/app/components/account-export.js index 41dc887a0..3bb7ec337 100644 --- a/ui/app/components/account-export.js +++ b/ui/app/components/account-export.js @@ -5,8 +5,8 @@ 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 = global.getMessage +const connect = require('../metamask-connect') +const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(ExportAccountView) @@ -36,7 +36,7 @@ ExportAccountView.prototype.render = function () { if (notExporting) return h('div') if (exportRequested) { - const warning = t('exportPrivateKeyWarning') + const warning = t(this.props.localeMessages, 'exportPrivateKeyWarning') return ( h('div', { style: { @@ -54,7 +54,7 @@ ExportAccountView.prototype.render = function () { h('p.error', warning), h('input#exportAccount.sizing-input', { type: 'password', - placeholder: t('confirmPassword').toLowerCase(), + placeholder: t(this.props.localeMessages, 'confirmPassword').toLowerCase(), onKeyPress: this.onExportKeyPress.bind(this), style: { position: 'relative', @@ -75,10 +75,10 @@ ExportAccountView.prototype.render = function () { style: { marginRight: '10px', }, - }, t('submit')), + }, t(this.props.localeMessages, 'submit')), h('button', { onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)), - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), ]), (this.props.warning) && ( h('span.error', { @@ -99,7 +99,7 @@ ExportAccountView.prototype.render = function () { margin: '0 20px', }, }, [ - h('label', t('copyPrivateKey') + ':'), + h('label', t(this.props.localeMessages, 'copyPrivateKey') + ':'), h('p.error.cursor-pointer', { style: { textOverflow: 'ellipsis', @@ -113,13 +113,13 @@ ExportAccountView.prototype.render = function () { }, plainKey), h('button', { onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)), - }, t('done')), + }, t(this.props.localeMessages, 'done')), h('button', { style: { marginLeft: '10px', }, onClick: () => exportAsFile(`MetaMask ${nickname} Private Key`, plainKey), - }, t('saveAsFile')), + }, t(this.props.localeMessages, 'saveAsFile')), ]) } } diff --git a/ui/app/components/account-menu/index.js b/ui/app/components/account-menu/index.js index 09d002597..dc9c36c40 100644 --- a/ui/app/components/account-menu/index.js +++ b/ui/app/components/account-menu/index.js @@ -1,12 +1,12 @@ 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 { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu') const Identicon = require('../identicon') const { formatBalance } = require('../../util') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountMenu) @@ -71,10 +71,10 @@ AccountMenu.prototype.render = function () { h(Item, { className: 'account-menu__header', }, [ - t('myAccounts'), + t(this.props.localeMessages, 'myAccounts'), h('button.account-menu__logout-button', { onClick: lockMetamask, - }, t('logout')), + }, t(this.props.localeMessages, 'logout')), ]), h(Divider), h('div.account-menu__accounts', this.renderAccounts()), @@ -82,23 +82,23 @@ AccountMenu.prototype.render = function () { h(Item, { onClick: () => showNewAccountPage('CREATE'), icon: h('img.account-menu__item-icon', { src: 'images/plus-btn-white.svg' }), - text: t('createAccount'), + text: t(this.props.localeMessages, 'createAccount'), }), h(Item, { onClick: () => showNewAccountPage('IMPORT'), icon: h('img.account-menu__item-icon', { src: 'images/import-account.svg' }), - text: t('importAccount'), + text: t(this.props.localeMessages, 'importAccount'), }), h(Divider), h(Item, { onClick: showInfoPage, icon: h('img', { src: 'images/mm-info-icon.svg' }), - text: t('infoHelp'), + text: t(this.props.localeMessages, 'infoHelp'), }), h(Item, { onClick: showConfigPage, icon: h('img.account-menu__item-icon', { src: 'images/settings.svg' }), - text: t('settings'), + text: t(this.props.localeMessages, 'settings'), }), ]) } @@ -156,6 +156,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', t(this.props.localeMessages, '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 2abdebeb9..5b83b4332 100644 --- a/ui/app/components/bn-as-decimal-input.js +++ b/ui/app/components/bn-as-decimal-input.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const extend = require('xtend') -const t = global.getMessage +const t = require('../../i18n-helper').getMessage module.exports = BnAsDecimalInput @@ -137,13 +137,13 @@ BnAsDecimalInput.prototype.constructWarning = function () { let message = name ? name + ' ' : '' if (min && max) { - message += t('betweenMinAndMax', [`${newMin} ${suffix}`, `${newMax} ${suffix}`]) + message += t(this.props.localeMessages, 'betweenMinAndMax', [`${newMin} ${suffix}`, `${newMax} ${suffix}`]) } else if (min) { - message += t('greaterThanMin', [`${newMin} ${suffix}`]) + message += t(this.props.localeMessages, 'greaterThanMin', [`${newMin} ${suffix}`]) } else if (max) { - message += t('lessThanMax', [`${newMax} ${suffix}`]) + message += t(this.props.localeMessages, 'lessThanMax', [`${newMax} ${suffix}`]) } else { - message += t('invalidInput') + message += t(this.props.localeMessages, 'invalidInput') } return message diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index 1e277a94b..b2b8cbbd5 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,7 @@ 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') +const t = require('../../i18n-helper.js').getMessage module.exports = connect(mapStateToProps)(BuyButtonSubview) @@ -77,7 +77,7 @@ BuyButtonSubview.prototype.headerSubview = function () { paddingTop: '4px', paddingBottom: '4px', }, - }, t('depositEth')), + }, t(this.props.localeMessages, 'depositEth')), ]), // loading indication @@ -119,7 +119,7 @@ BuyButtonSubview.prototype.headerSubview = function () { paddingTop: '4px', paddingBottom: '4px', }, - }, t('selectService')), + }, t(this.props.localeMessages, 'selectService')), ]), ]) @@ -165,14 +165,14 @@ BuyButtonSubview.prototype.primarySubview = function () { style: { marginTop: '15px', }, - }, t('borrowDharma')) + }, t(this.props.localeMessages, 'borrowDharma')) ) : null, ]) ) default: return ( - h('h2.error', t('unknownNetworkId')) + h('h2.error', t(this.props.localeMessages, 'unknownNetworkId')) ) } @@ -205,7 +205,7 @@ BuyButtonSubview.prototype.mainnetSubview = function () { ], subtext: { 'Coinbase': `${t('crypto')}/${t('fiat')} (${t('usaOnly')})`, - 'ShapeShift': t('crypto'), + 'ShapeShift': t(this.props.localeMessages, 'crypto'), }, onClick: this.radioHandler.bind(this), }), diff --git a/ui/app/components/coinbase-form.js b/ui/app/components/coinbase-form.js index b9ef143e6..be413905e 100644 --- a/ui/app/components/coinbase-form.js +++ b/ui/app/components/coinbase-form.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 = global.getMessage +const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(CoinbaseForm) @@ -38,11 +38,11 @@ CoinbaseForm.prototype.render = function () { }, [ h('button.btn-green', { onClick: this.toCoinbase.bind(this), - }, t('continueToCoinbase')), + }, t(this.props.localeMessages, 'continueToCoinbase')), h('button.btn-red', { onClick: () => props.dispatch(actions.goHome()), - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), ]), ]) } diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js index 610d5b6a8..db43668cb 100644 --- a/ui/app/components/copyButton.js +++ b/ui/app/components/copyButton.js @@ -2,7 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const copyToClipboard = require('copy-to-clipboard') -const t = global.getMessage +const t = require('../../i18n-helper').getMessage const Tooltip = require('./tooltip') @@ -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 ? t(this.props.localeMessages, 'copiedButton') : props.title || t(this.props.localeMessages, 'copyButton') return h('.copy-button', { style: { diff --git a/ui/app/components/copyable.js b/ui/app/components/copyable.js index e0bf66f7e..92a337a37 100644 --- a/ui/app/components/copyable.js +++ b/ui/app/components/copyable.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const Tooltip = require('./tooltip') const copyToClipboard = require('copy-to-clipboard') -const t = global.getMessage +const t = require('../../i18n-helper').getMessage module.exports = Copyable @@ -23,7 +23,7 @@ Copyable.prototype.render = function () { const { copied } = state return h(Tooltip, { - title: copied ? t('copiedExclamation') : t('copy'), + title: copied ? t(this.props.localeMessages, 'copiedExclamation') : t(this.props.localeMessages, '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 ac8f3b842..8e3960ce4 100644 --- a/ui/app/components/customize-gas-modal/index.js +++ b/ui/app/components/customize-gas-modal/index.js @@ -1,10 +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 GasModalCard = require('./gas-modal-card') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage const ethUtil = require('ethereumjs-util') @@ -147,7 +147,7 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { }) if (!balanceIsSufficient) { - error = t('balanceIsInsufficientGas') + error = t(this.props.localeMessages, 'balanceIsInsufficientGas') } const gasLimitTooLow = gasLimit && conversionGreaterThan( @@ -163,7 +163,7 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { ) if (gasLimitTooLow) { - error = t('gasLimitTooLow') + error = t(this.props.localeMessages, 'gasLimitTooLow') } this.setState({ error }) @@ -240,7 +240,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', t(this.props.localeMessages, 'customGas')), h('div.send-v2__customize-gas__close', { onClick: hideModal, @@ -256,8 +256,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: t(this.props.localeMessages, 'gasPrice'), + copy: t(this.props.localeMessages, 'gasPriceCalculation'), }), h(GasModalCard, { @@ -266,8 +266,8 @@ CustomizeGasModal.prototype.render = function () { // max: 100000, step: 1, onChange: value => this.convertAndSetGasLimit(value), - title: t('gasLimit'), - copy: t('gasLimitCalculation'), + title: t(this.props.localeMessages, 'gasLimit'), + copy: t(this.props.localeMessages, 'gasLimitCalculation'), }), ]), diff --git a/ui/app/components/dropdowns/components/account-dropdowns.js b/ui/app/components/dropdowns/components/account-dropdowns.js index 0cdc2c0ae..73afb7009 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 = global.getMessage +const t = require('../../../../i18n-helper').getMessage class AccountDropdowns extends Component { @@ -131,7 +131,7 @@ class AccountDropdowns extends Component { actions.showEditAccountModal(identity) }, }, [ - t('edit'), + t(this.props.localeMessages, 'edit'), ]), ]), @@ -145,7 +145,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', t(this.props.localeMessages, 'loose')) : null } catch (e) { return } } @@ -203,7 +203,7 @@ class AccountDropdowns extends Component { fontSize: '16px', lineHeight: '23px', }, - }, t('createAccount')), + }, t(this.props.localeMessages, 'createAccount')), ], ), h( @@ -237,7 +237,7 @@ class AccountDropdowns extends Component { fontSize: '16px', lineHeight: '23px', }, - }, t('importAccount')), + }, t(this.props.localeMessages, 'importAccount')), ] ), ] @@ -288,7 +288,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t('accountDetails'), + t(this.props.localeMessages, 'accountDetails'), ), h( DropdownMenuItem, @@ -304,7 +304,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t('etherscanView'), + t(this.props.localeMessages, 'etherscanView'), ), h( DropdownMenuItem, @@ -320,7 +320,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t('copyAddress'), + t(this.props.localeMessages, 'copyAddress'), ), h( DropdownMenuItem, @@ -332,7 +332,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t('exportPrivateKey'), + t(this.props.localeMessages, 'exportPrivateKey'), ), h( DropdownMenuItem, @@ -347,7 +347,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t('addToken'), + t(this.props.localeMessages, 'addToken'), ), ] diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js index a7acc7bb9..61c574aed 100644 --- a/ui/app/components/dropdowns/network-dropdown.js +++ b/ui/app/components/dropdowns/network-dropdown.js @@ -1,13 +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 Dropdown = require('./components/dropdown').Dropdown const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem const NetworkDropdownIcon = require('./components/network-dropdown-icon') const R = require('ramda') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage // classes from nodes of the toggle element. @@ -95,13 +95,13 @@ NetworkDropdown.prototype.render = function () { }, [ h('div.network-dropdown-header', {}, [ - h('div.network-dropdown-title', {}, t('networks')), + h('div.network-dropdown-title', {}, t(this.props.localeMessages, 'networks')), h('div.network-dropdown-divider'), h('div.network-dropdown-content', {}, - t('defaultNetwork') + t(this.props.localeMessages, 'defaultNetwork') ), ]), @@ -123,7 +123,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'mainnet' ? '#ffffff' : '#9b9b9b', }, - }, t('mainnet')), + }, t(this.props.localeMessages, 'mainnet')), ] ), @@ -145,7 +145,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'ropsten' ? '#ffffff' : '#9b9b9b', }, - }, t('ropsten')), + }, t(this.props.localeMessages, 'ropsten')), ] ), @@ -167,7 +167,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'kovan' ? '#ffffff' : '#9b9b9b', }, - }, t('kovan')), + }, t(this.props.localeMessages, 'kovan')), ] ), @@ -189,7 +189,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'rinkeby' ? '#ffffff' : '#9b9b9b', }, - }, t('rinkeby')), + }, t(this.props.localeMessages, 'rinkeby')), ] ), @@ -211,7 +211,7 @@ NetworkDropdown.prototype.render = function () { style: { color: activeNetwork === 'http://localhost:8545' ? '#ffffff' : '#9b9b9b', }, - }, t('localhost')), + }, t(this.props.localeMessages, 'localhost')), ] ), @@ -235,7 +235,7 @@ NetworkDropdown.prototype.render = function () { style: { color: activeNetwork === 'custom' ? '#ffffff' : '#9b9b9b', }, - }, t('customRPC')), + }, t(this.props.localeMessages, 'customRPC')), ] ), @@ -250,15 +250,15 @@ NetworkDropdown.prototype.getNetworkName = function () { let name if (providerName === 'mainnet') { - name = t('mainnet') + name = t(this.props.localeMessages, 'mainnet') } else if (providerName === 'ropsten') { - name = t('ropsten') + name = t(this.props.localeMessages, 'ropsten') } else if (providerName === 'kovan') { - name = t('kovan') + name = t(this.props.localeMessages, 'kovan') } else if (providerName === 'rinkeby') { - name = t('rinkeby') + name = t(this.props.localeMessages, 'rinkeby') } else { - name = t('unknownNetwork') + name = t(this.props.localeMessages, 'unknownNetwork') } return name diff --git a/ui/app/components/dropdowns/token-menu-dropdown.js b/ui/app/components/dropdowns/token-menu-dropdown.js index 392f43c35..403d17591 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 = global.getMessage +const t = require('../../../i18n-helper').getMessage module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown) @@ -45,7 +45,7 @@ TokenMenuDropdown.prototype.render = function () { showHideTokenConfirmationModal(this.props.token) this.props.onClose() }, - }, t('hideToken')), + }, t(this.props.localeMessages, 'hideToken')), ]), ]), diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index 4f6b3afe4..ea26acbca 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -8,7 +8,7 @@ const ENS = require('ethjs-ens') const networkMap = require('ethjs-ens/lib/network-map.json') const ensRE = /.+\..+$/ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' -const t = global.getMessage +const t = require('../../i18n-helper').getMessage module.exports = EnsInput @@ -90,13 +90,13 @@ EnsInput.prototype.lookupEnsName = function () { 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(t(this.props.localeMessages, 'noAddressForName')) if (address !== ensResolution) { this.setState({ loadingEns: false, ensResolution: address, nickname: recipient.trim(), - hoverText: address + '\n' + t('clickCopy'), + hoverText: address + '\n' + t(this.props.localeMessages, '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..7e53ba2f0 100644 --- a/ui/app/components/hex-as-decimal-input.js +++ b/ui/app/components/hex-as-decimal-input.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const extend = require('xtend') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = HexAsDecimalInput @@ -127,13 +127,13 @@ HexAsDecimalInput.prototype.constructWarning = function () { let message = name ? name + ' ' : '' if (min && max) { - message += t('betweenMinAndMax', [min, max]) + message += t(this.props.localeMessages, 'betweenMinAndMax', [min, max]) } else if (min) { - message += t('greaterThanMin', [min]) + message += t(this.props.localeMessages, 'greaterThanMin', [min]) } else if (max) { - message += t('lessThanMax', [max]) + message += t(this.props.localeMessages, 'lessThanMax', [max]) } else { - message += t('invalidInput') + message += t(this.props.localeMessages, '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 c6a3111b1..e4f2009aa 100644 --- a/ui/app/components/modals/account-details-modal.js +++ b/ui/app/components/modals/account-details-modal.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 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 = global.getMessage +const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -65,12 +65,12 @@ AccountDetailsModal.prototype.render = function () { h('button.btn-clear.account-modal__button', { onClick: () => global.platform.openWindow({ url: genAccountLink(address, network) }), - }, t('etherscanView')), + }, t(this.props.localeMessages, 'etherscanView')), // Holding on redesign for Export Private Key functionality h('button.btn-clear.account-modal__button', { onClick: () => showExportPrivateKeyModal(), - }, t('exportPrivateKey')), + }, t(this.props.localeMessages, 'exportPrivateKey')), ]) } diff --git a/ui/app/components/modals/account-modal-container.js b/ui/app/components/modals/account-modal-container.js index 964677244..ac6457b37 100644 --- a/ui/app/components/modals/account-modal-container.js +++ b/ui/app/components/modals/account-modal-container.js @@ -1,11 +1,11 @@ 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 = global.getMessage +const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -60,7 +60,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', ' ' + t(this.props.localeMessages, 'back')), ]), diff --git a/ui/app/components/modals/buy-options-modal.js b/ui/app/components/modals/buy-options-modal.js index 33f8f6682..0e93e9a2d 100644 --- a/ui/app/components/modals/buy-options-modal.js +++ b/ui/app/components/modals/buy-options-modal.js @@ -1,10 +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 networkNames = require('../../../../app/scripts/config.js').networkNames -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -57,15 +57,15 @@ BuyOptions.prototype.render = function () { }, [ h('div.buy-modal-content-title', { style: {}, - }, t('transfers')), - h('div', {}, t('howToDeposit')), + }, t(this.props.localeMessages, 'transfers')), + h('div', {}, t(this.props.localeMessages, '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, t(this.props.localeMessages, 'testFaucet'), () => toFaucet(network)) + : this.renderModalContentOption('Coinbase', t(this.props.localeMessages, 'depositFiat'), () => toCoinbase(address)), // h('div.buy-modal-content-option', {}, [ // h('div.buy-modal-content-option-title', {}, 'Shapeshift'), @@ -73,8 +73,8 @@ BuyOptions.prototype.render = function () { // ]),, this.renderModalContentOption( - t('directDeposit'), - t('depositFromAccount'), + t(this.props.localeMessages, 'directDeposit'), + t(this.props.localeMessages, 'depositFromAccount'), () => this.goToAccountDetailsModal() ), @@ -85,7 +85,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', {}, t(this.props.localeMessages, 'cancel'))), ]), ]) } diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js index 03304207e..3984e2c7b 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -1,11 +1,11 @@ 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 = global.getMessage +const t = require('../../../i18n-helper').getMessage let DIRECT_DEPOSIT_ROW_TITLE let DIRECT_DEPOSIT_ROW_TEXT @@ -16,7 +16,7 @@ let SHAPESHIFT_ROW_TEXT let FAUCET_ROW_TITLE const facuetRowText = (networkName) => { - return t('getEtherFromFaucet', [networkName]) + return t(this.props.localeMessages, 'getEtherFromFaucet', [networkName]) } function mapStateToProps (state) { @@ -49,13 +49,13 @@ function DepositEtherModal () { Component.call(this) // need to set after i18n locale has loaded - DIRECT_DEPOSIT_ROW_TITLE = t('directDepositEther') - DIRECT_DEPOSIT_ROW_TEXT = t('directDepositEtherExplainer') - COINBASE_ROW_TITLE = t('buyCoinbase') - COINBASE_ROW_TEXT = t('buyCoinbaseExplainer') - SHAPESHIFT_ROW_TITLE = t('depositShapeShift') - SHAPESHIFT_ROW_TEXT = t('depositShapeShiftExplainer') - FAUCET_ROW_TITLE = t('testFaucet') + DIRECT_DEPOSIT_ROW_TITLE = t(this.props.localeMessages, 'directDepositEther') + DIRECT_DEPOSIT_ROW_TEXT = t(this.props.localeMessages, 'directDepositEtherExplainer') + COINBASE_ROW_TITLE = t(this.props.localeMessages, 'buyCoinbase') + COINBASE_ROW_TEXT = t(this.props.localeMessages, 'buyCoinbaseExplainer') + SHAPESHIFT_ROW_TITLE = t(this.props.localeMessages, 'depositShapeShift') + SHAPESHIFT_ROW_TEXT = t(this.props.localeMessages, 'depositShapeShiftExplainer') + FAUCET_ROW_TITLE = t(this.props.localeMessages, 'testFaucet') this.state = { buyingWithShapeshift: false, @@ -126,7 +126,7 @@ DepositEtherModal.prototype.render = function () { h('div.page-container__title', [t('depositEther')]), h('div.page-container__subtitle', [ - t('needEtherInWallet'), + t(this.props.localeMessages, 'needEtherInWallet'), ]), h('div.page-container__header-close', { @@ -147,7 +147,7 @@ DepositEtherModal.prototype.render = function () { logo: h('img.deposit-ether-modal__buy-row__eth-logo', { src: '../../../images/eth_logo.svg' }), title: DIRECT_DEPOSIT_ROW_TITLE, text: DIRECT_DEPOSIT_ROW_TEXT, - buttonLabel: t('viewAccount'), + buttonLabel: t(this.props.localeMessages, 'viewAccount'), onButtonClick: () => this.goToAccountDetailsModal(), hide: buyingWithShapeshift, }), @@ -156,7 +156,7 @@ DepositEtherModal.prototype.render = function () { logo: h('i.fa.fa-tint.fa-2x'), title: FAUCET_ROW_TITLE, text: facuetRowText(networkName), - buttonLabel: t('getEther'), + buttonLabel: t(this.props.localeMessages, 'getEther'), onButtonClick: () => toFaucet(network), hide: !isTestNetwork || buyingWithShapeshift, }), @@ -170,7 +170,7 @@ DepositEtherModal.prototype.render = function () { }), title: COINBASE_ROW_TITLE, text: COINBASE_ROW_TEXT, - buttonLabel: t('continueToCoinbase'), + buttonLabel: t(this.props.localeMessages, 'continueToCoinbase'), onButtonClick: () => toCoinbase(address), hide: isTestNetwork || buyingWithShapeshift, }), @@ -183,7 +183,7 @@ DepositEtherModal.prototype.render = function () { }), title: SHAPESHIFT_ROW_TITLE, text: SHAPESHIFT_ROW_TEXT, - buttonLabel: t('shapeshiftBuy'), + buttonLabel: t(this.props.localeMessages, '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 79d6109cc..02de5b99c 100644 --- a/ui/app/components/modals/edit-account-name-modal.js +++ b/ui/app/components/modals/edit-account-name-modal.js @@ -1,10 +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 { getSelectedAccount } = require('../../selectors') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -70,7 +70,7 @@ EditAccountNameModal.prototype.render = function () { }, disabled: this.state.inputText.length === 0, }, [ - t('save'), + t(this.props.localeMessages, 'save'), ]), ]), diff --git a/ui/app/components/modals/export-private-key-modal.js b/ui/app/components/modals/export-private-key-modal.js index 3fc93b4f5..fac5366a4 100644 --- a/ui/app/components/modals/export-private-key-modal.js +++ b/ui/app/components/modals/export-private-key-modal.js @@ -1,13 +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 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 = global.getMessage +const t = require('../../../i18n-helper').getMessage const copyToClipboard = require('copy-to-clipboard') function mapStateToProps (state) { @@ -49,8 +49,8 @@ ExportPrivateKeyModal.prototype.exportAccountAndGetPrivateKey = function (passwo ExportPrivateKeyModal.prototype.renderPasswordLabel = function (privateKey) { return h('span.private-key-password-label', privateKey - ? t('copyPrivateKey') - : t('typePassword') + ? t(this.props.localeMessages, 'copyPrivateKey') + : t(this.props.localeMessages, 'typePassword') ) } @@ -87,8 +87,8 @@ ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password, ), (privateKey - ? this.renderButton('btn-clear export-private-key__button', () => hideModal(), t('done')) - : this.renderButton('btn-clear export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), t('confirm')) + ? this.renderButton('btn-clear export-private-key__button', () => hideModal(), t(this.props.localeMessages, 'done')) + : this.renderButton('btn-clear export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), t(this.props.localeMessages, 'confirm')) ), ]) @@ -121,7 +121,7 @@ ExportPrivateKeyModal.prototype.render = function () { h('div.account-modal-divider'), - h('span.modal-body-title', t('showPrivateKeys')), + h('span.modal-body-title', t(this.props.localeMessages, 'showPrivateKeys')), h('div.private-key-password', {}, [ this.renderPasswordLabel(privateKey), @@ -131,7 +131,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', t(this.props.localeMessages, '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 efd472cf3..a6cf2889f 100644 --- a/ui/app/components/modals/hide-token-confirmation-modal.js +++ b/ui/app/components/modals/hide-token-confirmation-modal.js @@ -1,10 +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 Identicon = require('../identicon') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -42,7 +42,7 @@ HideTokenConfirmationModal.prototype.render = function () { h('div.hide-token-confirmation__container', { }, [ h('div.hide-token-confirmation__title', {}, [ - t('hideTokenPrompt'), + t(this.props.localeMessages, 'hideTokenPrompt'), ]), h(Identicon, { @@ -55,19 +55,19 @@ HideTokenConfirmationModal.prototype.render = function () { h('div.hide-token-confirmation__symbol', {}, symbol), h('div.hide-token-confirmation__copy', {}, [ - t('readdToken'), + t(this.props.localeMessages, 'readdToken'), ]), h('div.hide-token-confirmation__buttons', {}, [ h('button.btn-cancel.hide-token-confirmation__button.allcaps', { onClick: () => hideModal(), }, [ - t('cancel'), + t(this.props.localeMessages, 'cancel'), ]), h('button.btn-clear.hide-token-confirmation__button.allcaps', { onClick: () => hideToken(address), }, [ - t('hide'), + t(this.props.localeMessages, 'hide'), ]), ]), ]), diff --git a/ui/app/components/modals/modal.js b/ui/app/components/modals/modal.js index 9250cc77e..d0f4b486c 100644 --- a/ui/app/components/modals/modal.js +++ b/ui/app/components/modals/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 FadeModal = require('boron').FadeModal const actions = require('../../actions') const isMobileView = require('../../../lib/is-mobile-view') diff --git a/ui/app/components/modals/new-account-modal.js b/ui/app/components/modals/new-account-modal.js index 7fe367f3f..7f9b7a154 100644 --- a/ui/app/components/modals/new-account-modal.js +++ b/ui/app/components/modals/new-account-modal.js @@ -3,7 +3,7 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const { connect } = require('react-redux') const actions = require('../../actions') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage class NewAccountModal extends Component { constructor (props) { @@ -23,7 +23,7 @@ class NewAccountModal extends Component { h('div.new-account-modal-wrapper', { }, [ h('div.new-account-modal-header', {}, [ - t('newAccount'), + t(this.props.localeMessages, 'newAccount'), ]), h('div.modal-close-x', { @@ -31,19 +31,19 @@ class NewAccountModal extends Component { }), h('div.new-account-modal-content', {}, [ - t('accountName'), + t(this.props.localeMessages, 'accountName'), ]), h('div.new-account-input-wrapper', {}, [ h('input.new-account-input', { value: this.state.newAccountName, - placeholder: t('sampleAccountName'), + placeholder: t(this.props.localeMessages, 'sampleAccountName'), onChange: event => this.setState({ newAccountName: event.target.value }), }, []), ]), h('div.new-account-modal-content.after-input', {}, [ - t('or'), + t(this.props.localeMessages, 'or'), ]), h('div.new-account-modal-content.after-input.pointer', { @@ -51,13 +51,13 @@ class NewAccountModal extends Component { this.props.hideModal() this.props.showImportPage() }, - }, t('importAnAccount')), + }, t(this.props.localeMessages, 'importAnAccount')), h('div.new-account-modal-content.button.allcaps', {}, [ h('button.btn-clear', { onClick: () => this.props.createAccount(newAccountName), }, [ - t('save'), + t(this.props.localeMessages, 'save'), ]), ]), ]), diff --git a/ui/app/components/modals/notification-modal.js b/ui/app/components/modals/notification-modal.js index 071d7ffd5..c05d80251 100644 --- a/ui/app/components/modals/notification-modal.js +++ b/ui/app/components/modals/notification-modal.js @@ -3,7 +3,7 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const { connect } = require('react-redux') const actions = require('../../actions') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage class NotificationModal extends Component { render () { 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.js b/ui/app/components/network.js index f3df2242a..d3a36b012 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -3,7 +3,7 @@ const h = require('react-hyperscript') const classnames = require('classnames') const inherits = require('util').inherits const NetworkDropdownIcon = require('./dropdowns/components/network-dropdown-icon') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = Network @@ -34,7 +34,7 @@ Network.prototype.render = function () { onClick: (event) => this.props.onClick(event), }, [ h('img', { - title: t('attemptingConnect'), + title: t(props.localeMessages, 'attemptingConnect'), style: { width: '27px', }, @@ -42,22 +42,22 @@ Network.prototype.render = function () { }), ]) } else if (providerName === 'mainnet') { - hoverText = t('mainnet') + hoverText = t(props.localeMessages, 'mainnet') iconName = 'ethereum-network' } else if (providerName === 'ropsten') { - hoverText = t('ropsten') + hoverText = t(props.localeMessages, 'ropsten') iconName = 'ropsten-test-network' } else if (parseInt(networkNumber) === 3) { - hoverText = t('ropsten') + hoverText = t(props.localeMessages, 'ropsten') iconName = 'ropsten-test-network' } else if (providerName === 'kovan') { - hoverText = t('kovan') + hoverText = t(props.localeMessages, 'kovan') iconName = 'kovan-test-network' } else if (providerName === 'rinkeby') { - hoverText = t('rinkeby') + hoverText = t(props.localeMessages, 'rinkeby') iconName = 'rinkeby-test-network' } else { - hoverText = t('unknownNetwork') + hoverText = t(props.localeMessages, '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', t(props.localeMessages, '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', t(props.localeMessages, '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', t(props.localeMessages, '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', t(props.localeMessages, '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', t(props.localeMessages, '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..ffc5ec6f1 100644 --- a/ui/app/components/notice.js +++ b/ui/app/components/notice.js @@ -4,7 +4,7 @@ const h = require('react-hyperscript') const ReactMarkdown = require('react-markdown') const linker = require('extension-link-enabler') const findDOMNode = require('react-dom').findDOMNode -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = Notice @@ -111,7 +111,7 @@ Notice.prototype.render = function () { style: { marginTop: '18px', }, - }, t('accept')), + }, t(this.props.localeMessages, 'accept')), ]) ) } diff --git a/ui/app/components/pending-msg-details.js b/ui/app/components/pending-msg-details.js index 87e66855d..8edf21b48 100644 --- a/ui/app/components/pending-msg-details.js +++ b/ui/app/components/pending-msg-details.js @@ -1,7 +1,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage const AccountPanel = require('./account-panel') @@ -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', t(this.props.localeMessages, '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..2364353be 100644 --- a/ui/app/components/pending-msg.js +++ b/ui/app/components/pending-msg.js @@ -2,7 +2,7 @@ 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 t = require('../../i18n-helper').getMessage module.exports = PendingMsg @@ -30,14 +30,14 @@ PendingMsg.prototype.render = function () { fontWeight: 'bold', textAlign: 'center', }, - }, t('signMessage')), + }, t(this.props.localeMessages, 'signMessage')), h('.error', { style: { margin: '10px', }, }, [ - t('signNotice'), + t(this.props.localeMessages, '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')), + }, t(this.props.localeMessages, 'readMore')), ]), // message details @@ -56,10 +56,10 @@ PendingMsg.prototype.render = function () { h('.flex-row.flex-space-around', [ h('button', { onClick: state.cancelMessage, - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), h('button', { onClick: state.signMessage, - }, t('sign')), + }, t(this.props.localeMessages, 'sign')), ]), ]) diff --git a/ui/app/components/pending-personal-msg-details.js b/ui/app/components/pending-personal-msg-details.js index b896e9a7e..74f7b2ba0 100644 --- a/ui/app/components/pending-personal-msg-details.js +++ b/ui/app/components/pending-personal-msg-details.js @@ -1,7 +1,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage const AccountPanel = require('./account-panel') const BinaryRenderer = require('./binary-renderer') @@ -46,7 +46,7 @@ PendingMsgDetails.prototype.render = function () { height: '260px', }, }, [ - h('label.font-small.allcaps', { style: { display: 'block' } }, t('message')), + h('label.font-small.allcaps', { style: { display: 'block' } }, t(this.props.localeMessages, 'message')), h(BinaryRenderer, { value: data, style: { diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index b6bfb9afe..483574094 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -9,7 +9,7 @@ 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 = global.getMessage +const t = require('../../../i18n-helper').getMessage const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') @@ -56,7 +56,7 @@ ConfirmDeployContract.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(t(this.props.localeMessages, 'invalidGasParams'))) this.setState({ submitting: false }) } } @@ -201,7 +201,7 @@ ConfirmDeployContract.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', [ t(this.props.localeMessages, 'gasFee') ]), h('div.confirm-screen-section-column', [ h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency.toUpperCase()}`), @@ -240,8 +240,8 @@ ConfirmDeployContract.prototype.renderTotalPlusGas = function () { return ( h('section.flex-row.flex-center.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', [ t(this.props.localeMessages, 'total') + ' ' ]), + h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, 'amountPlusGas') ]), ]), h('div.confirm-screen-section-column', [ @@ -274,8 +274,8 @@ ConfirmDeployContract.prototype.render = function () { h('h3.flex-center.confirm-screen-header', [ h('button.confirm-screen-back-button.allcaps', { onClick: () => backToAccountDetail(selectedAddress), - }, t('back')), - h('div.confirm-screen-title', t('confirmContract')), + }, t(this.props.localeMessages, 'back')), + h('div.confirm-screen-title', t(this.props.localeMessages, 'confirmContract')), h('div.confirm-screen-header-tip'), ]), h('div.flex-row.flex-center.confirm-screen-identicons', [ @@ -293,7 +293,7 @@ ConfirmDeployContract.prototype.render = function () { h('i.fa.fa-arrow-right.fa-lg'), h('div.confirm-screen-account-wrapper', [ h('i.fa.fa-file-text-o'), - h('span.confirm-screen-account-name', t('newContract')), + h('span.confirm-screen-account-name', t(this.props.localeMessages, 'newContract')), h('span.confirm-screen-account-number', ' '), ]), ]), @@ -311,7 +311,7 @@ ConfirmDeployContract.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', [ t(this.props.localeMessages, '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)}`), @@ -319,9 +319,9 @@ ConfirmDeployContract.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', [ t(this.props.localeMessages, 'to') ]), h('div.confirm-screen-section-column', [ - h('div.confirm-screen-row-info', t('newContract')), + h('div.confirm-screen-row-info', t(this.props.localeMessages, 'newContract')), ]), ]), @@ -338,7 +338,7 @@ ConfirmDeployContract.prototype.render = function () { // Cancel Button h('div.cancel.btn-light.confirm-screen-cancel-button.allcaps', { onClick: (event) => this.cancel(event, txMeta), - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), // Accept Button h('button.confirm-screen-confirm-button.allcaps', [t('confirm')]), diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index 7e1b25bb7..7fd498d83 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -9,7 +9,7 @@ const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const hexToBn = require('../../../../app/scripts/lib/hex-to-bn') const { conversionUtil, addCurrencies } = require('../../conversion-util') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') @@ -166,7 +166,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 : t(this.props.localeMessages, 'newRecipient'), }, memo: txParams.memo || '', gasFeeInFIAT, @@ -267,7 +267,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', [ t(this.props.localeMessages, '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)}`), @@ -275,7 +275,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', [ t(this.props.localeMessages, '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)}`), @@ -283,7 +283,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', [ t(this.props.localeMessages, 'gasFee') ]), h('div.confirm-screen-section-column', [ h('div.confirm-screen-row-info', `${gasFeeInFIAT} ${currentCurrency.toUpperCase()}`), @@ -294,8 +294,8 @@ ConfirmSendEther.prototype.render = function () { h('section.flex-row.flex-center.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', [ t(this.props.localeMessages, 'total') + ' ' ]), + h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, 'amountPlusGas') ]), ]), h('div.confirm-screen-section-column', [ @@ -395,7 +395,7 @@ ConfirmSendEther.prototype.render = function () { clearSend() this.cancel(event, txMeta) }, - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), // Accept Button h('button.confirm-screen-confirm-button.allcaps', [t('confirm')]), @@ -413,7 +413,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(t(this.props.localeMessages, '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 3a7678aa3..bd1ad82ef 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -6,7 +6,7 @@ const tokenAbi = require('human-standard-token-abi') const abiDecoder = require('abi-decoder') abiDecoder.addABI(tokenAbi) const actions = require('../../actions') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage const clone = require('clone') const Identicon = require('../identicon') const ethUtil = require('ethereumjs-util') @@ -134,7 +134,7 @@ ConfirmSendToken.prototype.getAmount = function () { ? +(sendTokenAmount * tokenExchangeRate * conversionRate).toFixed(2) : null, token: typeof value === 'undefined' - ? t('unknown') + ? t(this.props.localeMessages, 'unknown') : +sendTokenAmount.toFixed(decimals), } @@ -205,7 +205,7 @@ ConfirmSendToken.prototype.getData = function () { }, to: { address: value, - name: identities[value] ? identities[value].name : t('newRecipient'), + name: identities[value] ? identities[value].name : t(this.props.localeMessages, 'newRecipient'), }, memo: txParams.memo || '', } @@ -245,7 +245,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', [ t(this.props.localeMessages, 'gasFee') ]), h('div.confirm-screen-section-column', [ h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency}`), @@ -267,8 +267,8 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () { ? ( h('section.flex-row.flex-center.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', [ t(this.props.localeMessages, 'total') + ' ' ]), + h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, 'amountPlusGas') ]), ]), h('div.confirm-screen-section-column', [ @@ -280,8 +280,8 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () { : ( h('section.flex-row.flex-center.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', [ t(this.props.localeMessages, 'total') + ' ' ]), + h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, 'amountPlusGas') ]), ]), h('div.confirm-screen-section-column', [ @@ -315,9 +315,9 @@ ConfirmSendToken.prototype.render = function () { h('div.page-container__header', [ h('button.confirm-screen-back-button', { onClick: () => editTransaction(txMeta), - }, t('edit')), - h('div.page-container__title', t('confirm')), - h('div.page-container__subtitle', t('pleaseReviewTransaction')), + }, t(this.props.localeMessages, 'edit')), + h('div.page-container__title', t(this.props.localeMessages, 'confirm')), + h('div.page-container__subtitle', t(this.props.localeMessages, 'pleaseReviewTransaction')), ]), h('div.flex-row.flex-center.confirm-screen-identicons', [ h('div.confirm-screen-account-wrapper', [ @@ -358,7 +358,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', [ t(this.props.localeMessages, '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)}`), @@ -366,7 +366,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', [ t(this.props.localeMessages, '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)}`), @@ -386,7 +386,7 @@ ConfirmSendToken.prototype.render = function () { // Cancel Button h('div.cancel.btn-light.confirm-screen-cancel-button.allcaps', { onClick: (event) => this.cancel(event, txMeta), - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), // Accept Button h('button.confirm-screen-confirm-button.allcaps', [t('confirm')]), @@ -406,7 +406,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(t(this.props.localeMessages, 'invalidGasParams'))) this.setState({ submitting: false }) } } diff --git a/ui/app/components/pending-typed-msg-details.js b/ui/app/components/pending-typed-msg-details.js index ae0a1171e..21eec3ce5 100644 --- a/ui/app/components/pending-typed-msg-details.js +++ b/ui/app/components/pending-typed-msg-details.js @@ -4,7 +4,7 @@ const inherits = require('util').inherits const AccountPanel = require('./account-panel') const TypedMessageRenderer = require('./typed-message-renderer') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = PendingMsgDetails @@ -46,7 +46,7 @@ PendingMsgDetails.prototype.render = function () { height: '260px', }, }, [ - h('label.font-small.allcaps', { style: { display: 'block' } }, t('youSign')), + h('label.font-small.allcaps', { style: { display: 'block' } }, t(this.props.localeMessages, 'youSign')), h(TypedMessageRenderer, { value: data, style: { diff --git a/ui/app/components/pending-typed-msg.js b/ui/app/components/pending-typed-msg.js index ccde5e8af..91fa5f052 100644 --- a/ui/app/components/pending-typed-msg.js +++ b/ui/app/components/pending-typed-msg.js @@ -2,7 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const PendingTxDetails = require('./pending-typed-msg-details') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = PendingMsg @@ -27,7 +27,7 @@ PendingMsg.prototype.render = function () { fontWeight: 'bold', textAlign: 'center', }, - }, t('signMessage')), + }, t(this.props.localeMessages, 'signMessage')), // message details h(PendingTxDetails, state), @@ -36,10 +36,10 @@ PendingMsg.prototype.render = function () { h('.flex-row.flex-space-around', [ h('button.allcaps', { onClick: state.cancelTypedMessage, - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), h('button.allcaps', { onClick: state.signTypedMessage, - }, t('sign')), + }, t(this.props.localeMessages, 'sign')), ]), ]) 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-token/index.js b/ui/app/components/send-token/index.js index 4519f469b..96ccde214 100644 --- a/ui/app/components/send-token/index.js +++ b/ui/app/components/send-token/index.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 classnames = require('classnames') const abi = require('ethereumjs-abi') @@ -7,7 +7,7 @@ const inherits = require('util').inherits const actions = require('../../actions') const selectors = require('../../selectors') const { isValidAddress, allNull } = require('../../util') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage // const BalanceComponent = require('./balance-component') const Identicon = require('../identicon') @@ -127,14 +127,14 @@ SendTokenScreen.prototype.validate = function () { const amount = Number(stringAmount) const errors = { - to: !to ? t('required') : null, - amount: !amount ? t('required') : null, - gasPrice: !gasPrice ? t('gasPriceRequired') : null, - gasLimit: !gasLimit ? t('gasLimitRequired') : null, + to: !to ? t(this.props.localeMessages, 'required') : null, + amount: !amount ? t(this.props.localeMessages, 'required') : null, + gasPrice: !gasPrice ? t(this.props.localeMessages, 'gasPriceRequired') : null, + gasLimit: !gasLimit ? t(this.props.localeMessages, 'gasLimitRequired') : null, } if (to && !isValidAddress(to)) { - errors.to = t('invalidAddress') + errors.to = t(this.props.localeMessages, 'invalidAddress') } const isValid = Object.entries(errors).every(([key, value]) => value === null) @@ -238,7 +238,7 @@ SendTokenScreen.prototype.renderToAddressInput = function () { h('input.large-input.send-screen-input', { name: 'address', list: 'addresses', - placeholder: t('address'), + placeholder: t(this.props.localeMessages, 'address'), value: to, onChange: e => this.setState({ to: e.target.value, @@ -356,7 +356,7 @@ SendTokenScreen.prototype.renderGasInput = function () { }), h('div.send-screen-gas-labels', {}, [ - h('span', [ h('i.fa.fa-bolt'), t('gasFee') + ':']), + h('span', [ h('i.fa.fa-bolt'), t(this.props.localeMessages, 'gasFee') + ':']), h('span', [t('whatsThis')]), ]), h('div.large-input.send-screen-gas-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 2aaa43350..c156e4482 100644 --- a/ui/app/components/send/gas-fee-display-v2.js +++ b/ui/app/components/send/gas-fee-display-v2.js @@ -2,7 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const CurrencyDisplay = require('./currency-display') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage module.exports = GasFeeDisplay @@ -31,7 +31,7 @@ GasFeeDisplay.prototype.render = function () { convertedPrefix: '$', readOnly: true, }) - : h('div.currency-display', t('loading')), + : h('div.currency-display', t(this.props.localeMessages, 'loading')), h('button.send-v2__sliders-icon-container', { onClick, diff --git a/ui/app/components/send/gas-tooltip.js b/ui/app/components/send/gas-tooltip.js index 246c25152..8411fd61b 100644 --- a/ui/app/components/send/gas-tooltip.js +++ b/ui/app/components/send/gas-tooltip.js @@ -2,7 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const InputNumber = require('../input-number.js') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage module.exports = GasTooltip diff --git a/ui/app/components/send/send-v2-container.js b/ui/app/components/send/send-v2-container.js index 1106902b7..a2a3ed389 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 1b0a1064a..ca034d855 100644 --- a/ui/app/components/send/to-autocomplete.js +++ b/ui/app/components/send/to-autocomplete.js @@ -2,7 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const AccountListItem = require('./account-list-item') -const t = global.getMessage +const t = require('../../../i18n-helper').getMessage module.exports = 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: t(this.props.localeMessages, 'recipientAddress'), className: inError ? `send-v2__error-border` : '', value: to, onChange: event => onChange(event.target.value), diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js index 3f8c17932..46b16975a 100644 --- a/ui/app/components/shapeshift-form.js +++ b/ui/app/components/shapeshift-form.js @@ -1,13 +1,13 @@ 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') +const t = require('../../i18n-helper').getMessage function mapStateToProps (state) { const { @@ -94,7 +94,7 @@ ShapeshiftForm.prototype.onBuyWithShapeShift = function () { })) .catch(() => this.setState({ showQrCode: false, - errorMessage: t('invalidRequest'), + errorMessage: t(this.props.localeMessages, 'invalidRequest'), isLoading: false, })) } @@ -126,10 +126,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(t(this.props.localeMessages, 'status'), limit ? t(this.props.localeMessages, 'available') : t(this.props.localeMessages, 'unavailable')), + this.renderMetadata(t(this.props.localeMessages, 'limit'), limit), + this.renderMetadata(t(this.props.localeMessages, 'exchangeRate'), rate), + this.renderMetadata(t(this.props.localeMessages, 'min'), minimum), ]) } @@ -143,7 +143,7 @@ ShapeshiftForm.prototype.renderQrCode = function () { return h('div.shapeshift-form', {}, [ h('div.shapeshift-form__deposit-instruction', [ - t('depositCoin', [depositCoin.toUpperCase()]), + t(this.props.localeMessages, 'depositCoin', [depositCoin.toUpperCase()]), ]), h('div', depositAddress), @@ -180,7 +180,7 @@ ShapeshiftForm.prototype.render = function () { h('div.shapeshift-form__selector', [ - h('div.shapeshift-form__selector-label', t('deposit')), + h('div.shapeshift-form__selector-label', t(this.props.localeMessages, 'deposit')), h(SimpleDropdown, { selectedOption: this.state.depositCoin, @@ -200,7 +200,7 @@ ShapeshiftForm.prototype.render = function () { h('div.shapeshift-form__selector', [ h('div.shapeshift-form__selector-label', [ - t('receive'), + t(this.props.localeMessages, 'receive'), ]), h('div.shapeshift-form__selector-input', ['ETH']), @@ -218,7 +218,7 @@ ShapeshiftForm.prototype.render = function () { }, [ h('div.shapeshift-form__address-input-label', [ - t('refundAddress'), + t(this.props.localeMessages, 'refundAddress'), ]), h('input.shapeshift-form__address-input', { diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js index fddbc6821..cc401bc34 100644 --- a/ui/app/components/shift-list-item.js +++ b/ui/app/components/shift-list-item.js @@ -1,12 +1,12 @@ 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 t = require('../../i18n-helper').getMessage const CopyButton = require('./copyButton') const EthBalance = require('./eth-balance') @@ -76,7 +76,7 @@ ShiftListItem.prototype.renderUtilComponents = function () { value: this.props.depositAddress, }), h(Tooltip, { - title: t('qrCode'), + title: t(this.props.localeMessages, 'qrCode'), }, [ h('i.fa.fa-qrcode.pointer.pop-hover', { onClick: () => props.dispatch(actions.reshowQrCode(props.depositAddress, props.depositType)), @@ -136,8 +136,8 @@ ShiftListItem.prototype.renderInfo = function () { color: '#ABA9AA', width: '100%', }, - }, t('toETHviaShapeShift', [props.depositType])), - h('div', t('noDeposits')), + }, t(this.props.localeMessages, 'toETHviaShapeShift', [props.depositType])), + h('div', t(this.props.localeMessages, 'noDeposits')), h('div', { style: { fontSize: 'x-small', @@ -159,8 +159,8 @@ ShiftListItem.prototype.renderInfo = function () { color: '#ABA9AA', width: '100%', }, - }, t('toETHviaShapeShift', [props.depositType])), - h('div', t('conversionProgress')), + }, t(this.props.localeMessages, 'toETHviaShapeShift', [props.depositType])), + h('div', t(this.props.localeMessages, 'conversionProgress')), h('div', { style: { fontSize: 'x-small', @@ -185,7 +185,7 @@ ShiftListItem.prototype.renderInfo = function () { color: '#ABA9AA', width: '100%', }, - }, t('fromShapeShift')), + }, t(this.props.localeMessages, 'fromShapeShift')), h('div', formatDate(props.time)), h('div', { style: { @@ -197,7 +197,7 @@ ShiftListItem.prototype.renderInfo = function () { ]) case 'failed': - return h('span.error', '(' + t('failed') + ')') + return h('span.error', '(' + t(this.props.localeMessages, 'failed') + ')') default: return '' } diff --git a/ui/app/components/signature-request.js b/ui/app/components/signature-request.js index 7bf34e7b6..d6dd424ec 100644 --- a/ui/app/components/signature-request.js +++ b/ui/app/components/signature-request.js @@ -2,14 +2,14 @@ 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 t = require('../../i18n-helper').getMessage const { conversionUtil } = require('../conversion-util') const { @@ -55,7 +55,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', t(this.props.localeMessages, 'sigRequest')), h('div.request-signature__header__tip-container', [ h('div.request-signature__header__tip'), @@ -137,7 +137,7 @@ SignatureRequest.prototype.renderRequestInfo = function () { return h('div.request-signature__request-info', [ h('div.request-signature__headline', [ - t('yourSigRequested'), + t(this.props.localeMessages, 'yourSigRequested'), ]), ]) @@ -155,18 +155,18 @@ SignatureRequest.prototype.msgHexToText = function (hex) { SignatureRequest.prototype.renderBody = function () { let rows - let notice = t('youSign') + ':' + let notice = t(this.props.localeMessages, 'youSign') + ':' const { txData } = this.props const { type, msgParams: { data } } = txData if (type === 'personal_sign') { - rows = [{ name: t('message'), value: this.msgHexToText(data) }] + rows = [{ name: t(this.props.localeMessages, '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: t(this.props.localeMessages, 'message'), value: data }] + notice = t(this.props.localeMessages, 'signNotice') } return h('div.request-signature__body', {}, [ @@ -225,10 +225,10 @@ SignatureRequest.prototype.renderFooter = function () { return h('div.request-signature__footer', [ h('button.request-signature__footer__cancel-button', { onClick: cancel, - }, t('cancel')), + }, t(this.props.localeMessages, 'cancel')), h('button.request-signature__footer__sign-button', { onClick: sign, - }, t('sign')), + }, t(this.props.localeMessages, '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..439619158 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -3,9 +3,9 @@ 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') +const t = require('../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -43,7 +43,7 @@ TokenList.prototype.render = function () { const { tokens, isLoading, error } = state if (isLoading) { - return this.message(t('loadingTokens')) + return this.message(t(this.props.localeMessages, 'loadingTokens')) } if (error) { @@ -53,7 +53,7 @@ TokenList.prototype.render = function () { padding: '80px', }, }, [ - t('troubleTokenBalances'), + t(this.props.localeMessages, 'troubleTokenBalances'), h('span.hotFix', { style: { color: 'rgba(247, 134, 28, 1)', @@ -64,7 +64,7 @@ TokenList.prototype.render = function () { url: `https://ethplorer.io/address/${userAddress}`, }) }, - }, t('here')), + }, t(this.props.localeMessages, 'here')), ]) } diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index 6d6e79bd5..50555f2f3 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-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 EthBalance = require('./eth-balance') const addressSummary = require('../util').addressSummary @@ -11,7 +11,7 @@ const vreme = new (require('vreme'))() const Tooltip = require('./tooltip') const numberToBN = require('number-to-bn') const actions = require('../actions') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage const TransactionIcon = require('./transaction-list-item-icon') const ShiftListItem = require('./shift-list-item') @@ -86,7 +86,7 @@ TransactionListItem.prototype.render = function () { ]), h(Tooltip, { - title: t('transactionNumber'), + title: t(this.props.localeMessages, 'transactionNumber'), position: 'right', }, [ h('span', { @@ -143,12 +143,12 @@ TransactionListItem.prototype.render = function () { style: { paddingRight: '2px', }, - }, t('takesTooLong')), + }, t(this.props.localeMessages, 'takesTooLong')), h('div', { style: { textDecoration: 'underline', }, - }, t('retryWithMoreGas')), + }, t(this.props.localeMessages, 'retryWithMoreGas')), ]), ]) ) @@ -177,11 +177,11 @@ function recipientField (txParams, transaction, isTx, isMsg) { let message if (isMsg) { - message = t('sigRequested') + message = t(this.props.localeMessages, 'sigRequested') } else if (txParams.to) { message = addressSummary(txParams.to) } else { - message = t('contractDeployment') + message = t(this.props.localeMessages, 'contractDeployment') } return h('div', { @@ -204,7 +204,7 @@ function renderErrorOrWarning (transaction) { // show rejected if (status === 'rejected') { - return h('span.error', ' (' + t('rejected') + ')') + return h('span.error', ' (' + t(this.props.localeMessages, 'rejected') + ')') } if (transaction.err || transaction.warning) { const { err, warning = {} } = transaction @@ -220,7 +220,7 @@ function renderErrorOrWarning (transaction) { title: message, position: 'bottom', }, [ - h(`span.error`, ` (` + t('failed') + `)`), + h(`span.error`, ` (` + t(this.props.localeMessages, 'failed') + `)`), ]) ) } @@ -232,7 +232,7 @@ function renderErrorOrWarning (transaction) { title: message, position: 'bottom', }, [ - h(`span.warning`, ` (` + t('warning') + `)`), + h(`span.warning`, ` (` + t(this.props.localeMessages, 'warning') + `)`), ]) } } diff --git a/ui/app/components/transaction-list.js b/ui/app/components/transaction-list.js index 07f7a06ae..66da7054e 100644 --- a/ui/app/components/transaction-list.js +++ b/ui/app/components/transaction-list.js @@ -3,7 +3,7 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const TransactionListItem = require('./transaction-list-item') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = TransactionList @@ -79,7 +79,7 @@ TransactionList.prototype.render = function () { style: { marginTop: '50px', }, - }, t('noTransactionHistory')), + }, t(this.props.localeMessages, 'noTransactionHistory')), ]), ]), ]) diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 849d70489..db8621434 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') @@ -13,7 +13,7 @@ const { conversionUtil, multiplyCurrencies } = require('../conversion-util') const { calcTokenAmount } = require('../token-util') const { getCurrentCurrency } = require('../selectors') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(TxListItem) @@ -64,7 +64,7 @@ TxListItem.prototype.getAddressText = function () { default: return address ? `${address.slice(0, 10)}...${address.slice(-4)}` - : t('contractDeployment') + : t(this.props.localeMessages, 'contractDeployment') } } diff --git a/ui/app/components/tx-list.js b/ui/app/components/tx-list.js index 34dc837ae..d536b2806 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') @@ -10,7 +10,7 @@ const { formatDate } = require('../util') const { showConfTxPage } = require('../actions') const classnames = require('classnames') const { tokenInfoGetter } = require('../token-util') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(TxList) @@ -57,7 +57,7 @@ TxList.prototype.renderTransaction = function () { : [h( 'div.tx-list-item.tx-list-item--empty', { key: 'tx-list-none' }, - [ t('noTransactions') ], + [ t(this.props.localeMessages, 'noTransactions') ], )] } @@ -108,7 +108,7 @@ TxList.prototype.renderTransactionListItem = function (transaction, conversionRa if (isUnapproved) { opts.onClick = () => showConfTxPage({id: transActionId}) - opts.transactionStatus = t('Not Started') + opts.transactionStatus = t(this.props.localeMessages, 'Not Started') } 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 96d776270..f7ca9cc97 100644 --- a/ui/app/components/tx-view.js +++ b/ui/app/components/tx-view.js @@ -1,11 +1,11 @@ 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 const actions = require('../actions') const selectors = require('../selectors') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage const BalanceComponent = require('./balance-component') const TxList = require('./tx-list') @@ -73,21 +73,21 @@ TxView.prototype.renderButtons = function () { onClick: () => showModal({ name: 'DEPOSIT_ETHER', }), - }, t('deposit')), + }, t(this.props.localeMessages, 'deposit')), h('button.btn-clear.hero-balance-button.allcaps', { style: { marginLeft: '0.8em', }, onClick: showSendPage, - }, t('send')), + }, t(this.props.localeMessages, 'send')), ]) ) : ( h('div.flex-row.flex-center.hero-balance-buttons', [ h('button.btn-clear.hero-balance-button', { onClick: showSendTokenPage, - }, t('send')), + }, t(this.props.localeMessages, 'send')), ]) ) } diff --git a/ui/app/components/wallet-view.js b/ui/app/components/wallet-view.js index 18452205c..54770e436 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 inherits = require('util').inherits const classnames = require('classnames') @@ -11,7 +11,7 @@ const actions = require('../actions') const BalanceComponent = require('./balance-component') const TokenList = require('./token-list') const selectors = require('../selectors') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(WalletView) @@ -117,7 +117,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 ? t(this.props.localeMessages, 'imported') : ''), h('div.flex-column.flex-center.wallet-view__name-container', { style: { margin: '0 auto' }, @@ -134,13 +134,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', t(this.props.localeMessages, 'details')), ]), ]), h(Tooltip, { position: 'bottom', - title: this.state.hasCopied ? t('copiedExclamation') : t('copyToClipboard'), + title: this.state.hasCopied ? t(this.props.localeMessages, 'copiedExclamation') : t(this.props.localeMessages, 'copyToClipboard'), wrapperClassName: 'wallet-view__tooltip', }, [ h('button.wallet-view__address', { @@ -173,7 +173,7 @@ WalletView.prototype.render = function () { showAddTokenPage() hideSidebar() }, - }, t('addToken')), + }, t(this.props.localeMessages, 'addToken')), ]) } diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js index b4ffc48b7..cbf5cd1d2 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 actions = require('./actions') const txHelper = require('../lib/tx-helper') diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 370fdd5b7..797718498 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -1,12 +1,12 @@ const inherits = require('util').inherits const EventEmitter = require('events').EventEmitter const Component = require('react').Component -const connect = require('react-redux').connect +const connect = require('../metamask-connect') const h = require('react-hyperscript') const Mascot = require('../components/mascot') const actions = require('../actions') const Tooltip = require('../components/tooltip') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage const getCaretCoordinates = require('textarea-caret') const environmentType = require('../../../app/scripts/lib/environment-type') const { OLD_UI_NETWORK_TYPE } = require('../../../app/scripts/config').enums @@ -60,7 +60,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { color: '#7F8082', marginBottom: 10, }, - }, t('appName')), + }, t(this.props.localeMessages, 'appName')), h('div', [ @@ -70,10 +70,10 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { color: '#7F8082', display: 'inline', }, - }, t('encryptNewDen')), + }, t(this.props.localeMessages, 'encryptNewDen')), h(Tooltip, { - title: t('denExplainer'), + title: t(this.props.localeMessages, 'denExplainer'), }, [ h('i.fa.fa-question-circle.pointer', { style: { @@ -93,7 +93,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { h('input.large-input.letter-spacey', { type: 'password', id: 'password-box', - placeholder: t('newPassword'), + placeholder: t(this.props.localeMessages, 'newPassword'), onInput: this.inputChanged.bind(this), style: { width: 260, @@ -105,7 +105,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { h('input.large-input.letter-spacey', { type: 'password', id: 'password-box-confirm', - placeholder: t('confirmPassword'), + placeholder: t(this.props.localeMessages, 'confirmPassword'), onKeyPress: this.createVaultOnEnter.bind(this), onInput: this.inputChanged.bind(this), style: { @@ -120,7 +120,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { style: { margin: 12, }, - }, t('createDen')), + }, t(this.props.localeMessages, 'createDen')), h('.flex-row.flex-center.flex-grow', [ h('p.pointer', { @@ -130,7 +130,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { color: 'rgb(247, 134, 28)', textDecoration: 'underline', }, - }, t('importDen')), + }, t(this.props.localeMessages, 'importDen')), ]), h('.flex-row.flex-center.flex-grow', [ @@ -179,12 +179,12 @@ InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () { var passwordConfirm = passwordConfirmBox.value if (password.length < 8) { - this.warning = t('passwordShort') + this.warning = t(this.props.localeMessages, 'passwordShort') this.props.dispatch(actions.displayWarning(this.warning)) return } if (password !== passwordConfirm) { - this.warning = t('passwordMismatch') + this.warning = t(this.props.localeMessages, 'passwordMismatch') this.props.dispatch(actions.displayWarning(this.warning)) return } diff --git a/ui/app/info.js b/ui/app/info.js index 49ff9f24a..3375478dd 100644 --- a/ui/app/info.js +++ b/ui/app/info.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 actions = require('./actions') module.exports = connect(mapStateToProps)(InfoScreen) diff --git a/ui/app/keychains/hd/create-vault-complete.js b/ui/app/keychains/hd/create-vault-complete.js index 5ab5d4c33..9d99eeb0d 100644 --- a/ui/app/keychains/hd/create-vault-complete.js +++ b/ui/app/keychains/hd/create-vault-complete.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 actions = require('../../actions') const exportAsFile = require('../../util').exportAsFile diff --git a/ui/app/keychains/hd/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js index 4335186a5..5f323f7a1 100644 --- a/ui/app/keychains/hd/recover-seed/confirmation.js +++ b/ui/app/keychains/hd/recover-seed/confirmation.js @@ -1,7 +1,7 @@ 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') diff --git a/ui/app/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js index cb4088f61..0a604f505 100644 --- a/ui/app/keychains/hd/restore-vault.js +++ b/ui/app/keychains/hd/restore-vault.js @@ -1,6 +1,6 @@ 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 actions = require('../../actions') diff --git a/ui/app/metamask-connect.js b/ui/app/metamask-connect.js new file mode 100644 index 000000000..eef90529b --- /dev/null +++ b/ui/app/metamask-connect.js @@ -0,0 +1,18 @@ +const connect = require('react-redux').connect + +const metamaskConnect = (mapStateToProps, mapDispatchToProps) => { + return connect( + _higherOrderMapStateToProps(mapStateToProps), + mapDispatchToProps + ) +} + +const _higherOrderMapStateToProps = (mapStateToProps) => { + return (state, ownProps) => { + const stateProps = mapStateToProps(state, ownProps) + stateProps.localeMessages = state.localeMessages || {} + 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..d8b78e1dd --- /dev/null +++ b/ui/app/reducers/locale.js @@ -0,0 +1,18 @@ +const extend = require('xtend') +const actions = require('../actions') +const MetamascaraPlatform = require('../../../app/scripts/platforms/window') +const environmentType = require('../../../app/scripts/lib/environment-type') +const { OLD_UI_NETWORK_TYPE } = require('../../../app/scripts/config').enums + +module.exports = reduceMetamask + +function reduceMetamask (state, action) { + const localeMessagesState = extend({}, state.localeMessages) + + switch (action.type) { + case actions.SET_LOCALE_MESSAGES: + return action.value + default: + return localeMessagesState + } +} diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 4ca7d221e..611c55391 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -45,6 +45,7 @@ function reduceMetamask (state, action) { networkEndpointType: OLD_UI_NETWORK_TYPE, isRevealingSeedWords: false, welcomeScreenSeen: false, + currentLocale: 'ja', }, state.metamask) switch (action.type) { @@ -353,6 +354,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 193c98353..fca3decce 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 App = require('./app') const OldApp = require('../../old-ui/app/app') diff --git a/ui/app/send.js b/ui/app/send.js index 517b7690d..b6fa0c0da 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -1,7 +1,7 @@ // const { inherits } = require('util') // const PersistentForm = require('../lib/persistent-form') // const h = require('react-hyperscript') -// const connect = require('react-redux').connect +// const connect = require('./metamask-connect') // const Identicon = require('./components/identicon') // const EnsInput = require('./components/ens-input') // const GasTooltip = require('./components/send/gas-tooltip') diff --git a/ui/app/settings.js b/ui/app/settings.js index 95b69e46e..708d11082 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -112,9 +112,9 @@ class Settings extends Component { } renderCurrentLocale () { - const { setCurrentLocale } = this.props - const currentLocaleName = global.translator.localeName - const currentLocale = locales.find(locale => locale.code === currentLocaleName) + const { updateCurrentLocale, currentLocale } = this.props + // const currentLocaleName = global.translator.localeName + // const currentLocale = locales.find(locale => locale.code === currentLocaleName) return h('div.settings__content-row', [ h('div.settings__content-item', [ @@ -126,11 +126,12 @@ class Settings extends Component { h(SimpleDropdown, { placeholder: 'Select Locale', options: getLocaleOptions(), - selectedOption: currentLocaleName, + selectedOption: currentLocale, onSelect: async (newLocale) => { - log('set new locale', newLocale) - await global.translator.setLocale(newLocale) - log('did set new locale', newLocale) + // log('set new locale', newLocale) + // await global.translator.setLocale(newLocale) + updateCurrentLocale(newLocale) + // log('did set new locale', newLocale) }, }), ]), @@ -468,6 +469,7 @@ const mapStateToProps = state => { metamask: state.metamask, warning: state.appState.warning, isMascara: state.metamask.isMascara, + currentLocale: state.metamask.currentLocale, } } @@ -479,6 +481,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/template.js b/ui/app/template.js index d15b30fd2..83228ca77 100644 --- a/ui/app/template.js +++ b/ui/app/template.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)(COMPONENTNAME) diff --git a/ui/app/unlock.js b/ui/app/unlock.js index ac97d04d0..8b58ba1a8 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -1,11 +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 actions = require('./actions') const getCaretCoordinates = require('textarea-caret') const EventEmitter = require('events').EventEmitter -const t = require('../i18n') +const t = require('../i18n-helper').getMessage const { OLD_UI_NETWORK_TYPE } = require('../../app/scripts/config').enums const environmentType = require('../../app/scripts/lib/environment-type') @@ -41,7 +41,7 @@ UnlockScreen.prototype.render = function () { textTransform: 'uppercase', color: '#7F8082', }, - }, t('appName')), + }, t(this.props.localeMessages, 'appName')), h('input.large-input', { type: 'password', diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js new file mode 100644 index 000000000..7ad8cd040 --- /dev/null +++ b/ui/i18n-helper.js @@ -0,0 +1,37 @@ +// cross-browser connection to extension i18n API +const extension = require('extensionizer') +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 entry = locale[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 +} + +async function fetchLocale (localeName) { + const response = await fetch(`/_locales/${localeName}/messages.json`) + const locale = await response.json() + return locale +} + +module.exports = { + getMessage, + fetchLocale, +} diff --git a/ui/index.js b/ui/index.js index fdb2f23e0..c680accfe 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').getMessage const { OLD_UI_NETWORK_TYPE, BETA_UI_NETWORK_TYPE } = require('../app/scripts/config').enums global.log = require('loglevel') @@ -18,14 +19,17 @@ 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.localeMessages, opts) + .then((store) => { + cb(null, store) + }) }) } -function startApp (metamaskState, accountManager, opts) { +async function startApp (metamaskState, accountManager, currentLocaleMessages, opts) { // parse opts if (!metamaskState.featureFlags) metamaskState.featureFlags = {} + const store = configureStore({ // metamaskState represents the cross-tab state @@ -34,6 +38,8 @@ function startApp (metamaskState, accountManager, opts) { // appState represents the current tab's popup state appState: {}, + localeMessages: currentLocaleMessages, + // Which blockchain we are using: networkVersion: opts.networkVersion, }) From a51e8f6a165163b9cc37a4eb5b315cd37af17f77 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 19 Mar 2018 13:36:16 -0230 Subject: [PATCH 05/38] Fetch localeMessages in front end only. --- app/scripts/popup-core.js | 4 ++-- app/scripts/popup.js | 12 +----------- ui/index.js | 8 +++++--- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/scripts/popup-core.js b/app/scripts/popup-core.js index 5af913e98..2e4334bb1 100644 --- a/app/scripts/popup-core.js +++ b/app/scripts/popup-core.js @@ -11,11 +11,11 @@ const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex module.exports = initializePopup -function initializePopup ({ container, connectionStream, localeMessages }, cb) { +function initializePopup ({ container, connectionStream }, cb) { // setup app async.waterfall([ (cb) => connectToAccountManager(connectionStream, cb), - (accountManager, cb) => launchMetamaskUi({ container, accountManager, localeMessages }, cb), + (accountManager, cb) => launchMetamaskUi({ container, accountManager }, cb), ], cb) } diff --git a/app/scripts/popup.js b/app/scripts/popup.js index fe6aae799..5f526759a 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -1,9 +1,3 @@ -// setup i18n -// const Translator = require('../../ui/create-i18n') -// const translator = new Translator() -// global.translator = translator -// global.getMessage = translator.getMessage.bind(translator) - const injectCss = require('inject-css') const OldMetaMaskUiCss = require('../../old-ui/css') const NewMetaMaskUiCss = require('../../ui/css') @@ -28,10 +22,6 @@ async function start() { const release = global.platform.getVersion() setupRaven({ release }) - // Load translator - // await translator.setLocale('ja') - const localeMessages = await fetchLocale('ja') - // inject css // const css = MetaMaskUiCss() // injectCss(css) @@ -47,7 +37,7 @@ async function start() { // start ui const container = document.getElementById('app-content') - startPopup({ container, connectionStream, localeMessages }, (err, store) => { + startPopup({ container, connectionStream }, (err, store) => { if (err) return displayCriticalError(err) // Code commented out until we begin auto adding users to NewUI diff --git a/ui/index.js b/ui/index.js index c680accfe..598d2876b 100644 --- a/ui/index.js +++ b/ui/index.js @@ -4,7 +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').getMessage +const { fetchLocale } = require('./i18n-helper') const { OLD_UI_NETWORK_TYPE, BETA_UI_NETWORK_TYPE } = require('../app/scripts/config').enums global.log = require('loglevel') @@ -19,17 +19,19 @@ function launchMetamaskUi (opts, cb) { // check if we are unlocked first accountManager.getState(function (err, metamaskState) { if (err) return cb(err) - startApp(metamaskState, accountManager, opts.localeMessages, opts) + startApp(metamaskState, accountManager, opts) .then((store) => { cb(null, store) }) }) } -async function startApp (metamaskState, accountManager, currentLocaleMessages, opts) { +async function startApp (metamaskState, accountManager, opts) { // parse opts if (!metamaskState.featureFlags) metamaskState.featureFlags = {} + const currentLocaleMessages = await fetchLocale(metamaskState.currentLocale) + const store = configureStore({ // metamaskState represents the cross-tab state From 3191f2aa5ec4530df6dad6a750d60b797a84bda0 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 19 Mar 2018 13:37:07 -0230 Subject: [PATCH 06/38] Delete old i18n helper files. --- ui/create-i18n.js | 43 ------------------------------------------- ui/i18n.js | 33 --------------------------------- 2 files changed, 76 deletions(-) delete mode 100644 ui/create-i18n.js delete mode 100644 ui/i18n.js diff --git a/ui/create-i18n.js b/ui/create-i18n.js deleted file mode 100644 index c80f5351a..000000000 --- a/ui/create-i18n.js +++ /dev/null @@ -1,43 +0,0 @@ -// cross-browser connection to extension i18n API -const extension = require('extensionizer') -const log = require('loglevel') - - -class Translator { - - async setLocale(localeName) { - this.localeName = localeName - this.locale = await fetchLocale(localeName) - } - - getMessage (key, substitutions) { - // check locale is loaded - if (!this.locale) { - throw new Error('Translator - has not loaded a locale yet') - } - // check entry is present - const entry = this.locale[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 - } - -} - -async function fetchLocale (localeName) { - const response = await fetch(`/_locales/${localeName}/messages.json`) - const locale = await response.json() - return locale -} - -module.exports = Translator 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 From 98f934fb53b0ff66c3de3d11e1ea22b54f956fe6 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 19 Mar 2018 13:38:22 -0230 Subject: [PATCH 07/38] Delete commented out code from i18n implementation that used globals. --- ui/app/settings.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ui/app/settings.js b/ui/app/settings.js index 708d11082..809792f79 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -113,8 +113,6 @@ class Settings extends Component { renderCurrentLocale () { const { updateCurrentLocale, currentLocale } = this.props - // const currentLocaleName = global.translator.localeName - // const currentLocale = locales.find(locale => locale.code === currentLocaleName) return h('div.settings__content-row', [ h('div.settings__content-item', [ @@ -128,10 +126,7 @@ class Settings extends Component { options: getLocaleOptions(), selectedOption: currentLocale, onSelect: async (newLocale) => { - // log('set new locale', newLocale) - // await global.translator.setLocale(newLocale) updateCurrentLocale(newLocale) - // log('did set new locale', newLocale) }, }), ]), From 09260f9c5e0b2c460a214f00b87c8fafe0470419 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 19 Mar 2018 16:23:54 -0230 Subject: [PATCH 08/38] Fixed t() calls where localeMessages is missing; and fix incorrect connect reference. --- ui/app/components/customize-gas-modal/index.js | 6 +++--- ui/app/components/modals/deposit-ether-modal.js | 2 +- ui/app/components/modals/edit-account-name-modal.js | 2 +- ui/app/components/modals/new-account-modal.js | 2 +- ui/app/components/modals/notification-modal.js | 6 +++--- .../modals/notification-modals/confirm-reset-account.js | 2 +- ui/app/components/network.js | 5 ++++- ui/app/components/pending-tx/confirm-deploy-contract.js | 2 +- ui/app/components/pending-tx/confirm-send-ether.js | 2 +- ui/app/components/pending-tx/confirm-send-token.js | 2 +- ui/app/components/pending-tx/index.js | 2 +- ui/app/components/send/gas-tooltip.js | 2 +- ui/app/components/sender-to-recipient.js | 2 +- ui/app/components/shapeshift-form.js | 2 +- ui/app/components/signature-request.js | 4 ++-- ui/app/metamask-connect.js | 6 ++++-- ui/app/settings.js | 2 +- ui/i18n-helper.js | 2 +- 18 files changed, 29 insertions(+), 24 deletions(-) diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js index 8e3960ce4..ed0a3b45e 100644 --- a/ui/app/components/customize-gas-modal/index.js +++ b/ui/app/components/customize-gas-modal/index.js @@ -280,16 +280,16 @@ CustomizeGasModal.prototype.render = function () { h('div.send-v2__customize-gas__revert', { onClick: () => this.revert(), - }, [t('revert')]), + }, [t(this.props.localeMessages, 'revert')]), h('div.send-v2__customize-gas__buttons', [ h('div.send-v2__customize-gas__cancel.allcaps', { onClick: this.props.hideModal, - }, [t('cancel')]), + }, [t(this.props.localeMessages, 'cancel')]), h(`div.send-v2__customize-gas__save${error ? '__error' : ''}.allcaps`, { onClick: () => !error && this.save(gasPrice, gasLimit, gasTotal), - }, [t('save')]), + }, [t(this.props.localeMessages, 'save')]), ]), ]), diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js index 500a225c7..307e89a47 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -123,7 +123,7 @@ DepositEtherModal.prototype.render = function () { h('div.page-container__header', [ - h('div.page-container__title', [t('depositEther')]), + h('div.page-container__title', [t(this.props.localeMessages, 'depositEther')]), h('div.page-container__subtitle', [ t(this.props.localeMessages, 'needEtherInWallet'), diff --git a/ui/app/components/modals/edit-account-name-modal.js b/ui/app/components/modals/edit-account-name-modal.js index 02de5b99c..a64a41b27 100644 --- a/ui/app/components/modals/edit-account-name-modal.js +++ b/ui/app/components/modals/edit-account-name-modal.js @@ -51,7 +51,7 @@ EditAccountNameModal.prototype.render = function () { ]), h('div.edit-account-name-modal-title', { - }, [t('editAccountName')]), + }, [t(this.props.localeMessages, 'editAccountName')]), h('input.edit-account-name-modal-input', { placeholder: identity.name, diff --git a/ui/app/components/modals/new-account-modal.js b/ui/app/components/modals/new-account-modal.js index 7f9b7a154..2744af0b3 100644 --- a/ui/app/components/modals/new-account-modal.js +++ b/ui/app/components/modals/new-account-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') const t = require('../../../i18n-helper').getMessage diff --git a/ui/app/components/modals/notification-modal.js b/ui/app/components/modals/notification-modal.js index c05d80251..ba2c92c92 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') const t = require('../../../i18n-helper').getMessage @@ -23,12 +23,12 @@ class NotificationModal extends Component { }, [ h('div.notification-modal__header', {}, [ - t(header), + t(this.props.localeMessages, header), ]), h('div.notification-modal__message-wrapper', {}, [ h('div.notification-modal__message', {}, [ - t(message), + t(this.props.localeMessages, message), ]), ]), 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/network.js b/ui/app/components/network.js index d3a36b012..25003fd16 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -1,11 +1,12 @@ 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-helper').getMessage -module.exports = Network +module.exports = connect()(Network) inherits(Network, Component) @@ -78,6 +79,8 @@ Network.prototype.render = function () { }, }, [ (function () { + console.log(`12312312312312312 props.localeMessages`, props.localeMessages); + console.log(`12312312312312312 t(props.localeMessages, 'mainnet')`, t(props.localeMessages, 'mainnet')); switch (iconName) { case 'ethereum-network': return h('.network-indicator', [ diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index 340653422..bc93ad2f7 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') diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index be3a9d993..3a72f575f 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 h = require('react-hyperscript') const inherits = require('util').inherits const actions = require('../../actions') diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index fe5c80711..238223321 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 h = require('react-hyperscript') const inherits = require('util').inherits const tokenAbi = require('human-standard-token-abi') diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js index f4f6afb8f..e490a45f4 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/send/gas-tooltip.js b/ui/app/components/send/gas-tooltip.js index 8411fd61b..7bdb164c7 100644 --- a/ui/app/components/send/gas-tooltip.js +++ b/ui/app/components/send/gas-tooltip.js @@ -82,7 +82,7 @@ GasTooltip.prototype.render = function () { 'marginTop': '81px', }, }, [ - h('span.gas-tooltip-label', {}, [t('gasLimit')]), + h('span.gas-tooltip-label', {}, [t(this.props.localeMessages, 'gasLimit')]), h('i.fa.fa-info-circle'), ]), h(InputNumber, { diff --git a/ui/app/components/sender-to-recipient.js b/ui/app/components/sender-to-recipient.js index a0e90a37f..530c4abae 100644 --- a/ui/app/components/sender-to-recipient.js +++ b/ui/app/components/sender-to-recipient.js @@ -30,7 +30,7 @@ class SenderToRecipient extends Component { ]), h('.sender-to-recipient__recipient', [ h('i.fa.fa-file-text-o'), - h('.sender-to-recipient__name.sender-to-recipient__recipient-name', t('newContract')), + h('.sender-to-recipient__name.sender-to-recipient__recipient-name', t(this.props.localeMessages, 'newContract')), ]), ]) ) diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js index 46b16975a..f915135f6 100644 --- a/ui/app/components/shapeshift-form.js +++ b/ui/app/components/shapeshift-form.js @@ -240,7 +240,7 @@ ShapeshiftForm.prototype.render = function () { className: btnClass, disabled: !token, onClick: () => this.onBuyWithShapeShift(), - }, [t('buy')]), + }, [t(this.props.localeMessages, 'buy')]), ]) } diff --git a/ui/app/components/signature-request.js b/ui/app/components/signature-request.js index d6dd424ec..7f4493b66 100644 --- a/ui/app/components/signature-request.js +++ b/ui/app/components/signature-request.js @@ -76,7 +76,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', [t(this.props.localeMessages, 'account') + ':']), h(AccountDropdownMini, { selectedAccount, @@ -103,7 +103,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', [t(this.props.localeMessages, 'balance')]), h('div.request-signature__balance-value', `${balanceInEther} ETH`), diff --git a/ui/app/metamask-connect.js b/ui/app/metamask-connect.js index eef90529b..d13f8e87e 100644 --- a/ui/app/metamask-connect.js +++ b/ui/app/metamask-connect.js @@ -8,8 +8,10 @@ const metamaskConnect = (mapStateToProps, mapDispatchToProps) => { } const _higherOrderMapStateToProps = (mapStateToProps) => { - return (state, ownProps) => { - const stateProps = mapStateToProps(state, ownProps) + return (state, ownProps = {}) => { + const stateProps = mapStateToProps + ? mapStateToProps(state, ownProps) + : ownProps stateProps.localeMessages = state.localeMessages || {} return stateProps } diff --git a/ui/app/settings.js b/ui/app/settings.js index 809792f79..2280b189b 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.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 infuraCurrencies = require('./infura-conversion.json') const validUrl = require('valid-url') diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index 7ad8cd040..345e83f00 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -12,7 +12,7 @@ const getMessage = (locale, key, substitutions) => { const entry = locale[key] if (!entry) { log.error(`Translator - Unable to find value for "${key}"`) - throw new Error(`Translator - Unable to find value for "${key}"`) + // throw new Error(`Translator - Unable to find value for "${key}"`) } let phrase = entry.message // perform substitutions From 2ddc2cc1fbe5249f70d80e2a74146cb87dcc8421 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 19 Mar 2018 16:53:06 -0230 Subject: [PATCH 09/38] Lint fixes. --- app/scripts/popup.js | 1 - ui/app/accounts/import/index.js | 1 + ui/app/accounts/import/json.js | 1 + ui/app/accounts/new-account/create-form.js | 1 + ui/app/actions.js | 1 - ui/app/components/account-dropdowns.js | 2 ++ ui/app/components/dropdowns/components/account-dropdowns.js | 1 + ui/app/components/modals/new-account-modal.js | 1 + ui/app/components/modals/notification-modal.js | 1 + ui/app/components/network.js | 2 -- ui/app/components/pending-tx/confirm-deploy-contract.js | 3 ++- ui/app/components/pending-tx/confirm-send-token.js | 3 ++- ui/app/components/sender-to-recipient.js | 6 +++++- ui/app/reducers/locale.js | 3 --- ui/app/settings.js | 2 ++ ui/i18n-helper.js | 1 - 16 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 5f526759a..6ef0be1ff 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -9,7 +9,6 @@ const ExtensionPlatform = require('./platforms/extension') const NotificationManager = require('./lib/notification-manager') const notificationManager = new NotificationManager() const setupRaven = require('./lib/setupRaven') -const { fetchLocale } = require('../../ui/i18n-helper.js') start().catch(log.error) diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index ab5344dc6..98924b6d9 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.js @@ -2,6 +2,7 @@ const inherits = require('util').inherits const Component = require('react').Component const h = require('react-hyperscript') const connect = require('../../metamask-connect') +const t = require('../../../i18n-helper').getMessage import Select from 'react-select' // Subviews diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js index b3f412e98..f638e07c5 100644 --- a/ui/app/accounts/import/json.js +++ b/ui/app/accounts/import/json.js @@ -113,6 +113,7 @@ JsonImportSubview.propTypes = { goHome: PropTypes.func, displayWarning: PropTypes.func, importNewJsonAccount: PropTypes.func, + localeMessages: PropTypes.object, } const mapStateToProps = state => { diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js index 38cffec64..6eed0215c 100644 --- a/ui/app/accounts/new-account/create-form.js +++ b/ui/app/accounts/new-account/create-form.js @@ -62,6 +62,7 @@ NewAccountCreateForm.propTypes = { createAccount: PropTypes.func, goHome: PropTypes.func, numberOfExistingAccounts: PropTypes.number, + localeMessages: PropTypes.object, } const mapStateToProps = state => { diff --git a/ui/app/actions.js b/ui/app/actions.js index 4749d0735..12cf10411 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -1802,7 +1802,6 @@ function updateCurrentLocale (key) { return (dispatch) => { dispatch(actions.showLoadingIndication()) log.debug(`background.updateCurrentLocale`) - console.log(`fetchLocale`, fetchLocale); fetchLocale(key) .then((localeMessages) => { background.setCurrentLocale(key, (err) => { diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index 1f870a27c..f725e7d86 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -9,6 +9,7 @@ const DropdownMenuItem = require('./dropdown').DropdownMenuItem const Identicon = require('./identicon') const ethUtil = require('ethereumjs-util') const copyToClipboard = require('copy-to-clipboard') +const t = require('../../i18n-helper').getMessage class AccountDropdowns extends Component { constructor (props) { @@ -300,6 +301,7 @@ AccountDropdowns.propTypes = { style: PropTypes.object, enableAccountOptions: PropTypes.bool, enableAccountsSelector: PropTypes.bool, + localeMessages: PropTypes.object, } const mapDispatchToProps = (dispatch) => { diff --git a/ui/app/components/dropdowns/components/account-dropdowns.js b/ui/app/components/dropdowns/components/account-dropdowns.js index 73afb7009..6de4d8280 100644 --- a/ui/app/components/dropdowns/components/account-dropdowns.js +++ b/ui/app/components/dropdowns/components/account-dropdowns.js @@ -426,6 +426,7 @@ AccountDropdowns.propTypes = { enableAccountsSelector: PropTypes.bool, enableAccountOption: PropTypes.bool, enableAccountOptions: PropTypes.bool, + localeMessages: PropTypes.object, } const mapDispatchToProps = (dispatch) => { diff --git a/ui/app/components/modals/new-account-modal.js b/ui/app/components/modals/new-account-modal.js index 2744af0b3..23613ec9c 100644 --- a/ui/app/components/modals/new-account-modal.js +++ b/ui/app/components/modals/new-account-modal.js @@ -70,6 +70,7 @@ NewAccountModal.propTypes = { showImportPage: PropTypes.func, createAccount: PropTypes.func, numberOfExistingAccounts: PropTypes.number, + localeMessages: PropTypes.object, } const mapStateToProps = state => { diff --git a/ui/app/components/modals/notification-modal.js b/ui/app/components/modals/notification-modal.js index ba2c92c92..3898f1c44 100644 --- a/ui/app/components/modals/notification-modal.js +++ b/ui/app/components/modals/notification-modal.js @@ -63,6 +63,7 @@ NotificationModal.propTypes = { showCancelButton: PropTypes.bool, showConfirmButton: PropTypes.bool, onConfirm: PropTypes.func, + localeMessages: PropTypes.object, } const mapDispatchToProps = dispatch => { diff --git a/ui/app/components/network.js b/ui/app/components/network.js index 25003fd16..55bc14c3c 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -79,8 +79,6 @@ Network.prototype.render = function () { }, }, [ (function () { - console.log(`12312312312312312 props.localeMessages`, props.localeMessages); - console.log(`12312312312312312 t(props.localeMessages, 'mainnet')`, t(props.localeMessages, 'mainnet')); switch (iconName) { case 'ethereum-network': return h('.network-indicator', [ diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index bc93ad2f7..8e04fb84d 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -321,6 +321,7 @@ ConfirmDeployContract.propTypes = { conversionRate: PropTypes.number, currentCurrency: PropTypes.string, selectedAddress: PropTypes.string, + localeMessages: PropTypes.object, } const mapStateToProps = state => { @@ -347,4 +348,4 @@ const mapDispatchToProps = dispatch => { } } -module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract) \ No newline at end of file +module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract) diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index 238223321..4cd6f020b 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -378,7 +378,8 @@ ConfirmSendToken.prototype.render = function () { this.renderTotalPlusGas(), - ]) + ]), + ]), h('form#pending-tx-form', { diff --git a/ui/app/components/sender-to-recipient.js b/ui/app/components/sender-to-recipient.js index 530c4abae..02b6d96ea 100644 --- a/ui/app/components/sender-to-recipient.js +++ b/ui/app/components/sender-to-recipient.js @@ -1,5 +1,6 @@ const { Component } = require('react') const h = require('react-hyperscript') +const connect = require('../metamask-connect') const PropTypes = require('prop-types') const t = require('../../i18n-helper').getMessage const Identicon = require('./identicon') @@ -40,6 +41,9 @@ class SenderToRecipient extends Component { SenderToRecipient.propTypes = { senderName: PropTypes.string, senderAddress: PropTypes.string, + localeMessages: PropTypes.object, } -module.exports = SenderToRecipient +module.exports = { + AccountDropdowns: connect()(SenderToRecipient), +} \ No newline at end of file diff --git a/ui/app/reducers/locale.js b/ui/app/reducers/locale.js index d8b78e1dd..edfe9e865 100644 --- a/ui/app/reducers/locale.js +++ b/ui/app/reducers/locale.js @@ -1,8 +1,5 @@ const extend = require('xtend') const actions = require('../actions') -const MetamascaraPlatform = require('../../../app/scripts/platforms/window') -const environmentType = require('../../../app/scripts/lib/environment-type') -const { OLD_UI_NETWORK_TYPE } = require('../../../app/scripts/config').enums module.exports = reduceMetamask diff --git a/ui/app/settings.js b/ui/app/settings.js index 2280b189b..1412606e5 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -457,6 +457,8 @@ Settings.propTypes = { warning: PropTypes.string, goHome: PropTypes.func, isMascara: PropTypes.bool, + updateCurrentLocale: PropTypes.func, + currentLocale: PropTypes.object, } const mapStateToProps = state => { diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index 345e83f00..10147b0f6 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -1,5 +1,4 @@ // cross-browser connection to extension i18n API -const extension = require('extensionizer') const log = require('loglevel') const getMessage = (locale, key, substitutions) => { From d24a0590d363dbe88d383c8faec8eb28809242f0 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 22:11:47 -0230 Subject: [PATCH 10/38] i18n redux solution doesn't require importing t() and passing state to each t() call; t is just available on props. --- app/_locales/en/messages.json | 2 +- app/_locales/es/messages.json | 2 +- app/_locales/it/messages.json | 2 +- app/_locales/pt/messages.json | 2 +- ui/app/accounts/import/index.js | 15 +- ui/app/accounts/import/json.js | 17 +- ui/app/accounts/import/private-key.js | 7 +- ui/app/accounts/import/seed.js | 5 +- ui/app/accounts/new-account/create-form.js | 9 +- ui/app/accounts/new-account/index.js | 7 +- ui/app/add-token.js | 43 ++-- ui/app/app.js | 25 +- ui/app/components/account-dropdowns.js | 15 +- ui/app/components/account-export.js | 15 +- ui/app/components/account-menu/index.js | 15 +- ui/app/components/bn-as-decimal-input.js | 12 +- ui/app/components/buy-button-subview.js | 11 +- ui/app/components/coinbase-form.js | 5 +- ui/app/components/copyButton.js | 6 +- ui/app/components/copyable.js | 6 +- .../components/customize-gas-modal/index.js | 21 +- .../dropdowns/components/account-dropdowns.js | 19 +- .../components/dropdowns/network-dropdown.js | 27 +-- .../dropdowns/token-menu-dropdown.js | 3 +- ui/app/components/ens-input.js | 8 +- ui/app/components/hex-as-decimal-input.js | 12 +- .../modals/account-details-modal.js | 5 +- .../modals/account-modal-container.js | 3 +- ui/app/components/modals/buy-options-modal.js | 15 +- .../components/modals/deposit-ether-modal.js | 29 ++- .../modals/edit-account-name-modal.js | 5 +- .../modals/export-private-key-modal.js | 13 +- .../modals/hide-token-confirmation-modal.js | 9 +- ui/app/components/modals/modal.js | 2 +- ui/app/components/modals/new-account-modal.js | 13 +- .../components/modals/notification-modal.js | 5 +- ui/app/components/network.js | 25 +- ui/app/components/notice.js | 6 +- ui/app/components/pending-msg-details.js | 6 +- ui/app/components/pending-msg.js | 14 +- .../pending-tx/confirm-deploy-contract.js | 25 +- .../pending-tx/confirm-send-ether.js | 19 +- .../pending-tx/confirm-send-token.js | 35 ++- ui/app/components/send/currency-display.js | 2 +- ui/app/components/send/gas-fee-display-v2.js | 8 +- ui/app/components/send/gas-tooltip.js | 6 +- ui/app/components/send/send-v2-container.js | 1 + ui/app/components/send/to-autocomplete.js | 6 +- ui/app/components/sender-to-recipient.js | 3 +- ui/app/components/shapeshift-form.js | 21 +- ui/app/components/shift-list-item.js | 15 +- ui/app/components/signature-request.js | 21 +- ui/app/components/token-list.js | 7 +- ui/app/components/tx-list-item.js | 19 +- ui/app/components/tx-list.js | 7 +- ui/app/components/tx-view.js | 7 +- ui/app/components/wallet-view.js | 9 +- ui/app/first-time/init-menu.js | 19 +- .../keychains/hd/recover-seed/confirmation.js | 7 +- ui/app/keychains/hd/restore-vault.js | 25 +- ui/app/metamask-connect.js | 4 +- ui/app/reducers/locale.js | 4 +- ui/app/send-v2.js | 27 +-- ui/app/settings.js | 75 +++--- ui/app/unlock.js | 9 +- ui/i18n-helper.js | 4 +- ui/index.js | 6 +- yarn.lock | 229 +++++++++++++++++- 68 files changed, 636 insertions(+), 445 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index b309b119d..7f6b9e72d 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -232,7 +232,7 @@ "done": { "message": "Done" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Download State Logs" }, "dropped": { diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index f519c194c..0bef6bebf 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -759,7 +759,7 @@ "stateLogs": { "message": "Logs de estado" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Descargar logs de estados" }, "revealSeedWords": { diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index f54ef98ca..ef3ed4025 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -223,7 +223,7 @@ "done": { "message": "Finito" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Scarica i log di Stato" }, "edit": { diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index c9eb178f9..e770392d0 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -223,7 +223,7 @@ "done": { "message": "Finalizado" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Descarregar Registos de Estado" }, "edit": { diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index 00b1aab8e..75552924b 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.js @@ -2,7 +2,6 @@ const inherits = require('util').inherits const Component = require('react').Component const h = require('react-hyperscript') const connect = require('../../metamask-connect') -const t = require('../../../i18n-helper').getMessage import Select from 'react-select' // Subviews @@ -15,8 +14,8 @@ module.exports = connect(mapStateToProps)(AccountImportSubview) function mapStateToProps (state) { return { menuItems: [ - t(this.props.localeMessages, 'privateKey'), - t(this.props.localeMessages, 'jsonFile'), + this.props.t('privateKey'), + this.props.t('jsonFile'), ], } } @@ -36,7 +35,7 @@ AccountImportSubview.prototype.render = function () { 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', @@ -47,12 +46,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', @@ -85,9 +84,9 @@ AccountImportSubview.prototype.renderImportView = function () { const current = type || menuItems[0] switch (current) { - case t(this.props.localeMessages, 'privateKey'): + case this.props.t('privateKey'): return h(PrivateKeyImportView) - case t(this.props.localeMessages, 'jsonFile'): + case this.props.t('jsonFile'): return h(JsonImportView) default: return h(JsonImportView) diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js index 326e052f2..8bcc1a14e 100644 --- a/ui/app/accounts/import/json.js +++ b/ui/app/accounts/import/json.js @@ -4,7 +4,6 @@ const h = require('react-hyperscript') const connect = require('../../metamask-connect') const actions = require('../../actions') const FileInput = require('react-simple-file-input').default -const t = require('../../../i18n-helper').getMessage const HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts' @@ -25,11 +24,11 @@ class JsonImportSubview extends Component { return ( h('div.new-account-import-form__json', [ - h('p', t(this.props.localeMessages, 'usedByClients')), + h('p', this.props.t('usedByClients')), h('a.warning', { href: HELP_LINK, target: '_blank', - }, t(this.props.localeMessages, 'fileImportFail')), + }, this.props.t('fileImportFail')), h(FileInput, { readAs: 'text', @@ -44,7 +43,7 @@ class JsonImportSubview extends Component { h('input.new-account-import-form__input-password', { type: 'password', - placeholder: t(this.props.localeMessages, 'enterPassword'), + placeholder: this.props.t('enterPassword'), id: 'json-password-box', onKeyPress: this.createKeyringOnEnter.bind(this), }), @@ -54,13 +53,13 @@ class JsonImportSubview extends Component { h('button.new-account-create-form__button-cancel', { onClick: () => this.props.goHome(), }, [ - t(this.props.localeMessages, 'cancel'), + this.props.t('cancel'), ]), h('button.new-account-create-form__button-create', { onClick: () => this.createNewKeychain(), }, [ - t(this.props.localeMessages, 'import'), + this.props.t('import'), ]), ]), @@ -85,14 +84,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(this.props.localeMessages, 'needImportFile') + const message = this.props.t('needImportFile') return this.props.displayWarning(message) } @@ -100,7 +99,7 @@ class JsonImportSubview extends Component { const password = passwordInput.value if (!password) { - const message = t(this.props.localeMessages, 'needImportPassword') + const message = this.props.t('needImportPassword') return this.props.displayWarning(message) } diff --git a/ui/app/accounts/import/private-key.js b/ui/app/accounts/import/private-key.js index 9a23b791a..40114ceca 100644 --- a/ui/app/accounts/import/private-key.js +++ b/ui/app/accounts/import/private-key.js @@ -3,7 +3,6 @@ const Component = require('react').Component const h = require('react-hyperscript') const connect = require('../../metamask-connect') const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView) @@ -34,7 +33,7 @@ PrivateKeyImportView.prototype.render = function () { return ( h('div.new-account-import-form__private-key', [ - h('span.new-account-create-form__instruction', t(this.props.localeMessages, 'pastePrivateKey')), + h('span.new-account-create-form__instruction', this.props.t('pastePrivateKey')), h('div.new-account-import-form__private-key-password-container', [ @@ -51,13 +50,13 @@ PrivateKeyImportView.prototype.render = function () { h('button.new-account-create-form__button-cancel.allcaps', { onClick: () => goHome(), }, [ - t(this.props.localeMessages, 'cancel'), + this.props.t('cancel'), ]), h('button.new-account-create-form__button-create.allcaps', { onClick: () => this.createNewKeychain(), }, [ - t(this.props.localeMessages, 'import'), + this.props.t('import'), ]), ]), diff --git a/ui/app/accounts/import/seed.js b/ui/app/accounts/import/seed.js index d701feedc..5479a6be9 100644 --- a/ui/app/accounts/import/seed.js +++ b/ui/app/accounts/import/seed.js @@ -2,7 +2,6 @@ const inherits = require('util').inherits const Component = require('react').Component const h = require('react-hyperscript') const connect = require('../../metamask-connect') -const t = require('../../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(SeedImportSubview) @@ -21,10 +20,10 @@ SeedImportSubview.prototype.render = function () { style: { }, }, [ - t(this.props.localeMessages, 'pasteSeed'), + this.props.t('pasteSeed'), h('textarea'), h('br'), - h('button', t(this.props.localeMessages, 'submit')), + h('button', this.props.t('submit')), ]) ) } diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js index 6eed0215c..b0e109cd7 100644 --- a/ui/app/accounts/new-account/create-form.js +++ b/ui/app/accounts/new-account/create-form.js @@ -3,7 +3,6 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const connect = require('../../metamask-connect') const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage class NewAccountCreateForm extends Component { constructor (props) { @@ -14,7 +13,7 @@ class NewAccountCreateForm extends Component { this.state = { newAccountName: '', - defaultAccountName: t(this.props.localeMessages, 'newAccountNumberName', [newAccountNumber]), + defaultAccountName: this.props.t('newAccountNumberName', [newAccountNumber]), } } @@ -25,7 +24,7 @@ class NewAccountCreateForm extends Component { return h('div.new-account-create-form', [ h('div.new-account-create-form__input-label', {}, [ - t(this.props.localeMessages, 'accountName'), + this.props.t('accountName'), ]), h('div.new-account-create-form__input-wrapper', {}, [ @@ -41,13 +40,13 @@ class NewAccountCreateForm extends Component { h('button.new-account-create-form__button-cancel.allcaps', { onClick: () => this.props.goHome(), }, [ - t(this.props.localeMessages, 'cancel'), + this.props.t('cancel'), ]), h('button.new-account-create-form__button-create.allcaps', { onClick: () => this.props.createAccount(newAccountName || defaultAccountName), }, [ - t(this.props.localeMessages, 'create'), + this.props.t('create'), ]), ]), diff --git a/ui/app/accounts/new-account/index.js b/ui/app/accounts/new-account/index.js index 8c305bfae..584016974 100644 --- a/ui/app/accounts/new-account/index.js +++ b/ui/app/accounts/new-account/index.js @@ -3,7 +3,6 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('../../metamask-connect') const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage 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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'import')), + }, this.props.t('import')), ]), diff --git a/ui/app/add-token.js b/ui/app/add-token.js index 9576a7aef..b4846510e 100644 --- a/ui/app/add-token.js +++ b/ui/app/add-token.js @@ -26,7 +26,6 @@ const fuse = new Fuse(contractList, { const actions = require('./actions') const ethUtil = require('ethereumjs-util') const { tokenInfoGetter } = require('./token-util') -const t = require('../i18n') const emptyAddr = '0x0000000000000000000000000000000000000000' @@ -140,28 +139,28 @@ 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 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 +168,7 @@ AddTokenScreen.prototype.validate = function () { isEmpty && !isSelected ), true) ) { - errors.tokenSelector = t('mustSelectOne') + errors.tokenSelector = this.props.t('mustSelectOne') } return { @@ -199,7 +198,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 +211,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 +225,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, @@ -300,11 +299,11 @@ 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__title', t('addToken')), - h('div.add-token__description', t('likeToAddTokens')), + h('div.add-token__title', this.props.t('addToken')), + 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 ]) => ( @@ -323,10 +322,10 @@ AddTokenScreen.prototype.renderConfirmation = function () { h('div.add-token__buttons', [ h('button.btn-cancel.add-token__button', { onClick: () => this.setState({ isShowingConfirmation: false }), - }, t('back')), + }, this.props.t('back')), h('button.btn-clear.add-token__button', { onClick: () => addTokens(tokens).then(goHome), - }, t('addTokens')), + }, this.props.t('addTokens')), ]), ]) ) @@ -342,15 +341,15 @@ AddTokenScreen.prototype.render = function () { h('div.add-token', [ h('div.add-token__wrapper', [ h('div.add-token__title-container', [ - h('div.add-token__title', t('addToken')), - h('div.add-token__description', t('tokenWarning1')), - h('div.add-token__description', t('tokenSelection')), + h('div.add-token__title', this.props.t('addToken')), + h('div.add-token__description', this.props.t('tokenWarning1')), + h('div.add-token__description', this.props.t('tokenSelection')), ]), h('div.add-token__content-container', [ h('div.add-token__input-container', [ h('input.add-token__input', { type: 'text', - placeholder: t('search'), + placeholder: this.props.t('search'), onChange: e => this.setState({ searchQuery: e.target.value }), }), h('div.add-token__search-input-error-message', errors.tokenSelector), @@ -364,7 +363,7 @@ AddTokenScreen.prototype.render = function () { h('div.add-token__add-custom', { onClick: () => this.setState({ isCollapsed: !isCollapsed }), }, [ - t('addCustomToken'), + this.props.t('addCustomToken'), h(`i.fa.fa-angle-${isCollapsed ? 'down' : 'up'}`), ]), this.renderCustomForm(), @@ -373,10 +372,10 @@ AddTokenScreen.prototype.render = function () { h('div.add-token__buttons', [ h('button.btn-cancel.add-token__button', { onClick: goHome, - }, t('cancel')), + }, this.props.t('cancel')), h('button.btn-clear.add-token__button', { onClick: this.onNext, - }, t('next')), + }, this.props.t('next')), ]), ]) ) diff --git a/ui/app/app.js b/ui/app/app.js index f69efd1c7..91d5af899 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -4,7 +4,6 @@ const connect = require('./metamask-connect') const h = require('react-hyperscript') const actions = require('./actions') const classnames = require('classnames') -const t = require('../i18n-helper').getMessage // mascara const MascaraFirstTime = require('../../mascara/src/app/first-time').default @@ -294,8 +293,8 @@ App.prototype.renderAppBar = function () { // metamask name h('.flex-row', [ - h('h1', t(this.props.localeMessages, 'appName')), - h('div.beta-label', t(this.props.localeMessages, 'beta')), + h('h1', this.props.t('appName')), + h('div.beta-label', this.props.t('beta')), ]), ]), @@ -557,15 +556,15 @@ App.prototype.getConnectingLabel = function () { 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 @@ -578,15 +577,15 @@ App.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/account-dropdowns.js b/ui/app/components/account-dropdowns.js index f725e7d86..88c7dbb60 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -9,7 +9,6 @@ const DropdownMenuItem = require('./dropdown').DropdownMenuItem const Identicon = require('./identicon') const ethUtil = require('ethereumjs-util') const copyToClipboard = require('copy-to-clipboard') -const t = require('../../i18n-helper').getMessage 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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'importAccount')), + }, this.props.t('importAccount')), ] ), ] @@ -193,7 +192,7 @@ class AccountDropdowns extends Component { global.platform.openWindow({ url }) }, }, - t(this.props.localeMessages, 'etherscanView'), + this.props.t('etherscanView'), ), h( DropdownMenuItem, @@ -205,7 +204,7 @@ class AccountDropdowns extends Component { actions.showQrView(selected, identity ? identity.name : '') }, }, - t(this.props.localeMessages, 'showQRCode'), + this.props.t('showQRCode'), ), h( DropdownMenuItem, @@ -217,7 +216,7 @@ class AccountDropdowns extends Component { copyToClipboard(checkSumAddress) }, }, - t(this.props.localeMessages, 'copyAddress'), + this.props.t('copyAddress'), ), h( DropdownMenuItem, @@ -227,7 +226,7 @@ class AccountDropdowns extends Component { actions.requestAccountExport() }, }, - t(this.props.localeMessages, 'exportPrivateKey'), + this.props.t('exportPrivateKey'), ), ] ) diff --git a/ui/app/components/account-export.js b/ui/app/components/account-export.js index 3bb7ec337..8889f88a7 100644 --- a/ui/app/components/account-export.js +++ b/ui/app/components/account-export.js @@ -6,7 +6,6 @@ const copyToClipboard = require('copy-to-clipboard') const actions = require('../actions') const ethUtil = require('ethereumjs-util') const connect = require('../metamask-connect') -const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(ExportAccountView) @@ -36,7 +35,7 @@ ExportAccountView.prototype.render = function () { if (notExporting) return h('div') if (exportRequested) { - const warning = t(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'submit')), + }, this.props.t('submit')), h('button', { onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)), - }, t(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'done')), + }, this.props.t('done')), h('button', { style: { marginLeft: '10px', }, onClick: () => exportAsFile(`MetaMask ${nickname} Private Key`, plainKey), - }, t(this.props.localeMessages, 'saveAsFile')), + }, this.props.t('saveAsFile')), ]) } } diff --git a/ui/app/components/account-menu/index.js b/ui/app/components/account-menu/index.js index dc9c36c40..a9120f9db 100644 --- a/ui/app/components/account-menu/index.js +++ b/ui/app/components/account-menu/index.js @@ -6,7 +6,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-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountMenu) @@ -71,10 +70,10 @@ AccountMenu.prototype.render = function () { h(Item, { className: 'account-menu__header', }, [ - t(this.props.localeMessages, 'myAccounts'), + this.props.t('myAccounts'), h('button.account-menu__logout-button', { onClick: lockMetamask, - }, t(this.props.localeMessages, 'logout')), + }, this.props.t('logout')), ]), h(Divider), h('div.account-menu__accounts', this.renderAccounts()), @@ -82,23 +81,23 @@ AccountMenu.prototype.render = function () { h(Item, { onClick: () => showNewAccountPage('CREATE'), icon: h('img.account-menu__item-icon', { src: 'images/plus-btn-white.svg' }), - text: t(this.props.localeMessages, 'createAccount'), + text: this.props.t('createAccount'), }), h(Item, { onClick: () => showNewAccountPage('IMPORT'), icon: h('img.account-menu__item-icon', { src: 'images/import-account.svg' }), - text: t(this.props.localeMessages, 'importAccount'), + text: this.props.t('importAccount'), }), h(Divider), h(Item, { onClick: showInfoPage, icon: h('img', { src: 'images/mm-info-icon.svg' }), - text: t(this.props.localeMessages, 'infoHelp'), + text: this.props.t('infoHelp'), }), h(Item, { onClick: showConfigPage, icon: h('img.account-menu__item-icon', { src: 'images/settings.svg' }), - text: t(this.props.localeMessages, 'settings'), + text: this.props.t('settings'), }), ]) } @@ -156,6 +155,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(this.props.localeMessages, 'imported')) : null + return isLoose ? h('.keyring-label.allcaps', this.props.t('imported')) : null } catch (e) { return } } diff --git a/ui/app/components/bn-as-decimal-input.js b/ui/app/components/bn-as-decimal-input.js index 5b83b4332..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-helper').getMessage +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(this.props.localeMessages, 'betweenMinAndMax', [`${newMin} ${suffix}`, `${newMax} ${suffix}`]) + message += this.props.t('betweenMinAndMax', [`${newMin} ${suffix}`, `${newMax} ${suffix}`]) } else if (min) { - message += t(this.props.localeMessages, 'greaterThanMin', [`${newMin} ${suffix}`]) + message += this.props.t('greaterThanMin', [`${newMin} ${suffix}`]) } else if (max) { - message += t(this.props.localeMessages, 'lessThanMax', [`${newMax} ${suffix}`]) + message += this.props.t('lessThanMax', [`${newMax} ${suffix}`]) } else { - message += t(this.props.localeMessages, '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 b2b8cbbd5..2243ce38b 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -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-helper.js').getMessage module.exports = connect(mapStateToProps)(BuyButtonSubview) @@ -77,7 +76,7 @@ BuyButtonSubview.prototype.headerSubview = function () { paddingTop: '4px', paddingBottom: '4px', }, - }, t(this.props.localeMessages, 'depositEth')), + }, this.props.t('depositEth')), ]), // loading indication @@ -119,7 +118,7 @@ BuyButtonSubview.prototype.headerSubview = function () { paddingTop: '4px', paddingBottom: '4px', }, - }, t(this.props.localeMessages, 'selectService')), + }, this.props.t('selectService')), ]), ]) @@ -165,14 +164,14 @@ BuyButtonSubview.prototype.primarySubview = function () { style: { marginTop: '15px', }, - }, t(this.props.localeMessages, 'borrowDharma')) + }, this.props.t('borrowDharma')) ) : null, ]) ) default: return ( - h('h2.error', t(this.props.localeMessages, 'unknownNetworkId')) + h('h2.error', this.props.t('unknownNetworkId')) ) } @@ -205,7 +204,7 @@ BuyButtonSubview.prototype.mainnetSubview = function () { ], subtext: { 'Coinbase': `${t('crypto')}/${t('fiat')} (${t('usaOnly')})`, - 'ShapeShift': t(this.props.localeMessages, 'crypto'), + '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 be413905e..0f980fbd5 100644 --- a/ui/app/components/coinbase-form.js +++ b/ui/app/components/coinbase-form.js @@ -3,7 +3,6 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('../metamask-connect') const actions = require('../actions') -const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(CoinbaseForm) @@ -38,11 +37,11 @@ CoinbaseForm.prototype.render = function () { }, [ h('button.btn-green', { onClick: this.toCoinbase.bind(this), - }, t(this.props.localeMessages, 'continueToCoinbase')), + }, this.props.t('continueToCoinbase')), h('button.btn-red', { onClick: () => props.dispatch(actions.goHome()), - }, t(this.props.localeMessages, 'cancel')), + }, this.props.t('cancel')), ]), ]) } diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js index db43668cb..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-helper').getMessage +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(this.props.localeMessages, 'copiedButton') : props.title || t(this.props.localeMessages, '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 92a337a37..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-helper').getMessage +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(this.props.localeMessages, 'copiedExclamation') : t(this.props.localeMessages, '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 e44675880..1ea64de27 100644 --- a/ui/app/components/customize-gas-modal/index.js +++ b/ui/app/components/customize-gas-modal/index.js @@ -4,7 +4,6 @@ const inherits = require('util').inherits const connect = require('../../metamask-connect') const actions = require('../../actions') const GasModalCard = require('./gas-modal-card') -const t = require('../../../i18n-helper').getMessage const ethUtil = require('ethereumjs-util') @@ -150,7 +149,7 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { }) if (!balanceIsSufficient) { - error = t(this.props.localeMessages, 'balanceIsInsufficientGas') + error = this.props.t('balanceIsInsufficientGas') } const gasLimitTooLow = gasLimit && conversionGreaterThan( @@ -166,7 +165,7 @@ CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { ) if (gasLimitTooLow) { - error = t(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'gasPrice'), - copy: t(this.props.localeMessages, '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(this.props.localeMessages, 'gasLimit'), - copy: t(this.props.localeMessages, 'gasLimitCalculation'), + title: this.props.t('gasLimit'), + copy: this.props.t('gasLimitCalculation'), }), ]), @@ -299,16 +298,16 @@ CustomizeGasModal.prototype.render = function () { h('div.send-v2__customize-gas__revert', { onClick: () => this.revert(), - }, [t(this.props.localeMessages, 'revert')]), + }, [this.props.t('revert')]), h('div.send-v2__customize-gas__buttons', [ h('div.send-v2__customize-gas__cancel.allcaps', { onClick: this.props.hideModal, - }, [t(this.props.localeMessages, 'cancel')]), + }, [this.props.t('cancel')]), h(`div.send-v2__customize-gas__save${error ? '__error' : ''}.allcaps`, { onClick: () => !error && this.save(newGasPrice, gasLimit, gasTotal), - }, [t(this.props.localeMessages, '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 6de4d8280..d570b3d36 100644 --- a/ui/app/components/dropdowns/components/account-dropdowns.js +++ b/ui/app/components/dropdowns/components/account-dropdowns.js @@ -10,7 +10,6 @@ const Identicon = require('../../identicon') const ethUtil = require('ethereumjs-util') const copyToClipboard = require('copy-to-clipboard') const { formatBalance } = require('../../../util') -const t = require('../../../../i18n-helper').getMessage class AccountDropdowns extends Component { @@ -131,7 +130,7 @@ class AccountDropdowns extends Component { actions.showEditAccountModal(identity) }, }, [ - t(this.props.localeMessages, 'edit'), + this.props.t('edit'), ]), ]), @@ -145,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(this.props.localeMessages, 'loose')) : null + return isLoose ? h('.keyring-label.allcaps', this.props.t('loose')) : null } catch (e) { return } } @@ -203,7 +202,7 @@ class AccountDropdowns extends Component { fontSize: '16px', lineHeight: '23px', }, - }, t(this.props.localeMessages, 'createAccount')), + }, this.props.t('createAccount')), ], ), h( @@ -237,7 +236,7 @@ class AccountDropdowns extends Component { fontSize: '16px', lineHeight: '23px', }, - }, t(this.props.localeMessages, 'importAccount')), + }, this.props.t('importAccount')), ] ), ] @@ -288,7 +287,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t(this.props.localeMessages, 'accountDetails'), + this.props.t('accountDetails'), ), h( DropdownMenuItem, @@ -304,7 +303,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t(this.props.localeMessages, 'etherscanView'), + this.props.t('etherscanView'), ), h( DropdownMenuItem, @@ -320,7 +319,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t(this.props.localeMessages, 'copyAddress'), + this.props.t('copyAddress'), ), h( DropdownMenuItem, @@ -332,7 +331,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t(this.props.localeMessages, 'exportPrivateKey'), + this.props.t('exportPrivateKey'), ), h( DropdownMenuItem, @@ -347,7 +346,7 @@ class AccountDropdowns extends Component { menuItemStyles, ), }, - t(this.props.localeMessages, 'addToken'), + this.props.t('addToken'), ), ] diff --git a/ui/app/components/dropdowns/network-dropdown.js b/ui/app/components/dropdowns/network-dropdown.js index 61c574aed..aac7a9ee5 100644 --- a/ui/app/components/dropdowns/network-dropdown.js +++ b/ui/app/components/dropdowns/network-dropdown.js @@ -7,7 +7,6 @@ const Dropdown = require('./components/dropdown').Dropdown const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem const NetworkDropdownIcon = require('./components/network-dropdown-icon') const R = require('ramda') -const t = require('../../../i18n-helper').getMessage // classes from nodes of the toggle element. @@ -95,13 +94,13 @@ NetworkDropdown.prototype.render = function () { }, [ h('div.network-dropdown-header', {}, [ - h('div.network-dropdown-title', {}, t(this.props.localeMessages, 'networks')), + h('div.network-dropdown-title', {}, this.props.t('networks')), h('div.network-dropdown-divider'), h('div.network-dropdown-content', {}, - t(this.props.localeMessages, 'defaultNetwork') + this.props.t('defaultNetwork') ), ]), @@ -123,7 +122,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'mainnet' ? '#ffffff' : '#9b9b9b', }, - }, t(this.props.localeMessages, 'mainnet')), + }, this.props.t('mainnet')), ] ), @@ -145,7 +144,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'ropsten' ? '#ffffff' : '#9b9b9b', }, - }, t(this.props.localeMessages, 'ropsten')), + }, this.props.t('ropsten')), ] ), @@ -167,7 +166,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'kovan' ? '#ffffff' : '#9b9b9b', }, - }, t(this.props.localeMessages, 'kovan')), + }, this.props.t('kovan')), ] ), @@ -189,7 +188,7 @@ NetworkDropdown.prototype.render = function () { style: { color: providerType === 'rinkeby' ? '#ffffff' : '#9b9b9b', }, - }, t(this.props.localeMessages, 'rinkeby')), + }, this.props.t('rinkeby')), ] ), @@ -211,7 +210,7 @@ NetworkDropdown.prototype.render = function () { style: { color: activeNetwork === 'http://localhost:8545' ? '#ffffff' : '#9b9b9b', }, - }, t(this.props.localeMessages, 'localhost')), + }, this.props.t('localhost')), ] ), @@ -235,7 +234,7 @@ NetworkDropdown.prototype.render = function () { style: { color: activeNetwork === 'custom' ? '#ffffff' : '#9b9b9b', }, - }, t(this.props.localeMessages, 'customRPC')), + }, this.props.t('customRPC')), ] ), @@ -250,15 +249,15 @@ NetworkDropdown.prototype.getNetworkName = function () { let name if (providerName === 'mainnet') { - name = t(this.props.localeMessages, 'mainnet') + name = this.props.t('mainnet') } else if (providerName === 'ropsten') { - name = t(this.props.localeMessages, 'ropsten') + name = this.props.t('ropsten') } else if (providerName === 'kovan') { - name = t(this.props.localeMessages, 'kovan') + name = this.props.t('kovan') } else if (providerName === 'rinkeby') { - name = t(this.props.localeMessages, 'rinkeby') + name = this.props.t('rinkeby') } else { - name = t(this.props.localeMessages, '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 403d17591..630e1f99d 100644 --- a/ui/app/components/dropdowns/token-menu-dropdown.js +++ b/ui/app/components/dropdowns/token-menu-dropdown.js @@ -3,7 +3,6 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const connect = require('../../metamask-connect') const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown) @@ -45,7 +44,7 @@ TokenMenuDropdown.prototype.render = function () { showHideTokenConfirmationModal(this.props.token) this.props.onClose() }, - }, t(this.props.localeMessages, 'hideToken')), + }, this.props.t('hideToken')), ]), ]), diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index ea26acbca..e731286bb 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -8,10 +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-helper').getMessage +const connect = require('../metamask-connect') -module.exports = EnsInput +module.exports = connect()(EnsInput) inherits(EnsInput, Component) function EnsInput () { @@ -90,13 +90,13 @@ EnsInput.prototype.lookupEnsName = function () { log.info(`ENS attempting to resolve name: ${recipient}`) this.ens.lookup(recipient.trim()) .then((address) => { - if (address === ZERO_ADDRESS) throw new Error(t(this.props.localeMessages, '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(this.props.localeMessages, '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 7e53ba2f0..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-helper').getMessage +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(this.props.localeMessages, 'betweenMinAndMax', [min, max]) + message += this.props.t('betweenMinAndMax', [min, max]) } else if (min) { - message += t(this.props.localeMessages, 'greaterThanMin', [min]) + message += this.props.t('greaterThanMin', [min]) } else if (max) { - message += t(this.props.localeMessages, 'lessThanMax', [max]) + message += this.props.t('lessThanMax', [max]) } else { - message += t(this.props.localeMessages, 'invalidInput') + message += this.props.t('invalidInput') } return message diff --git a/ui/app/components/modals/account-details-modal.js b/ui/app/components/modals/account-details-modal.js index e4f2009aa..24d856b43 100644 --- a/ui/app/components/modals/account-details-modal.js +++ b/ui/app/components/modals/account-details-modal.js @@ -8,7 +8,6 @@ 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-helper').getMessage function mapStateToProps (state) { return { @@ -65,12 +64,12 @@ AccountDetailsModal.prototype.render = function () { h('button.btn-clear.account-modal__button', { onClick: () => global.platform.openWindow({ url: genAccountLink(address, network) }), - }, t(this.props.localeMessages, 'etherscanView')), + }, this.props.t('etherscanView')), // Holding on redesign for Export Private Key functionality h('button.btn-clear.account-modal__button', { onClick: () => showExportPrivateKeyModal(), - }, t(this.props.localeMessages, '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 ac6457b37..70efe16cb 100644 --- a/ui/app/components/modals/account-modal-container.js +++ b/ui/app/components/modals/account-modal-container.js @@ -5,7 +5,6 @@ const connect = require('../../metamask-connect') const actions = require('../../actions') const { getSelectedIdentity } = require('../../selectors') const Identicon = require('../identicon') -const t = require('../../../i18n-helper').getMessage 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(this.props.localeMessages, '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 0e93e9a2d..c0ee3632e 100644 --- a/ui/app/components/modals/buy-options-modal.js +++ b/ui/app/components/modals/buy-options-modal.js @@ -4,7 +4,6 @@ const inherits = require('util').inherits const connect = require('../../metamask-connect') const actions = require('../../actions') const networkNames = require('../../../../app/scripts/config.js').networkNames -const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -57,15 +56,15 @@ BuyOptions.prototype.render = function () { }, [ h('div.buy-modal-content-title', { style: {}, - }, t(this.props.localeMessages, 'transfers')), - h('div', {}, t(this.props.localeMessages, '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(this.props.localeMessages, 'testFaucet'), () => toFaucet(network)) - : this.renderModalContentOption('Coinbase', t(this.props.localeMessages, '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(this.props.localeMessages, 'directDeposit'), - t(this.props.localeMessages, '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(this.props.localeMessages, '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 307e89a47..0b097d546 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -5,7 +5,6 @@ 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-helper').getMessage let DIRECT_DEPOSIT_ROW_TITLE let DIRECT_DEPOSIT_ROW_TEXT @@ -16,7 +15,7 @@ let SHAPESHIFT_ROW_TEXT let FAUCET_ROW_TITLE const facuetRowText = (networkName) => { - return t(this.props.localeMessages, 'getEtherFromFaucet', [networkName]) + return this.props.t('getEtherFromFaucet', [networkName]) } function mapStateToProps (state) { @@ -49,13 +48,13 @@ function DepositEtherModal () { Component.call(this) // need to set after i18n locale has loaded - DIRECT_DEPOSIT_ROW_TITLE = t(this.props.localeMessages, 'directDepositEther') - DIRECT_DEPOSIT_ROW_TEXT = t(this.props.localeMessages, 'directDepositEtherExplainer') - COINBASE_ROW_TITLE = t(this.props.localeMessages, 'buyCoinbase') - COINBASE_ROW_TEXT = t(this.props.localeMessages, 'buyCoinbaseExplainer') - SHAPESHIFT_ROW_TITLE = t(this.props.localeMessages, 'depositShapeShift') - SHAPESHIFT_ROW_TEXT = t(this.props.localeMessages, 'depositShapeShiftExplainer') - FAUCET_ROW_TITLE = t(this.props.localeMessages, 'testFaucet') + DIRECT_DEPOSIT_ROW_TITLE = this.props.t('directDepositEther') + DIRECT_DEPOSIT_ROW_TEXT = this.props.t('directDepositEtherExplainer') + COINBASE_ROW_TITLE = this.props.t('buyCoinbase') + COINBASE_ROW_TEXT = this.props.t('buyCoinbaseExplainer') + SHAPESHIFT_ROW_TITLE = this.props.t('depositShapeShift') + SHAPESHIFT_ROW_TEXT = this.props.t('depositShapeShiftExplainer') + FAUCET_ROW_TITLE = this.props.t('testFaucet') this.state = { buyingWithShapeshift: false, @@ -123,10 +122,10 @@ DepositEtherModal.prototype.render = function () { h('div.page-container__header', [ - h('div.page-container__title', [t(this.props.localeMessages, 'depositEther')]), + h('div.page-container__title', [this.props.t('depositEther')]), h('div.page-container__subtitle', [ - t(this.props.localeMessages, 'needEtherInWallet'), + this.props.t('needEtherInWallet'), ]), h('div.page-container__header-close', { @@ -149,7 +148,7 @@ DepositEtherModal.prototype.render = function () { }), title: DIRECT_DEPOSIT_ROW_TITLE, text: DIRECT_DEPOSIT_ROW_TEXT, - buttonLabel: t(this.props.localeMessages, 'viewAccount'), + buttonLabel: this.props.t('viewAccount'), onButtonClick: () => this.goToAccountDetailsModal(), hide: buyingWithShapeshift, }), @@ -158,7 +157,7 @@ DepositEtherModal.prototype.render = function () { logo: h('i.fa.fa-tint.fa-2x'), title: FAUCET_ROW_TITLE, text: facuetRowText(networkName), - buttonLabel: t(this.props.localeMessages, 'getEther'), + buttonLabel: this.props.t('getEther'), onButtonClick: () => toFaucet(network), hide: !isTestNetwork || buyingWithShapeshift, }), @@ -172,7 +171,7 @@ DepositEtherModal.prototype.render = function () { }), title: COINBASE_ROW_TITLE, text: COINBASE_ROW_TEXT, - buttonLabel: t(this.props.localeMessages, 'continueToCoinbase'), + buttonLabel: this.props.t('continueToCoinbase'), onButtonClick: () => toCoinbase(address), hide: isTestNetwork || buyingWithShapeshift, }), @@ -185,7 +184,7 @@ DepositEtherModal.prototype.render = function () { }), title: SHAPESHIFT_ROW_TITLE, text: SHAPESHIFT_ROW_TEXT, - buttonLabel: t(this.props.localeMessages, '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 a64a41b27..4f5bc001a 100644 --- a/ui/app/components/modals/edit-account-name-modal.js +++ b/ui/app/components/modals/edit-account-name-modal.js @@ -4,7 +4,6 @@ const inherits = require('util').inherits const connect = require('../../metamask-connect') const actions = require('../../actions') const { getSelectedAccount } = require('../../selectors') -const t = require('../../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -51,7 +50,7 @@ EditAccountNameModal.prototype.render = function () { ]), h('div.edit-account-name-modal-title', { - }, [t(this.props.localeMessages, '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(this.props.localeMessages, '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 fac5366a4..b92d250fa 100644 --- a/ui/app/components/modals/export-private-key-modal.js +++ b/ui/app/components/modals/export-private-key-modal.js @@ -7,7 +7,6 @@ const actions = require('../../actions') const AccountModalContainer = require('./account-modal-container') const { getSelectedIdentity } = require('../../selectors') const ReadOnlyInput = require('../readonly-input') -const t = require('../../../i18n-helper').getMessage 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(this.props.localeMessages, 'copyPrivateKey') - : t(this.props.localeMessages, 'typePassword') + ? this.props.t('copyPrivateKey') + : this.props.t('typePassword') ) } @@ -87,8 +86,8 @@ ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password, ), (privateKey - ? this.renderButton('btn-clear export-private-key__button', () => hideModal(), t(this.props.localeMessages, 'done')) - : this.renderButton('btn-clear export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), t(this.props.localeMessages, 'confirm')) + ? this.renderButton('btn-clear export-private-key__button', () => hideModal(), this.props.t('done')) + : this.renderButton('btn-clear 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(this.props.localeMessages, '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(this.props.localeMessages, '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 a6cf2889f..5207b4c95 100644 --- a/ui/app/components/modals/hide-token-confirmation-modal.js +++ b/ui/app/components/modals/hide-token-confirmation-modal.js @@ -4,7 +4,6 @@ const inherits = require('util').inherits const connect = require('../../metamask-connect') const actions = require('../../actions') const Identicon = require('../identicon') -const t = require('../../../i18n-helper').getMessage 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(this.props.localeMessages, '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(this.props.localeMessages, 'readdToken'), + this.props.t('readdToken'), ]), h('div.hide-token-confirmation__buttons', {}, [ h('button.btn-cancel.hide-token-confirmation__button.allcaps', { onClick: () => hideModal(), }, [ - t(this.props.localeMessages, 'cancel'), + this.props.t('cancel'), ]), h('button.btn-clear.hide-token-confirmation__button.allcaps', { onClick: () => hideToken(address), }, [ - t(this.props.localeMessages, 'hide'), + this.props.t('hide'), ]), ]), ]), diff --git a/ui/app/components/modals/modal.js b/ui/app/components/modals/modal.js index d0f4b486c..9250cc77e 100644 --- a/ui/app/components/modals/modal.js +++ b/ui/app/components/modals/modal.js @@ -1,7 +1,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits -const connect = require('../../metamask-connect') +const connect = require('react-redux').connect const FadeModal = require('boron').FadeModal const actions = require('../../actions') const isMobileView = require('../../../lib/is-mobile-view') diff --git a/ui/app/components/modals/new-account-modal.js b/ui/app/components/modals/new-account-modal.js index 23613ec9c..c46980855 100644 --- a/ui/app/components/modals/new-account-modal.js +++ b/ui/app/components/modals/new-account-modal.js @@ -3,7 +3,6 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const connect = require('../../metamask-connect') const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage class NewAccountModal extends Component { constructor (props) { @@ -23,7 +22,7 @@ class NewAccountModal extends Component { h('div.new-account-modal-wrapper', { }, [ h('div.new-account-modal-header', {}, [ - t(this.props.localeMessages, '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(this.props.localeMessages, 'accountName'), + this.props.t('accountName'), ]), h('div.new-account-input-wrapper', {}, [ h('input.new-account-input', { value: this.state.newAccountName, - placeholder: t(this.props.localeMessages, 'sampleAccountName'), + placeholder: this.props.t('sampleAccountName'), onChange: event => this.setState({ newAccountName: event.target.value }), }, []), ]), h('div.new-account-modal-content.after-input', {}, [ - t(this.props.localeMessages, '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(this.props.localeMessages, 'importAnAccount')), + }, this.props.t('importAnAccount')), h('div.new-account-modal-content.button.allcaps', {}, [ h('button.btn-clear', { onClick: () => this.props.createAccount(newAccountName), }, [ - t(this.props.localeMessages, 'save'), + this.props.t('save'), ]), ]), ]), diff --git a/ui/app/components/modals/notification-modal.js b/ui/app/components/modals/notification-modal.js index 3898f1c44..3c4ab5194 100644 --- a/ui/app/components/modals/notification-modal.js +++ b/ui/app/components/modals/notification-modal.js @@ -3,7 +3,6 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const connect = require('../../metamask-connect') const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage class NotificationModal extends Component { render () { @@ -23,12 +22,12 @@ class NotificationModal extends Component { }, [ h('div.notification-modal__header', {}, [ - t(this.props.localeMessages, header), + this.props.t(header), ]), h('div.notification-modal__message-wrapper', {}, [ h('div.notification-modal__message', {}, [ - t(this.props.localeMessages, message), + this.props.t(message), ]), ]), diff --git a/ui/app/components/network.js b/ui/app/components/network.js index 55bc14c3c..10961390e 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -4,7 +4,6 @@ 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-helper').getMessage module.exports = connect()(Network) @@ -35,7 +34,7 @@ Network.prototype.render = function () { onClick: (event) => this.props.onClick(event), }, [ h('img', { - title: t(props.localeMessages, 'attemptingConnect'), + title: props.t('attemptingConnect'), style: { width: '27px', }, @@ -43,22 +42,22 @@ Network.prototype.render = function () { }), ]) } else if (providerName === 'mainnet') { - hoverText = t(props.localeMessages, 'mainnet') + hoverText = props.t('mainnet') iconName = 'ethereum-network' } else if (providerName === 'ropsten') { - hoverText = t(props.localeMessages, 'ropsten') + hoverText = props.t('ropsten') iconName = 'ropsten-test-network' } else if (parseInt(networkNumber) === 3) { - hoverText = t(props.localeMessages, 'ropsten') + hoverText = props.t('ropsten') iconName = 'ropsten-test-network' } else if (providerName === 'kovan') { - hoverText = t(props.localeMessages, 'kovan') + hoverText = props.t('kovan') iconName = 'kovan-test-network' } else if (providerName === 'rinkeby') { - hoverText = t(props.localeMessages, 'rinkeby') + hoverText = props.t('rinkeby') iconName = 'rinkeby-test-network' } else { - hoverText = t(props.localeMessages, 'unknownNetwork') + hoverText = props.t('unknownNetwork') iconName = 'unknown-private-network' } @@ -86,7 +85,7 @@ Network.prototype.render = function () { backgroundColor: '#038789', // $blue-lagoon nonSelectBackgroundColor: '#15afb2', }), - h('.network-name', t(props.localeMessages, 'mainnet')), + h('.network-name', props.t('mainnet')), h('i.fa.fa-chevron-down.fa-lg.network-caret'), ]) case 'ropsten-test-network': @@ -95,7 +94,7 @@ Network.prototype.render = function () { backgroundColor: '#e91550', // $crimson nonSelectBackgroundColor: '#ec2c50', }), - h('.network-name', t(props.localeMessages, 'ropsten')), + h('.network-name', props.t('ropsten')), h('i.fa.fa-chevron-down.fa-lg.network-caret'), ]) case 'kovan-test-network': @@ -104,7 +103,7 @@ Network.prototype.render = function () { backgroundColor: '#690496', // $purple nonSelectBackgroundColor: '#b039f3', }), - h('.network-name', t(props.localeMessages, 'kovan')), + h('.network-name', props.t('kovan')), h('i.fa.fa-chevron-down.fa-lg.network-caret'), ]) case 'rinkeby-test-network': @@ -113,7 +112,7 @@ Network.prototype.render = function () { backgroundColor: '#ebb33f', // $tulip-tree nonSelectBackgroundColor: '#ecb23e', }), - h('.network-name', t(props.localeMessages, 'rinkeby')), + h('.network-name', props.t('rinkeby')), h('i.fa.fa-chevron-down.fa-lg.network-caret'), ]) default: @@ -125,7 +124,7 @@ Network.prototype.render = function () { }, }), - h('.network-name', t(props.localeMessages, '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 ffc5ec6f1..a999ffd88 100644 --- a/ui/app/components/notice.js +++ b/ui/app/components/notice.js @@ -4,9 +4,9 @@ const h = require('react-hyperscript') const ReactMarkdown = require('react-markdown') const linker = require('extension-link-enabler') const findDOMNode = require('react-dom').findDOMNode -const t = require('../../i18n-helper').getMessage +const connect = require('../metamask-connect') -module.exports = Notice +module.exports = connect()(Notice) inherits(Notice, Component) function Notice () { @@ -111,7 +111,7 @@ Notice.prototype.render = function () { style: { marginTop: '18px', }, - }, t(this.props.localeMessages, 'accept')), + }, this.props.t('accept')), ]) ) } diff --git a/ui/app/components/pending-msg-details.js b/ui/app/components/pending-msg-details.js index 8edf21b48..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-helper').getMessage +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(this.props.localeMessages, '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 2364353be..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-helper').getMessage +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(this.props.localeMessages, 'signMessage')), + }, this.props.t('signMessage')), h('.error', { style: { margin: '10px', }, }, [ - t(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'cancel')), + }, this.props.t('cancel')), h('button', { onClick: state.signMessage, - }, t(this.props.localeMessages, '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 8e04fb84d..6b912af7f 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -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-helper').getMessage const SenderToRecipient = require('../sender-to-recipient') const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') @@ -177,7 +176,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(this.props.localeMessages, '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()}`), @@ -216,8 +215,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(this.props.localeMessages, 'total') + ' ' ]), - h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, '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', [ @@ -246,9 +245,9 @@ class ConfirmDeployContract extends Component { h('.page-container__header', [ h('.page-container__back-button', { onClick: () => backToAccountDetail(selectedAddress), - }, t(this.props.localeMessages, 'back')), - h('.page-container__title', t(this.props.localeMessages, 'confirmContract')), - h('.page-container__subtitle', t(this.props.localeMessages, 'pleaseReviewTransaction')), + }, this.props.t('back')), + h('.page-container__title', this.props.t('confirmContract')), + h('.page-container__subtitle', this.props.t('pleaseReviewTransaction')), ]), // Main Send token Card h('.page-container__content', [ @@ -271,7 +270,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(this.props.localeMessages, '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)}`), @@ -279,9 +278,9 @@ class ConfirmDeployContract extends Component { ]), h('section.flex-row.flex-center.confirm-screen-row', [ - h('span.confirm-screen-label.confirm-screen-section-column', [ t(this.props.localeMessages, '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(this.props.localeMessages, 'newContract')), + h('div.confirm-screen-row-info', this.props.t('newContract')), ]), ]), @@ -299,12 +298,12 @@ class ConfirmDeployContract extends Component { // Cancel Button h('button.btn-cancel.page-container__footer-button.allcaps', { onClick: event => this.cancel(event, txMeta), - }, t(this.props.localeMessages, 'cancel')), + }, this.props.t('cancel')), // Accept Button h('button.btn-confirm.page-container__footer-button.allcaps', { onClick: event => this.onSubmit(event), - }, t(this.props.localeMessages, 'confirm')), + }, this.props.t('confirm')), ]), ]), ]) @@ -344,7 +343,7 @@ const mapDispatchToProps = dispatch => { return { backToAccountDetail: address => dispatch(actions.backToAccountDetail(address)), cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })), - displayWarning: warning => actions.displayWarning(t(this.props.localeMessages, warning)), + displayWarning: warning => actions.displayWarning(this.props.t(warning)), } } diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index 253b69b7a..02394b0c5 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -14,7 +14,6 @@ const { multiplyCurrencies, } = require('../../conversion-util') const GasFeeDisplay = require('../send/gas-fee-display-v2') -const t = require('../../../i18n-helper').getMessage const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') @@ -196,7 +195,7 @@ ConfirmSendEther.prototype.getData = function () { }, to: { address: txParams.to, - name: identities[txParams.to] ? identities[txParams.to].name : t(this.props.localeMessages, 'newRecipient'), + name: identities[txParams.to] ? identities[txParams.to].name : this.props.t('newRecipient'), }, memo: txParams.memo || '', gasFeeInFIAT, @@ -311,7 +310,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(this.props.localeMessages, '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)}`), @@ -319,7 +318,7 @@ ConfirmSendEther.prototype.render = function () { ]), h('section.flex-row.flex-center.confirm-screen-row', [ - h('span.confirm-screen-label.confirm-screen-section-column', [ t(this.props.localeMessages, '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)}`), @@ -327,7 +326,7 @@ ConfirmSendEther.prototype.render = function () { ]), h('section.flex-row.flex-center.confirm-screen-row', [ - h('span.confirm-screen-label.confirm-screen-section-column', [ t(this.props.localeMessages, '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, @@ -340,8 +339,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(this.props.localeMessages, 'total') + ' ' ]), - h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, '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', [ @@ -442,10 +441,10 @@ ConfirmSendEther.prototype.render = function () { clearSend() this.cancel(event, txMeta) }, - }, t(this.props.localeMessages, 'cancel')), + }, this.props.t('cancel')), // Accept Button - h('button.btn-confirm.page-container__footer-button.allcaps', [t(this.props.localeMessages, 'confirm')]), + h('button.btn-confirm.page-container__footer-button.allcaps', [this.props.t('confirm')]), ]), ]), ]), @@ -462,7 +461,7 @@ ConfirmSendEther.prototype.onSubmit = function (event) { if (valid && this.verifyGasParams()) { this.props.sendTransaction(txMeta, event) } else { - this.props.dispatch(actions.displayWarning(t(this.props.localeMessages, '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 54963ae9a..d53f8b32f 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -6,7 +6,6 @@ const tokenAbi = require('human-standard-token-abi') const abiDecoder = require('abi-decoder') abiDecoder.addABI(tokenAbi) const actions = require('../../actions') -const t = require('../../../i18n-helper').getMessage const clone = require('clone') const Identicon = require('../identicon') const GasFeeDisplay = require('../send/gas-fee-display-v2.js') @@ -22,7 +21,7 @@ const { } = require('../../token-util') const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') - +// const { getTokenExchangeRate, getSelectedAddress, @@ -168,7 +167,7 @@ ConfirmSendToken.prototype.getAmount = function () { ? +(sendTokenAmount * tokenExchangeRate * conversionRate).toFixed(2) : null, token: typeof value === 'undefined' - ? t(this.props.localeMessages, 'unknown') + ? this.props.t('unknown') : +sendTokenAmount.toFixed(decimals), } @@ -240,7 +239,7 @@ ConfirmSendToken.prototype.getData = function () { }, to: { address: value, - name: identities[value] ? identities[value].name : t(this.props.localeMessages, 'newRecipient'), + name: identities[value] ? identities[value].name : this.props.t('newRecipient'), }, memo: txParams.memo || '', } @@ -286,7 +285,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(this.props.localeMessages, '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, @@ -308,8 +307,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(this.props.localeMessages, 'total') + ' ' ]), - h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, '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', [ @@ -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(this.props.localeMessages, 'total') + ' ' ]), - h('div.confirm-screen-total-box__subtitle', [ t(this.props.localeMessages, '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', [ @@ -350,10 +349,10 @@ ConfirmSendToken.prototype.render = function () { this.inputs = [] const isTxReprice = Boolean(txMeta.lastGasPrice) - const title = isTxReprice ? t(this.props.localeMessages, 'reprice:title') : t(this.props.localeMessages, 'confirm') + const title = isTxReprice ? this.props.t('reprice:title') : this.props.t('confirm') const subtitle = isTxReprice - ? t(this.props.localeMessages, 'reprice:subtitle') - : t(this.props.localeMessages, 'pleaseReviewTransaction') + ? this.props.t('reprice:subtitle') + : this.props.t('pleaseReviewTransaction') return ( h('div.confirm-screen-container.confirm-send-token', [ @@ -362,7 +361,7 @@ ConfirmSendToken.prototype.render = function () { h('div.page-container__header', [ !txMeta.lastGasPrice && h('button.confirm-screen-back-button', { onClick: () => editTransaction(txMeta), - }, t(this.props.localeMessages, 'edit')), + }, this.props.t('edit')), h('div.page-container__title', title), h('div.page-container__subtitle', subtitle), ]), @@ -406,7 +405,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(this.props.localeMessages, '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)}`), @@ -414,7 +413,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(this.props.localeMessages, '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)}`), @@ -436,10 +435,10 @@ ConfirmSendToken.prototype.render = function () { // Cancel Button h('button.btn-cancel.page-container__footer-button.allcaps', { onClick: (event) => this.cancel(event, txMeta), - }, t(this.props.localeMessages, 'cancel')), + }, this.props.t('cancel')), // Accept Button - h('button.btn-confirm.page-container__footer-button.allcaps', [t(this.props.localeMessages, 'confirm')]), + h('button.btn-confirm.page-container__footer-button.allcaps', [this.props.t('confirm')]), ]), ]), ]), @@ -456,7 +455,7 @@ ConfirmSendToken.prototype.onSubmit = function (event) { if (valid && this.verifyGasParams()) { this.props.sendTransaction(txMeta, event) } else { - this.props.dispatch(actions.displayWarning(t(this.props.localeMessages, 'invalidGasParams'))) + this.props.dispatch(actions.displayWarning(this.props.t('invalidGasParams'))) this.setState({ submitting: false }) } } diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js index 819fee0a0..a0aaada4d 100644 --- a/ui/app/components/send/currency-display.js +++ b/ui/app/components/send/currency-display.js @@ -10,7 +10,7 @@ inherits(CurrencyDisplay, Component) function CurrencyDisplay () { Component.call(this) } - +// function toHexWei (value) { return conversionUtil(value, { fromNumericBase: 'dec', diff --git a/ui/app/components/send/gas-fee-display-v2.js b/ui/app/components/send/gas-fee-display-v2.js index 04a43df2f..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-helper').getMessage +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', t(this.props.localeMessages, 'setGasPrice')) - : h('div.currency-display', t(this.props.localeMessages, '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 7bdb164c7..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-helper').getMessage +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(this.props.localeMessages, '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 25902cfce..d90a6bf75 100644 --- a/ui/app/components/send/send-v2-container.js +++ b/ui/app/components/send/send-v2-container.js @@ -53,6 +53,7 @@ function mapStateToProps (state) { tokenContract: getSelectedTokenContract(state), unapprovedTxs: state.metamask.unapprovedTxs, network: state.metamask.network, + t: t.bind(null, state.localeMessages), } } diff --git a/ui/app/components/send/to-autocomplete.js b/ui/app/components/send/to-autocomplete.js index ca034d855..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-helper').getMessage +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(this.props.localeMessages, '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 02b6d96ea..dc72dc303 100644 --- a/ui/app/components/sender-to-recipient.js +++ b/ui/app/components/sender-to-recipient.js @@ -2,7 +2,6 @@ const { Component } = require('react') const h = require('react-hyperscript') const connect = require('../metamask-connect') const PropTypes = require('prop-types') -const t = require('../../i18n-helper').getMessage const Identicon = require('./identicon') class SenderToRecipient extends Component { @@ -31,7 +30,7 @@ class SenderToRecipient extends Component { ]), h('.sender-to-recipient__recipient', [ h('i.fa.fa-file-text-o'), - h('.sender-to-recipient__name.sender-to-recipient__recipient-name', t(this.props.localeMessages, 'newContract')), + h('.sender-to-recipient__name.sender-to-recipient__recipient-name', this.props.t('newContract')), ]), ]) ) diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js index f915135f6..31af74b36 100644 --- a/ui/app/components/shapeshift-form.js +++ b/ui/app/components/shapeshift-form.js @@ -7,7 +7,6 @@ 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-helper').getMessage function mapStateToProps (state) { const { @@ -94,7 +93,7 @@ ShapeshiftForm.prototype.onBuyWithShapeShift = function () { })) .catch(() => this.setState({ showQrCode: false, - errorMessage: t(this.props.localeMessages, '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(this.props.localeMessages, 'status'), limit ? t(this.props.localeMessages, 'available') : t(this.props.localeMessages, 'unavailable')), - this.renderMetadata(t(this.props.localeMessages, 'limit'), limit), - this.renderMetadata(t(this.props.localeMessages, 'exchangeRate'), rate), - this.renderMetadata(t(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'buy')]), + }, [this.props.t('buy')]), ]) } diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js index cc401bc34..d810eddc9 100644 --- a/ui/app/components/shift-list-item.js +++ b/ui/app/components/shift-list-item.js @@ -6,7 +6,6 @@ const vreme = new (require('vreme'))() const explorerLink = require('etherscan-link').createExplorerLink const actions = require('../actions') const addressSummary = require('../util').addressSummary -const t = require('../../i18n-helper').getMessage 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(this.props.localeMessages, '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(this.props.localeMessages, 'toETHviaShapeShift', [props.depositType])), - h('div', t(this.props.localeMessages, '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(this.props.localeMessages, 'toETHviaShapeShift', [props.depositType])), - h('div', t(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, '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 7f4493b66..a1ed049f7 100644 --- a/ui/app/components/signature-request.js +++ b/ui/app/components/signature-request.js @@ -9,7 +9,6 @@ const classnames = require('classnames') const AccountDropdownMini = require('./dropdowns/account-dropdown-mini') const actions = require('../actions') -const t = require('../../i18n-helper').getMessage 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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, '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(this.props.localeMessages, 'yourSigRequested'), + this.props.t('yourSigRequested'), ]), ]) @@ -155,18 +154,18 @@ SignatureRequest.prototype.msgHexToText = function (hex) { SignatureRequest.prototype.renderBody = function () { let rows - let notice = t(this.props.localeMessages, 'youSign') + ':' + let notice = this.props.t('youSign') + ':' const { txData } = this.props const { type, msgParams: { data } } = txData if (type === 'personal_sign') { - rows = [{ name: t(this.props.localeMessages, '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(this.props.localeMessages, 'message'), value: data }] - notice = t(this.props.localeMessages, '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.request-signature__footer__cancel-button', { onClick: cancel, - }, t(this.props.localeMessages, 'cancel')), + }, this.props.t('cancel')), h('button.request-signature__footer__sign-button', { onClick: sign, - }, t(this.props.localeMessages, 'sign')), + }, this.props.t('sign')), ]) } diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js index 439619158..ae22f3702 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -5,7 +5,6 @@ const TokenTracker = require('eth-token-tracker') const TokenCell = require('./token-cell.js') const connect = require('../metamask-connect') const selectors = require('../selectors') -const t = require('../../i18n-helper').getMessage function mapStateToProps (state) { return { @@ -43,7 +42,7 @@ TokenList.prototype.render = function () { const { tokens, isLoading, error } = state if (isLoading) { - return this.message(t(this.props.localeMessages, 'loadingTokens')) + return this.message(this.props.t('loadingTokens')) } if (error) { @@ -53,7 +52,7 @@ TokenList.prototype.render = function () { padding: '80px', }, }, [ - t(this.props.localeMessages, '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(this.props.localeMessages, 'here')), + }, this.props.t('here')), ]) } diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 3819de195..5e88d38d3 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -14,7 +14,6 @@ const { conversionUtil, multiplyCurrencies } = require('../conversion-util') const { calcTokenAmount } = require('../token-util') const { getCurrentCurrency } = require('../selectors') -const t = require('../../i18n-helper').getMessage 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(this.props.localeMessages, '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 d8c882ae2..7c2da30fe 100644 --- a/ui/app/components/tx-list.js +++ b/ui/app/components/tx-list.js @@ -10,7 +10,6 @@ const { formatDate } = require('../util') const { showConfTxPage } = require('../actions') const classnames = require('classnames') const { tokenInfoGetter } = require('../token-util') -const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(TxList) @@ -40,7 +39,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', {}, [ @@ -57,7 +56,7 @@ TxList.prototype.renderTransaction = function () { : [h( 'div.tx-list-item.tx-list-item--empty', { key: 'tx-list-none' }, - [ t(this.props.localeMessages, 'noTransactions') ], + [ this.props.t('noTransactions') ], )] } @@ -111,7 +110,7 @@ TxList.prototype.renderTransactionListItem = function (transaction, conversionRa if (isUnapproved) { opts.onClick = () => showConfTxPage({ id: transactionId }) - opts.transactionStatus = t(this.props.localeMessages, 'Not Started') + opts.transactionStatus = this.props.t('Not Started') } 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 f7ca9cc97..81aee4308 100644 --- a/ui/app/components/tx-view.js +++ b/ui/app/components/tx-view.js @@ -5,7 +5,6 @@ const ethUtil = require('ethereumjs-util') const inherits = require('util').inherits const actions = require('../actions') const selectors = require('../selectors') -const t = require('../../i18n-helper').getMessage const BalanceComponent = require('./balance-component') const TxList = require('./tx-list') @@ -73,21 +72,21 @@ TxView.prototype.renderButtons = function () { onClick: () => showModal({ name: 'DEPOSIT_ETHER', }), - }, t(this.props.localeMessages, 'deposit')), + }, this.props.t('deposit')), h('button.btn-clear.hero-balance-button.allcaps', { style: { marginLeft: '0.8em', }, onClick: showSendPage, - }, t(this.props.localeMessages, 'send')), + }, this.props.t('send')), ]) ) : ( h('div.flex-row.flex-center.hero-balance-buttons', [ h('button.btn-clear.hero-balance-button', { onClick: showSendTokenPage, - }, t(this.props.localeMessages, 'send')), + }, this.props.t('send')), ]) ) } diff --git a/ui/app/components/wallet-view.js b/ui/app/components/wallet-view.js index 54770e436..c42fedf9a 100644 --- a/ui/app/components/wallet-view.js +++ b/ui/app/components/wallet-view.js @@ -11,7 +11,6 @@ const actions = require('../actions') const BalanceComponent = require('./balance-component') const TokenList = require('./token-list') const selectors = require('../selectors') -const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(WalletView) @@ -117,7 +116,7 @@ WalletView.prototype.render = function () { onClick: hideSidebar, }), - h('div.wallet-view__keyring-label.allcaps', isLoose ? t(this.props.localeMessages, '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' }, @@ -134,13 +133,13 @@ WalletView.prototype.render = function () { selectedIdentity.name, ]), - h('button.btn-clear.wallet-view__details-button.allcaps', t(this.props.localeMessages, 'details')), + h('button.btn-clear.wallet-view__details-button.allcaps', this.props.t('details')), ]), ]), h(Tooltip, { position: 'bottom', - title: this.state.hasCopied ? t(this.props.localeMessages, 'copiedExclamation') : t(this.props.localeMessages, 'copyToClipboard'), + title: this.state.hasCopied ? this.props.t('copiedExclamation') : this.props.t('copyToClipboard'), wrapperClassName: 'wallet-view__tooltip', }, [ h('button.wallet-view__address', { @@ -173,7 +172,7 @@ WalletView.prototype.render = function () { showAddTokenPage() hideSidebar() }, - }, t(this.props.localeMessages, 'addToken')), + }, this.props.t('addToken')), ]) } diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js index 797718498..c0c2d3ed0 100644 --- a/ui/app/first-time/init-menu.js +++ b/ui/app/first-time/init-menu.js @@ -6,7 +6,6 @@ const h = require('react-hyperscript') const Mascot = require('../components/mascot') const actions = require('../actions') const Tooltip = require('../components/tooltip') -const t = require('../../i18n-helper').getMessage const getCaretCoordinates = require('textarea-caret') const environmentType = require('../../../app/scripts/lib/environment-type') const { OLD_UI_NETWORK_TYPE } = require('../../../app/scripts/config').enums @@ -60,7 +59,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { color: '#7F8082', marginBottom: 10, }, - }, t(this.props.localeMessages, 'appName')), + }, this.props.t('appName')), h('div', [ @@ -70,10 +69,10 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { color: '#7F8082', display: 'inline', }, - }, t(this.props.localeMessages, 'encryptNewDen')), + }, this.props.t('encryptNewDen')), h(Tooltip, { - title: t(this.props.localeMessages, 'denExplainer'), + title: this.props.t('denExplainer'), }, [ h('i.fa.fa-question-circle.pointer', { style: { @@ -93,7 +92,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { h('input.large-input.letter-spacey', { type: 'password', id: 'password-box', - placeholder: t(this.props.localeMessages, 'newPassword'), + placeholder: this.props.t('newPassword'), onInput: this.inputChanged.bind(this), style: { width: 260, @@ -105,7 +104,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { h('input.large-input.letter-spacey', { type: 'password', id: 'password-box-confirm', - placeholder: t(this.props.localeMessages, 'confirmPassword'), + placeholder: this.props.t('confirmPassword'), onKeyPress: this.createVaultOnEnter.bind(this), onInput: this.inputChanged.bind(this), style: { @@ -120,7 +119,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { style: { margin: 12, }, - }, t(this.props.localeMessages, 'createDen')), + }, this.props.t('createDen')), h('.flex-row.flex-center.flex-grow', [ h('p.pointer', { @@ -130,7 +129,7 @@ InitializeMenuScreen.prototype.renderMenu = function (state) { color: 'rgb(247, 134, 28)', textDecoration: 'underline', }, - }, t(this.props.localeMessages, 'importDen')), + }, this.props.t('importDen')), ]), h('.flex-row.flex-center.flex-grow', [ @@ -179,12 +178,12 @@ InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () { var passwordConfirm = passwordConfirmBox.value if (password.length < 8) { - this.warning = t(this.props.localeMessages, 'passwordShort') + this.warning = this.props.t('passwordShort') this.props.dispatch(actions.displayWarning(this.warning)) return } if (password !== passwordConfirm) { - this.warning = t(this.props.localeMessages, 'passwordMismatch') + this.warning = this.props.t('passwordMismatch') this.props.dispatch(actions.displayWarning(this.warning)) return } diff --git a/ui/app/keychains/hd/recover-seed/confirmation.js b/ui/app/keychains/hd/recover-seed/confirmation.js index 4a62c8803..f97ac66fe 100644 --- a/ui/app/keychains/hd/recover-seed/confirmation.js +++ b/ui/app/keychains/hd/recover-seed/confirmation.js @@ -4,7 +4,6 @@ const Component = require('react').Component 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 164cf28dc..f47a2641a 100644 --- a/ui/app/keychains/hd/restore-vault.js +++ b/ui/app/keychains/hd/restore-vault.js @@ -2,7 +2,6 @@ const inherits = require('util').inherits const PersistentForm = require('../../../lib/persistent-form') 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 index d13f8e87e..38fc05930 100644 --- a/ui/app/metamask-connect.js +++ b/ui/app/metamask-connect.js @@ -1,4 +1,5 @@ const connect = require('react-redux').connect +const t = require('../i18n-helper').getMessage const metamaskConnect = (mapStateToProps, mapDispatchToProps) => { return connect( @@ -12,7 +13,8 @@ const _higherOrderMapStateToProps = (mapStateToProps) => { const stateProps = mapStateToProps ? mapStateToProps(state, ownProps) : ownProps - stateProps.localeMessages = state.localeMessages || {} + console.log(`state.localeMessages`, state.localeMessages); + stateProps.t = t.bind(null, state.localeMessages) return stateProps } } diff --git a/ui/app/reducers/locale.js b/ui/app/reducers/locale.js index edfe9e865..bdd97acb4 100644 --- a/ui/app/reducers/locale.js +++ b/ui/app/reducers/locale.js @@ -8,7 +8,9 @@ function reduceMetamask (state, action) { switch (action.type) { case actions.SET_LOCALE_MESSAGES: - return action.value + return extend(localeMessagesState, { + current: action.value, + }) default: return localeMessagesState } diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 31118378d..49947a11c 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') @@ -189,9 +188,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: () => { @@ -262,11 +261,11 @@ SendTransactionScreen.prototype.handleToChange = function (to) { 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) @@ -282,9 +281,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')), ]), @@ -382,11 +381,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 }) @@ -416,7 +415,7 @@ SendTransactionScreen.prototype.renderAmountRow = function () { setMaxModeTo(true) this.setAmountToMax() }, - }, [ !maxModeOn ? t('max') : '' ]), + }, [ !maxModeOn ? this.props.t('max') : '' ]), ]), h('div.send-v2__form-field', [ @@ -514,11 +513,11 @@ SendTransactionScreen.prototype.renderFooter = function () { clearSend() goHome() }, - }, t('cancel')), + }, this.props.t('cancel')), h('button.btn-clear.page-container__footer-button', { disabled: !noErrors || !gasTotal || missingTokenBalance, onClick: event => this.onSubmit(event), - }, t('next')), + }, this.props.t('next')), ]) } diff --git a/ui/app/settings.js b/ui/app/settings.js index f75b1e8b4..d3525e9c0 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -10,7 +10,6 @@ const TabBar = require('./components/tab-bar') const SimpleDropdown = require('./components/dropdowns/simple-dropdown') const ToggleButton = require('react-toggle-button') const { OLD_UI_NETWORK_TYPE } = require('../../app/scripts/config').enums -const t = require('../i18n') const getInfuraCurrencyOptions = () => { const sortedCurrencies = infuraCurrencies.objects.sort((a, b) => { @@ -62,8 +61,8 @@ class Settings extends Component { return h('div.settings__tabs', [ h(TabBar, { tabs: [ - { content: t('settings'), key: 'settings' }, - { content: t('info'), key: 'info' }, + { content: this.props.t('settings'), key: 'settings' }, + { content: this.props.t('info'), key: 'info' }, ], defaultTab: activeTab, tabSelected: key => this.setState({ activeTab: key }), @@ -76,7 +75,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', [ @@ -96,13 +95,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), @@ -142,31 +141,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 } @@ -187,12 +186,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') { @@ -205,7 +204,7 @@ class Settings extends Component { event.preventDefault() this.validateRpc(this.state.newRpc) }, - }, t('save')), + }, this.props.t('save')), ]), ]), ]) @@ -221,9 +220,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')) } } } @@ -232,10 +231,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', [ @@ -244,13 +243,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')), ]), ]), ]) @@ -262,7 +261,7 @@ 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.settings__clear-button.settings__clear-button--red', { @@ -270,7 +269,7 @@ class Settings extends Component { event.preventDefault() revealSeedConfirmation() }, - }, t('revealSeedWords')), + }, this.props.t('revealSeedWords')), ]), ]), ]) @@ -282,7 +281,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.settings__clear-button.settings__clear-button--orange', { @@ -290,7 +289,7 @@ class Settings extends Component { event.preventDefault() setFeatureFlagToBeta() }, - }, t('useOldUI')), + }, this.props.t('useOldUI')), ]), ]), ]) @@ -301,7 +300,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.settings__clear-button.settings__clear-button--orange', { @@ -309,7 +308,7 @@ class Settings extends Component { event.preventDefault() showResetAccountConfirmationModal() }, - }, t('resetAccount')), + }, this.props.t('resetAccount')), ]), ]), ]) @@ -345,13 +344,13 @@ class Settings 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', [ @@ -359,7 +358,7 @@ class Settings 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', [ @@ -367,7 +366,7 @@ class Settings 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'), @@ -376,7 +375,7 @@ class Settings 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', [ @@ -384,7 +383,7 @@ class Settings 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', [ @@ -392,7 +391,7 @@ class Settings 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')), ]), ]), ]) @@ -414,7 +413,7 @@ class Settings extends Component { h('div.settings__info-item', [ h( 'div.settings__info-about', - t('builtInCalifornia') + this.props.t('builtInCalifornia') ), ]), ]), diff --git a/ui/app/unlock.js b/ui/app/unlock.js index 423e76e10..e8e1ba051 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -5,7 +5,6 @@ const connect = require('./metamask-connect') const actions = require('./actions') const getCaretCoordinates = require('textarea-caret') const EventEmitter = require('events').EventEmitter -const t = require('../i18n-helper').getMessage 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(this.props.localeMessages, '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 index 10147b0f6..70555f239 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -2,13 +2,15 @@ const log = require('loglevel') const getMessage = (locale, key, substitutions) => { + console.log(`locale, key, substitutions`, 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 entry = locale[key] + 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}"`) diff --git a/ui/index.js b/ui/index.js index 598d2876b..fe57f791a 100644 --- a/ui/index.js +++ b/ui/index.js @@ -31,6 +31,7 @@ async function startApp (metamaskState, accountManager, opts) { if (!metamaskState.featureFlags) metamaskState.featureFlags = {} const currentLocaleMessages = await fetchLocale(metamaskState.currentLocale) + const enLocaleMessages = await fetchLocale('en') const store = configureStore({ @@ -40,7 +41,10 @@ async function startApp (metamaskState, accountManager, opts) { // appState represents the current tab's popup state appState: {}, - localeMessages: currentLocaleMessages, + localeMessages: { + current: currentLocaleMessages, + en: enLocaleMessages, + }, // Which blockchain we are using: networkVersion: opts.networkVersion, diff --git a/yarn.lock b/yarn.lock index 7512e10db..c1b9bef83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -253,6 +253,10 @@ ansi-colors@^1.0.1: dependencies: ansi-wrap "^0.1.0" +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + ansi-escapes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" @@ -299,6 +303,10 @@ ansi-wrap@0.1.0, ansi-wrap@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" +ansi@^0.3.0, ansi@~0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/ansi/-/ansi-0.3.1.tgz#0c42d4fb17160d5a9af1e484bace1c66922c1b21" + ansicolors@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" @@ -1611,7 +1619,7 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^3.0.5, bluebird@^3.1.1, bluebird@^3.3.0, bluebird@^3.4.6, bluebird@^3.5.0: +bluebird@^3.0.5, bluebird@^3.1.1, bluebird@^3.3.0, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.0: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -2021,6 +2029,10 @@ buffer-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" +buffer-from@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531" + buffer-more-ints@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz#26b3885d10fa13db7fc01aae3aab870199e0124c" @@ -2155,6 +2167,22 @@ caniuse-lite@^1.0.30000810, caniuse-lite@^1.0.30000813: version "1.0.30000814" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000814.tgz#73eb6925ac2e54d495218f1ea0007da3940e488b" +caporal@^0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/caporal/-/caporal-0.10.0.tgz#2ddfbe5ede26d2bd356f042f564ff57803cdabc9" + dependencies: + bluebird "^3.4.7" + chalk "^1.1.3" + cli-table2 "^0.2.0" + fast-levenshtein "^2.0.6" + lodash.camelcase "^4.3.0" + lodash.kebabcase "^4.1.1" + lodash.merge "^4.6.0" + micromist "^1.0.1" + prettyjson "^1.2.1" + tabtab "^2.2.2" + winston "^2.3.1" + caseless@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" @@ -2353,12 +2381,27 @@ classnames@^2.2.4, classnames@^2.2.5: version "2.2.5" resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d" +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" + dependencies: + restore-cursor "^1.0.1" + cli-cursor@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: restore-cursor "^2.0.0" +cli-table2@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/cli-table2/-/cli-table2-0.2.0.tgz#2d1ef7f218a0e786e214540562d4bd177fe32d97" + dependencies: + lodash "^3.10.1" + string-width "^1.0.1" + optionalDependencies: + colors "^1.1.2" + cli-width@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" @@ -2635,6 +2678,15 @@ concat-stream@^1.4.3, concat-stream@^1.4.6, concat-stream@^1.5.0, concat-stream@ readable-stream "^2.2.2" typedarray "^0.0.6" +concat-stream@^1.4.7: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + concat-stream@~1.5.0, concat-stream@~1.5.1: version "1.5.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" @@ -3677,6 +3729,14 @@ es-abstract@^1.5.0, es-abstract@^1.6.1, es-abstract@^1.7.0: is-callable "^1.1.3" is-regex "^1.0.4" +es-check@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es-check/-/es-check-2.0.3.tgz#04eafde54f5bfcf0881b1ae35c4a5205a9041ee2" + dependencies: + acorn "^5.1.2" + caporal "^0.10.0" + glob "^7.1.2" + es-to-primitive@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" @@ -4462,6 +4522,10 @@ exists-stat@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/exists-stat/-/exists-stat-1.0.0.tgz#0660e3525a2e89d9e446129440c272edfa24b529" +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + expand-braces@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" @@ -4579,6 +4643,14 @@ extensionizer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/extensionizer/-/extensionizer-1.0.0.tgz#01c209bbea6d9c0acba77129c3aa4a9a98fc3538" +external-editor@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-1.1.1.tgz#12d7b0db850f7ff7e7081baf4005700060c4600b" + dependencies: + extend "^3.0.0" + spawn-sync "^1.0.15" + tmp "^0.0.29" + external-editor@^2.0.4: version "2.1.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" @@ -4696,6 +4768,13 @@ fetch-ponyfill@^4.0.0: dependencies: node-fetch "~1.7.1" +figures@^1.3.5: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" @@ -5068,6 +5147,16 @@ gather-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/gather-stream/-/gather-stream-1.0.0.tgz#b33994af457a8115700d410f317733cbe7a0904b" +gauge@~1.2.5: + version "1.2.7" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-1.2.7.tgz#e9cec5483d3d4ee0ef44b60a7d99e4935e136d93" + dependencies: + ansi "^0.3.0" + has-unicode "^2.0.0" + lodash.pad "^4.1.0" + lodash.padend "^4.1.0" + lodash.padstart "^4.1.0" + gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" @@ -6046,6 +6135,25 @@ inline-source-map@~0.6.0: dependencies: source-map "~0.5.3" +inquirer@^1.0.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-1.2.3.tgz#4dec6f32f37ef7bb0b2ed3f1d1a5c3f545074918" + dependencies: + ansi-escapes "^1.1.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + external-editor "^1.1.0" + figures "^1.3.5" + lodash "^4.3.0" + mute-stream "0.0.6" + pinkie-promise "^2.0.0" + run-async "^2.2.0" + rx "^4.1.0" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + inquirer@^3.0.6: version "3.3.0" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" @@ -7173,6 +7281,10 @@ lodash.assignin@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + lodash.castarray@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.castarray/-/lodash.castarray-4.4.0.tgz#c02513515e309daddd4c24c60cfddcf5976d9115" @@ -7191,6 +7303,10 @@ lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" +lodash.difference@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c" + lodash.escape@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-3.2.0.tgz#995ee0dc18c1b48cc92effae71a10aab5b487698" @@ -7228,6 +7344,10 @@ lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" +lodash.kebabcase@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" + lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" @@ -7244,10 +7364,26 @@ lodash.memoize@~3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" +lodash.merge@^4.6.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" + lodash.mergewith@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55" +lodash.pad@^4.1.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/lodash.pad/-/lodash.pad-4.5.1.tgz#4330949a833a7c8da22cc20f6a26c4d59debba70" + +lodash.padend@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padend/-/lodash.padend-4.6.1.tgz#53ccba047d06e158d311f45da625f4e49e6f166e" + +lodash.padstart@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b" + lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" @@ -7281,10 +7417,18 @@ lodash.templatesettings@^3.0.0: lodash._reinterpolate "^3.0.0" lodash.escape "^3.0.0" +lodash.uniq@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" + lodash.uniqby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz#d99c07a669e9e6d24e1362dfe266c67616af1302" +lodash@^3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.0, lodash@~4.17.2, lodash@~4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -7655,6 +7799,12 @@ micromatch@^3.1.4: snapdragon "^0.8.1" to-regex "^3.0.1" +micromist@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/micromist/-/micromist-1.0.2.tgz#41f84949a04c30cdc60a394d0cb06aaa08b86364" + dependencies: + lodash.camelcase "^4.3.0" + miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" @@ -7883,6 +8033,10 @@ mute-stdout@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/mute-stdout/-/mute-stdout-1.0.0.tgz#5b32ea07eb43c9ded6130434cf926f46b2a7fd4d" +mute-stream@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db" + mute-stream@0.0.7, mute-stream@~0.0.4: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" @@ -8203,6 +8357,14 @@ npm-run-path@^2.0.0: gauge "~2.7.3" set-blocking "~2.0.0" +npmlog@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-2.0.4.tgz#98b52530f2514ca90d09ec5b22c8846722375692" + dependencies: + ansi "~0.3.1" + are-we-there-yet "~1.1.2" + gauge "~1.2.5" + nth-check@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.1.tgz#9929acdf628fc2c41098deab82ac580cf149aae4" @@ -8437,6 +8599,10 @@ onecolor@^3.0.4: version "3.0.5" resolved "https://registry.yarnpkg.com/onecolor/-/onecolor-3.0.5.tgz#36eff32201379efdf1180fb445e51a8e2425f9f6" +onetime@^1.0.0: + version "1.1.0" + resolved "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + onetime@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" @@ -8505,7 +8671,11 @@ os-locale@^2.0.0: lcid "^1.0.0" mem "^1.1.0" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: +os-shim@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917" + +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -8967,6 +9137,13 @@ pretty-hrtime@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" +prettyjson@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prettyjson/-/prettyjson-1.2.1.tgz#fcffab41d19cab4dfae5e575e64246619b12d289" + dependencies: + colors "^1.1.2" + minimist "^1.2.0" + printf@^0.2.3: version "0.2.5" resolved "https://registry.yarnpkg.com/printf/-/printf-0.2.5.tgz#c438ca2ca33e3927671db4ab69c0e52f936a4f0f" @@ -9967,6 +10144,13 @@ response-stream@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/response-stream/-/response-stream-0.0.0.tgz#da4b17cc7684c98c962beb4d95f668c8dcad09d5" +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" + restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" @@ -10038,6 +10222,10 @@ rx-lite@*, rx-lite@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" +rx@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" + safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" @@ -10538,6 +10726,13 @@ spawn-args@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/spawn-args/-/spawn-args-0.2.0.tgz#fb7d0bd1d70fd4316bd9e3dec389e65f9d6361bb" +spawn-sync@^1.0.15: + version "1.0.15" + resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476" + dependencies: + concat-stream "^1.4.7" + os-shim "^0.1.2" + spawn-wrap@^1.4.2: version "1.4.2" resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.2.tgz#cff58e73a8224617b6561abdc32586ea0c82248c" @@ -11034,6 +11229,19 @@ table@^4.0.1: slice-ansi "1.0.0" string-width "^2.1.1" +tabtab@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/tabtab/-/tabtab-2.2.2.tgz#7a047f143b010b4cbd31f857e82961512cbf4e14" + dependencies: + debug "^2.2.0" + inquirer "^1.0.2" + lodash.difference "^4.5.0" + lodash.uniq "^4.5.0" + minimist "^1.2.0" + mkdirp "^0.5.1" + npmlog "^2.0.3" + object-assign "^4.1.0" + tap-parser@^5.1.0: version "5.4.0" resolved "https://registry.yarnpkg.com/tap-parser/-/tap-parser-5.4.0.tgz#6907e89725d7b7fa6ae41ee2c464c3db43188aec" @@ -11252,6 +11460,12 @@ tmp@0.0.33, tmp@0.0.x, tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" +tmp@^0.0.29: + version "0.0.29" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.29.tgz#f25125ff0dd9da3ccb0c2dd371ee1288bb9128c0" + dependencies: + os-tmpdir "~1.0.1" + to-absolute-glob@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz#1865f43d9e74b0822db9f145b78cff7d0f7c849b" @@ -12055,6 +12269,17 @@ winston@2.1.x: pkginfo "0.3.x" stack-trace "0.0.x" +winston@^2.3.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/winston/-/winston-2.4.1.tgz#a3a9265105564263c6785b4583b8c8aca26fded6" + dependencies: + async "~1.0.0" + colors "1.0.x" + cycle "1.0.x" + eyes "0.1.x" + isstream "0.1.x" + stack-trace "0.0.x" + wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" From 6cbadc0aa342550654cbdb00c3b276542fbd19c5 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 22:54:52 -0230 Subject: [PATCH 11/38] Missed modifications of t() in merge resolution. --- ui/app/components/network-display.js | 3 +-- ui/app/components/pending-tx/confirm-deploy-contract.js | 1 - ui/app/components/pending-tx/confirm-send-ether.js | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ui/app/components/network-display.js b/ui/app/components/network-display.js index 9dc31b5c7..0bc5cdaf8 100644 --- a/ui/app/components/network-display.js +++ b/ui/app/components/network-display.js @@ -3,7 +3,6 @@ const h = require('react-hyperscript') const PropTypes = require('prop-types') const { connect } = require('react-redux') 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)), ]) } } diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index 512aa793d..60afdc7ae 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -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') diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index 68c6f14d2..b76dc94d8 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -13,7 +13,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') From 3c144302d65053fc3082b8b24662fc3e0231ca3a Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 22:57:09 -0230 Subject: [PATCH 12/38] Remove console.logs --- ui/app/metamask-connect.js | 1 - ui/i18n-helper.js | 1 - 2 files changed, 2 deletions(-) diff --git a/ui/app/metamask-connect.js b/ui/app/metamask-connect.js index 38fc05930..097be8dc3 100644 --- a/ui/app/metamask-connect.js +++ b/ui/app/metamask-connect.js @@ -13,7 +13,6 @@ const _higherOrderMapStateToProps = (mapStateToProps) => { const stateProps = mapStateToProps ? mapStateToProps(state, ownProps) : ownProps - console.log(`state.localeMessages`, state.localeMessages); stateProps.t = t.bind(null, state.localeMessages) return stateProps } diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index 70555f239..dc83f45c9 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -2,7 +2,6 @@ const log = require('loglevel') const getMessage = (locale, key, substitutions) => { - console.log(`locale, key, substitutions`, locale, key, substitutions); // check locale is loaded if (!locale) { // throw new Error('Translator - has not loaded a locale yet.') From 18f85835296f12814e0593dfc67b29ac672ddf53 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 23:10:28 -0230 Subject: [PATCH 13/38] Fix references to undefined 'this.props' --- ui/app/accounts/import/index.js | 22 +++++++--------- .../components/modals/deposit-ether-modal.js | 26 +++++++++---------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index 75552924b..3720e637f 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.js @@ -9,26 +9,24 @@ const JsonImportView = require('./json.js') const PrivateKeyImportView = require('./private-key.js') -module.exports = connect(mapStateToProps)(AccountImportSubview) - -function mapStateToProps (state) { - return { - menuItems: [ - this.props.t('privateKey'), - this.props.t('jsonFile'), - ], - } -} +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 ( @@ -80,7 +78,7 @@ 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) { diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js index 0b097d546..40f805181 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -14,10 +14,6 @@ let SHAPESHIFT_ROW_TITLE let SHAPESHIFT_ROW_TEXT let FAUCET_ROW_TITLE -const facuetRowText = (networkName) => { - return this.props.t('getEtherFromFaucet', [networkName]) -} - function mapStateToProps (state) { return { network: state.metamask.network, @@ -44,17 +40,17 @@ 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 = this.props.t('directDepositEther') - DIRECT_DEPOSIT_ROW_TEXT = this.props.t('directDepositEtherExplainer') - COINBASE_ROW_TITLE = this.props.t('buyCoinbase') - COINBASE_ROW_TEXT = this.props.t('buyCoinbaseExplainer') - SHAPESHIFT_ROW_TITLE = this.props.t('depositShapeShift') - SHAPESHIFT_ROW_TEXT = this.props.t('depositShapeShiftExplainer') - FAUCET_ROW_TITLE = this.props.t('testFaucet') + 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, @@ -63,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, @@ -156,7 +156,7 @@ DepositEtherModal.prototype.render = function () { this.renderRow({ logo: h('i.fa.fa-tint.fa-2x'), title: FAUCET_ROW_TITLE, - text: facuetRowText(networkName), + text: this.facuetRowText(networkName), buttonLabel: this.props.t('getEther'), onButtonClick: () => toFaucet(network), hide: !isTestNetwork || buyingWithShapeshift, From a82631791efb496efc9f611a2a3edbac7123d221 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 23:48:10 -0230 Subject: [PATCH 14/38] Lint fixes --- ui/app/accounts/import/index.js | 4 +--- ui/app/accounts/import/json.js | 2 +- ui/app/accounts/new-account/create-form.js | 2 +- ui/app/components/account-dropdowns.js | 2 +- ui/app/components/buy-button-subview.js | 4 ++-- ui/app/components/dropdowns/components/account-dropdowns.js | 2 +- ui/app/components/modals/new-account-modal.js | 4 ++-- ui/app/components/modals/notification-modal.js | 2 +- ui/app/components/network-display.js | 1 + ui/app/components/pending-tx/confirm-deploy-contract.js | 5 +++-- ui/app/components/pending-tx/confirm-send-token.js | 2 +- ui/app/components/send/send-v2-container.js | 1 - ui/app/components/sender-to-recipient.js | 4 ++-- ui/app/settings.js | 1 + 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js index 3720e637f..b09b50ef7 100644 --- a/ui/app/accounts/import/index.js +++ b/ui/app/accounts/import/index.js @@ -17,14 +17,13 @@ function AccountImportSubview () { } AccountImportSubview.prototype.getMenuItemTexts = function () { - return [ + return [ this.props.t('privateKey'), this.props.t('jsonFile'), ] } AccountImportSubview.prototype.render = function () { - const props = this.props const state = this.state || {} const menuItems = this.getMenuItemTexts() const { type } = state @@ -75,7 +74,6 @@ AccountImportSubview.prototype.render = function () { } AccountImportSubview.prototype.renderImportView = function () { - const props = this.props const state = this.state || {} const { type } = state const menuItems = this.getMenuItemTexts() diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js index 8bcc1a14e..431c693ee 100644 --- a/ui/app/accounts/import/json.js +++ b/ui/app/accounts/import/json.js @@ -112,7 +112,7 @@ JsonImportSubview.propTypes = { goHome: PropTypes.func, displayWarning: PropTypes.func, importNewJsonAccount: PropTypes.func, - localeMessages: PropTypes.object, + t: PropTypes.func, } const mapStateToProps = state => { diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js index b0e109cd7..728088568 100644 --- a/ui/app/accounts/new-account/create-form.js +++ b/ui/app/accounts/new-account/create-form.js @@ -61,7 +61,7 @@ NewAccountCreateForm.propTypes = { createAccount: PropTypes.func, goHome: PropTypes.func, numberOfExistingAccounts: PropTypes.number, - localeMessages: PropTypes.object, + t: PropTypes.object, } const mapStateToProps = state => { diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index 88c7dbb60..84678fee6 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -300,7 +300,7 @@ AccountDropdowns.propTypes = { style: PropTypes.object, enableAccountOptions: PropTypes.bool, enableAccountsSelector: PropTypes.bool, - localeMessages: PropTypes.object, + t: PropTypes.func, } const mapDispatchToProps = (dispatch) => { diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index 2243ce38b..eafa2af91 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -143,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: { @@ -203,7 +203,7 @@ BuyButtonSubview.prototype.mainnetSubview = function () { 'ShapeShift', ], subtext: { - 'Coinbase': `${t('crypto')}/${t('fiat')} (${t('usaOnly')})`, + '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/dropdowns/components/account-dropdowns.js b/ui/app/components/dropdowns/components/account-dropdowns.js index d570b3d36..5e7c0d554 100644 --- a/ui/app/components/dropdowns/components/account-dropdowns.js +++ b/ui/app/components/dropdowns/components/account-dropdowns.js @@ -425,7 +425,7 @@ AccountDropdowns.propTypes = { enableAccountsSelector: PropTypes.bool, enableAccountOption: PropTypes.bool, enableAccountOptions: PropTypes.bool, - localeMessages: PropTypes.object, + t: PropTypes.func, } const mapDispatchToProps = (dispatch) => { diff --git a/ui/app/components/modals/new-account-modal.js b/ui/app/components/modals/new-account-modal.js index c46980855..372b65251 100644 --- a/ui/app/components/modals/new-account-modal.js +++ b/ui/app/components/modals/new-account-modal.js @@ -11,7 +11,7 @@ class NewAccountModal extends Component { const newAccountNumber = numberOfExistingAccounts + 1 this.state = { - newAccountName: `${t('account')} ${newAccountNumber}`, + newAccountName: `${props.t('account')} ${newAccountNumber}`, } } @@ -69,7 +69,7 @@ NewAccountModal.propTypes = { showImportPage: PropTypes.func, createAccount: PropTypes.func, numberOfExistingAccounts: PropTypes.number, - localeMessages: PropTypes.object, + 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 3c4ab5194..5d6dca177 100644 --- a/ui/app/components/modals/notification-modal.js +++ b/ui/app/components/modals/notification-modal.js @@ -62,7 +62,7 @@ NotificationModal.propTypes = { showCancelButton: PropTypes.bool, showConfirmButton: PropTypes.bool, onConfirm: PropTypes.func, - localeMessages: PropTypes.object, + t: PropTypes.func, } const mapDispatchToProps = dispatch => { diff --git a/ui/app/components/network-display.js b/ui/app/components/network-display.js index 0bc5cdaf8..ce1ab21a5 100644 --- a/ui/app/components/network-display.js +++ b/ui/app/components/network-display.js @@ -38,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/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index 60afdc7ae..370ffdda3 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -32,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 }) } } @@ -324,6 +324,7 @@ ConfirmDeployContract.propTypes = { conversionRate: PropTypes.number, currentCurrency: PropTypes.string, selectedAddress: PropTypes.string, + t: PropTypes.func, } const mapStateToProps = state => { @@ -346,7 +347,7 @@ 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), } } diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index 50d803fc4..f9b6bb79e 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -327,7 +327,7 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () { 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')}`), ]), ]) ) diff --git a/ui/app/components/send/send-v2-container.js b/ui/app/components/send/send-v2-container.js index d90a6bf75..25902cfce 100644 --- a/ui/app/components/send/send-v2-container.js +++ b/ui/app/components/send/send-v2-container.js @@ -53,7 +53,6 @@ function mapStateToProps (state) { tokenContract: getSelectedTokenContract(state), unapprovedTxs: state.metamask.unapprovedTxs, network: state.metamask.network, - t: t.bind(null, state.localeMessages), } } diff --git a/ui/app/components/sender-to-recipient.js b/ui/app/components/sender-to-recipient.js index 420d50e42..590769b02 100644 --- a/ui/app/components/sender-to-recipient.js +++ b/ui/app/components/sender-to-recipient.js @@ -59,9 +59,9 @@ class SenderToRecipient extends Component { SenderToRecipient.propTypes = { senderName: PropTypes.string, senderAddress: PropTypes.string, - localeMessages: PropTypes.object, - recipientName: PropTypes.string, + recipientName: PropTypes.string, recipientAddress: PropTypes.string, + t: PropTypes.func, } module.exports = { diff --git a/ui/app/settings.js b/ui/app/settings.js index d3525e9c0..96790cb10 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -459,6 +459,7 @@ Settings.propTypes = { isMascara: PropTypes.bool, updateCurrentLocale: PropTypes.func, currentLocale: PropTypes.object, + t: PropTypes.func, } const mapStateToProps = state => { From 3d3bd0eaf001e153eb3c7e9cea5c269bd17d1978 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 00:08:01 -0230 Subject: [PATCH 15/38] Correct connect reference in confirm-send-ether, confirm-deploy-contract, network-display. --- ui/app/components/network-display.js | 2 +- ui/app/components/pending-tx/confirm-deploy-contract.js | 2 +- ui/app/components/pending-tx/confirm-send-ether.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/app/components/network-display.js b/ui/app/components/network-display.js index ce1ab21a5..111a82be1 100644 --- a/ui/app/components/network-display.js +++ b/ui/app/components/network-display.js @@ -1,7 +1,7 @@ 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 networkToColorHash = { diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index 370ffdda3..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') diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index b76dc94d8..255f0e8a2 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 h = require('react-hyperscript') const inherits = require('util').inherits const actions = require('../../actions') From ca5bce477e9acdd5f8457b99de2c32a7b4f26e33 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 00:54:44 -0230 Subject: [PATCH 16/38] Fix sender-to-recipient export and non-existent translation key. --- ui/app/components/sender-to-recipient.js | 6 ++---- ui/app/components/tx-list.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ui/app/components/sender-to-recipient.js b/ui/app/components/sender-to-recipient.js index 590769b02..4c3881668 100644 --- a/ui/app/components/sender-to-recipient.js +++ b/ui/app/components/sender-to-recipient.js @@ -59,11 +59,9 @@ class SenderToRecipient extends Component { SenderToRecipient.propTypes = { senderName: PropTypes.string, senderAddress: PropTypes.string, - recipientName: PropTypes.string, + recipientName: PropTypes.string, recipientAddress: PropTypes.string, t: PropTypes.func, } -module.exports = { - AccountDropdowns: connect()(SenderToRecipient), -} \ No newline at end of file +module.exports = connect()(SenderToRecipient) diff --git a/ui/app/components/tx-list.js b/ui/app/components/tx-list.js index 7c2da30fe..5f09d887e 100644 --- a/ui/app/components/tx-list.js +++ b/ui/app/components/tx-list.js @@ -110,7 +110,7 @@ TxList.prototype.renderTransactionListItem = function (transaction, conversionRa if (isUnapproved) { opts.onClick = () => showConfTxPage({ id: transactionId }) - opts.transactionStatus = this.props.t('Not Started') + opts.transactionStatus = this.props.t('notStarted') } else if (transactionHash) { opts.onClick = () => this.view(transactionHash, transactionNetworkId) } From edf63f8b51ec0717e580ec69b495987a00062b92 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 01:09:21 -0230 Subject: [PATCH 17/38] Add en localeMessages to test states. --- development/genStates.js | 5 +++++ development/get-locale-messages.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 development/get-locale-messages.js diff --git a/development/genStates.js b/development/genStates.js index bc274c757..1b21a42e5 100644 --- a/development/genStates.js +++ b/development/genStates.js @@ -1,6 +1,7 @@ const fs = require('fs') const path = require('path') const promisify = require('pify') +const getLocaleMessages = require('./get-locale-messages') start().catch(console.error) @@ -12,6 +13,10 @@ async function start () { const stateFilePath = path.join(__dirname, 'states', stateFileName) const stateFileContent = await promisify(fs.readFile)(stateFilePath, 'utf8') const state = JSON.parse(stateFileContent) + + const enLocaleMessages = await getLocaleMessages() + state.localeMessages = { en: enLocaleMessages, current: {} } + const stateName = stateFileName.split('.')[0].replace(/-/g, ' ', 'g') states[stateName] = state })) diff --git a/development/get-locale-messages.js b/development/get-locale-messages.js new file mode 100644 index 000000000..3b76a851d --- /dev/null +++ b/development/get-locale-messages.js @@ -0,0 +1,12 @@ +const fs = require('fs') +const path = require('path') +const promisify = require('pify') + +async function getLocaleMessages () { + const localeMessagesPath = path.join(process.cwd(), 'app', '_locales', 'en', 'messages.json') + const enLocaleMessagesJSON = await promisify(fs.readFile)(localeMessagesPath) + const enLocaleMessages = JSON.parse(enLocaleMessagesJSON) + return enLocaleMessages +} + +module.exports = getLocaleMessages From d613dfb43419ea1e18691659d39f6ac403c21d75 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 01:19:00 -0230 Subject: [PATCH 18/38] Correct reprice title and subtitle key names. --- app/_locales/en/messages.json | 4 ++-- ui/app/components/pending-tx/confirm-send-token.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 7f6b9e72d..9fac9c248 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -659,10 +659,10 @@ "save": { "message": "Save" }, - "reprice:title": { + "reprice_title": { "message": "Reprice Transaction" }, - "reprice:subtitle": { + "reprice_subtitle": { "message": "Increase your gas price to attempt to overwrite and speed up your transaction" }, "saveAsFile": { diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index f9b6bb79e..9196f9ab1 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -350,9 +350,9 @@ ConfirmSendToken.prototype.render = function () { this.inputs = [] const isTxReprice = Boolean(txMeta.lastGasPrice) - const title = isTxReprice ? this.props.t('reprice:title') : this.props.t('confirm') + const title = isTxReprice ? this.props.t('reprice_title') : this.props.t('confirm') const subtitle = isTxReprice - ? this.props.t('reprice:subtitle') + ? this.props.t('reprice_subtitle') : this.props.t('pleaseReviewTransaction') return ( From a0df4b6892f3a8f15d2915a062ebe1d9cdeabaec Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 12:36:13 -0230 Subject: [PATCH 19/38] Correct proptypes for t in new-account/create-form.js --- ui/app/accounts/new-account/create-form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js index 728088568..65f29914c 100644 --- a/ui/app/accounts/new-account/create-form.js +++ b/ui/app/accounts/new-account/create-form.js @@ -61,7 +61,7 @@ NewAccountCreateForm.propTypes = { createAccount: PropTypes.func, goHome: PropTypes.func, numberOfExistingAccounts: PropTypes.number, - t: PropTypes.object, + t: PropTypes.func, } const mapStateToProps = state => { From b9309f689be7f55fde0a32a6e576784aa9fc1061 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 12:39:16 -0230 Subject: [PATCH 20/38] Use extension api to get initial locale. --- app/scripts/background.js | 10 ++++++---- app/scripts/controllers/preferences.js | 2 +- .../lib/get-first-preferred-lang-code.js | 18 ++++++++++++++++++ app/scripts/metamask-controller.js | 2 +- package.json | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 app/scripts/lib/get-first-preferred-lang-code.js diff --git a/app/scripts/background.js b/app/scripts/background.js index 8bd7766ad..c8fe1cd63 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -19,7 +19,7 @@ const setupRaven = require('./lib/setupRaven') const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry') const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics') const EdgeEncryptor = require('./edge-encryptor') - +const getFirstPreferredLangCode = require('./lib/get-first-preferred-lang-code') const STORAGE_KEY = 'metamask-config' const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' @@ -58,7 +58,8 @@ setupMetamaskMeshMetrics() async function initialize () { const initState = await loadStateFromPersistence() - await setupController(initState) + const initLangCode = await getFirstPreferredLangCode() + await setupController(initState, initLangCode) log.debug('MetaMask initialization complete.') } @@ -90,11 +91,10 @@ async function loadStateFromPersistence () { return versionedData.data } -function setupController (initState) { +function setupController (initState, initLangCode) { // // MetaMask Controller // - const controller = new MetamaskController({ // User confirmation callbacks: showUnconfirmedMessage: triggerUi, @@ -102,6 +102,8 @@ function setupController (initState) { showUnapprovedTx: triggerUi, // initial state initState, + // initial locale code + initLangCode, // platform specific api platform, encryptor: isEdge ? new EdgeEncryptor() : undefined, diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index dc7da90d0..b4819d951 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -11,7 +11,7 @@ class PreferencesController { tokens: [], useBlockie: false, featureFlags: {}, - currentLocale: 'ja', + currentLocale: opts.initLangCode, }, opts.initState) this.store = new ObservableStore(initState) } diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js new file mode 100644 index 000000000..74dfe246c --- /dev/null +++ b/app/scripts/lib/get-first-preferred-lang-code.js @@ -0,0 +1,18 @@ +const fs = require('fs') +const path = require('path') +const extension = require('extensionizer') +const promisify = require('pify') + +const existingLocaleCodes = fs.readdirSync(path.join(__dirname, '..', '..', '_locales')) + +async function getFirstPreferredLangCode () { + const userPreferredLocaleCodes = await promisify( + extension.i18n.getAcceptLanguages, + { errorFirst: false } + )().catch(err => console.log('err123', err)) + const firstPreferredLangCode = userPreferredLocaleCodes.find(code => existingLocaleCodes.includes(code)) + // const firstPreferredLangCode = userPreferredLocaleCodes[0] + return firstPreferredLangCode || 'en' +} + +module.exports = getFirstPreferredLangCode diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index bd092cea0..6e82f6011 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -57,7 +57,6 @@ module.exports = class MetamaskController extends EventEmitter { this.defaultMaxListeners = 20 this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200) - this.opts = opts const initState = opts.initState || {} this.recordFirstTimeInfo(initState) @@ -82,6 +81,7 @@ module.exports = class MetamaskController extends EventEmitter { // preferences controller this.preferencesController = new PreferencesController({ initState: initState.PreferencesController, + initLangCode: opts.initLangCode, }) // currency controller diff --git a/package.json b/package.json index 1aae1092e..f10491fd1 100644 --- a/package.json +++ b/package.json @@ -141,6 +141,7 @@ "promise-filter": "^1.1.0", "promise-to-callback": "^1.0.0", "pump": "^3.0.0", + "pify": "^3.0.0", "pumpify": "^1.3.4", "qrcode-npm": "0.0.3", "ramda": "^0.24.1", From 11a30378d7aea9d5e331ff52f61b136820a54fb1 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 23 Mar 2018 14:21:32 -0230 Subject: [PATCH 21/38] Memoize t function in metamask-connect --- ui/app/metamask-connect.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/app/metamask-connect.js b/ui/app/metamask-connect.js index 097be8dc3..8da594635 100644 --- a/ui/app/metamask-connect.js +++ b/ui/app/metamask-connect.js @@ -9,11 +9,17 @@ const metamaskConnect = (mapStateToProps, mapDispatchToProps) => { } const _higherOrderMapStateToProps = (mapStateToProps) => { + let _t + let currentLocale return (state, ownProps = {}) => { const stateProps = mapStateToProps ? mapStateToProps(state, ownProps) : ownProps - stateProps.t = t.bind(null, state.localeMessages) + if (currentLocale !== state.metamask.currentLocale) { + currentLocale = state.metamask.currentLocale + _t = t.bind(null, state.localeMessages) + } + stateProps.t = _t return stateProps } } From 3ed9933adbd138d00ea8f85a7def8a1020b99060 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 23 Mar 2018 14:28:34 -0230 Subject: [PATCH 22/38] Include locales in served test files. --- test/base.conf.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/base.conf.js b/test/base.conf.js index adb5357e8..e2e9d44ba 100644 --- a/test/base.conf.js +++ b/test/base.conf.js @@ -19,11 +19,13 @@ module.exports = function(config) { 'test/integration/jquery-3.1.0.min.js', { pattern: 'dist/chrome/images/**/*.*', watched: false, included: false, served: true }, { pattern: 'dist/chrome/fonts/**/*.*', watched: false, included: false, served: true }, + { pattern: 'dist/chrome/_locales/**/*.*', watched: false, included: false, served: true }, ], proxies: { '/images/': '/base/dist/chrome/images/', '/fonts/': '/base/dist/chrome/fonts/', + '/_locales/': '/base/dist/chrome/_locales/', }, // test results reporter to use From 08e67c4e4a7548cc90321e8eb172a428e03568b4 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 23 Mar 2018 14:29:59 -0230 Subject: [PATCH 23/38] Default current locale in metamask reducer to empty string. --- ui/app/reducers/metamask.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 6e226b0e6..89acdaac3 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -46,7 +46,7 @@ function reduceMetamask (state, action) { networkEndpointType: OLD_UI_NETWORK_TYPE, isRevealingSeedWords: false, welcomeScreenSeen: false, - currentLocale: 'ja', + currentLocale: '', }, state.metamask) switch (action.type) { From 0d71dd7ca0c0c3178670a9882c34d180495a7031 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 23 Mar 2018 14:31:15 -0230 Subject: [PATCH 24/38] i18n helper fetchLocale handles 404 gracefully --- ui/i18n-helper.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index dc83f45c9..3ce24ddfb 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -25,10 +25,18 @@ const getMessage = (locale, key, substitutions) => { return phrase } -async function fetchLocale (localeName) { - const response = await fetch(`/_locales/${localeName}/messages.json`) - const locale = await response.json() - return locale +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 = { From cd204ee8036d0efb46aaf5cced5babca94ea97d6 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 23 Mar 2018 14:51:19 -0230 Subject: [PATCH 25/38] Add currentLocale to test states. --- development/states/add-token.json | 3 ++- development/states/confirm-new-ui.json | 3 ++- development/states/confirm-sig-requests.json | 3 ++- development/states/first-time.json | 3 ++- development/states/send-edit.json | 3 ++- development/states/send-new-ui.json | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/development/states/add-token.json b/development/states/add-token.json index e78393b7f..9c0f16372 100644 --- a/development/states/add-token.json +++ b/development/states/add-token.json @@ -106,7 +106,8 @@ "errors": {}, "maxModeOn": false, "editingTransactionId": null - } + }, + "currentLocale": "en" }, "appState": { "menuOpen": false, diff --git a/development/states/confirm-new-ui.json b/development/states/confirm-new-ui.json index 6981781a9..ae3098ecb 100644 --- a/development/states/confirm-new-ui.json +++ b/development/states/confirm-new-ui.json @@ -128,7 +128,8 @@ "errors": {}, "maxModeOn": false, "editingTransactionId": null - } + }, + "currentLocale": "en" }, "appState": { "menuOpen": false, diff --git a/development/states/confirm-sig-requests.json b/development/states/confirm-sig-requests.json index 0a691e948..b51003d11 100644 --- a/development/states/confirm-sig-requests.json +++ b/development/states/confirm-sig-requests.json @@ -149,7 +149,8 @@ "errors": {}, "maxModeOn": false, "editingTransactionId": null - } + }, + "currentLocale": "en" }, "appState": { "menuOpen": false, diff --git a/development/states/first-time.json b/development/states/first-time.json index 4f5352992..fe9188b80 100644 --- a/development/states/first-time.json +++ b/development/states/first-time.json @@ -36,7 +36,8 @@ }, "shapeShiftTxList": [], "lostAccounts": [], - "tokens": [] + "tokens": [], + "currentLocale": "en" }, "appState": { "menuOpen": false, diff --git a/development/states/send-edit.json b/development/states/send-edit.json index 6981781a9..ae3098ecb 100644 --- a/development/states/send-edit.json +++ b/development/states/send-edit.json @@ -128,7 +128,8 @@ "errors": {}, "maxModeOn": false, "editingTransactionId": null - } + }, + "currentLocale": "en" }, "appState": { "menuOpen": false, diff --git a/development/states/send-new-ui.json b/development/states/send-new-ui.json index a0a2c66e4..1297a9139 100644 --- a/development/states/send-new-ui.json +++ b/development/states/send-new-ui.json @@ -107,7 +107,8 @@ "errors": {}, "maxModeOn": false, "editingTransactionId": null - } + }, + "currentLocale": "en" }, "appState": { "menuOpen": false, From 35baff15aa181a5ec647d5738c027c8ba1ee9285 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 26 Mar 2018 16:04:26 -0230 Subject: [PATCH 26/38] Empty commit. From be2254b880c8c7bc17a139c3137dbe1e11c6060d Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 27 Mar 2018 10:37:45 -0230 Subject: [PATCH 27/38] Remove comments and console.logs --- app/scripts/lib/get-first-preferred-lang-code.js | 3 +-- ui/app/components/pending-tx/confirm-send-token.js | 2 +- ui/app/components/send/currency-display.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js index 74dfe246c..849018f26 100644 --- a/app/scripts/lib/get-first-preferred-lang-code.js +++ b/app/scripts/lib/get-first-preferred-lang-code.js @@ -9,9 +9,8 @@ async function getFirstPreferredLangCode () { const userPreferredLocaleCodes = await promisify( extension.i18n.getAcceptLanguages, { errorFirst: false } - )().catch(err => console.log('err123', err)) + )() const firstPreferredLangCode = userPreferredLocaleCodes.find(code => existingLocaleCodes.includes(code)) - // const firstPreferredLangCode = userPreferredLocaleCodes[0] return firstPreferredLangCode || 'en' } diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js index 9196f9ab1..3e66705ae 100644 --- a/ui/app/components/pending-tx/confirm-send-token.js +++ b/ui/app/components/pending-tx/confirm-send-token.js @@ -21,7 +21,7 @@ const { } = require('../../token-util') const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') -// + const { getTokenExchangeRate, getSelectedAddress, diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js index a0aaada4d..819fee0a0 100644 --- a/ui/app/components/send/currency-display.js +++ b/ui/app/components/send/currency-display.js @@ -10,7 +10,7 @@ inherits(CurrencyDisplay, Component) function CurrencyDisplay () { Component.call(this) } -// + function toHexWei (value) { return conversionUtil(value, { fromNumericBase: 'dec', From f74e802026538e81d7d224eb72353b85eb2ac149 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 27 Mar 2018 10:52:19 -0230 Subject: [PATCH 28/38] Undo unnecessary line removals. --- app/scripts/background.js | 1 + app/scripts/metamask-controller.js | 1 + 2 files changed, 2 insertions(+) diff --git a/app/scripts/background.js b/app/scripts/background.js index 98de1d278..7782fc41e 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -94,6 +94,7 @@ function setupController (initState, initLangCode) { // // MetaMask Controller // + const controller = new MetamaskController({ // User confirmation callbacks: showUnconfirmedMessage: triggerUi, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 6e82f6011..ff7b66572 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -57,6 +57,7 @@ module.exports = class MetamaskController extends EventEmitter { this.defaultMaxListeners = 20 this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200) + this.opts = opts const initState = opts.initState || {} this.recordFirstTimeInfo(initState) From 4ee48acf5672f00d59c49ec68452cd1dd57afa31 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 14:30:50 -0700 Subject: [PATCH 29/38] deps - update package-lock --- package-lock.json | 66 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6ada40b0..015828549 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5352,6 +5352,11 @@ "json-rpc-error": "2.0.0", "promise-to-callback": "1.0.0" } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } }, @@ -5665,6 +5670,13 @@ "ethjs-util": "0.1.4", "pify": "2.3.0", "tape": "4.8.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } } }, "ethjs-format": { @@ -7053,6 +7065,13 @@ "pify": "2.3.0", "pinkie-promise": "2.0.1", "rimraf": "2.6.2" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } } } } @@ -8357,6 +8376,13 @@ "object-assign": "4.1.1", "pify": "2.3.0", "pinkie-promise": "2.0.1" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } } }, "globjoin": { @@ -11917,6 +11943,13 @@ "pify": "2.3.0", "pinkie-promise": "2.0.1", "strip-bom": "2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } } }, "loader-runner": { @@ -16461,6 +16494,13 @@ "graceful-fs": "4.1.11", "pify": "2.3.0", "pinkie-promise": "2.0.1" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } } }, "pathval": { @@ -16507,9 +16547,9 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" }, "ping-pong-stream": { "version": "1.0.0", @@ -19786,6 +19826,14 @@ "object-assign": "4.1.1", "pify": "2.3.0", "pinkie-promise": "2.0.1" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "has-flag": { @@ -20050,6 +20098,12 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, "postcss": { "version": "5.2.18", "resolved": "https://registry.npmjs.org/postcss/-/postcss-5.2.18.tgz", @@ -21654,6 +21708,12 @@ "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, "replace-ext": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", From 2053cac69129a436d20d1392e0361554d7b16959 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 27 Mar 2018 21:35:12 -0230 Subject: [PATCH 30/38] Don't query for undefined. --- ui/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/index.js b/ui/index.js index fe57f791a..1e0e9f1cc 100644 --- a/ui/index.js +++ b/ui/index.js @@ -30,7 +30,9 @@ async function startApp (metamaskState, accountManager, opts) { // parse opts if (!metamaskState.featureFlags) metamaskState.featureFlags = {} - const currentLocaleMessages = await fetchLocale(metamaskState.currentLocale) + const currentLocaleMessages = metamaskState.currentLocale + ? await fetchLocale(metamaskState.currentLocale) + : {} const enLocaleMessages = await fetchLocale('en') const store = configureStore({ From 9e1bdcb09d811e125d8603b4cdaeb94ab04d0d9a Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 17:16:23 -0700 Subject: [PATCH 31/38] test - integration - add locale build step --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c1ba6e761..f4900c77e 100644 --- a/package.json +++ b/package.json @@ -21,13 +21,15 @@ "test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload", "test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", "test:flat": "npm run test:flat:build && karma start test/flat.conf.js", - "test:flat:build": "npm run test:flat:build:ui && npm run test:flat:build:tests", + "test:flat:build": "npm run test:flat:build:ui && npm run test:flat:build:tests && npm run test:flat:build:locales", "test:flat:build:tests": "node test/integration/index.js", "test:flat:build:states": "node development/genStates.js", + "test:flat:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales", "test:flat:build:ui": "npm run test:flat:build:states && browserify ./development/mock-dev.js -o ./development/bundle.js", "test:mascara": "npm run test:mascara:build && karma start test/mascara.conf.js", - "test:mascara:build": "mkdirp dist/mascara && npm run test:mascara:build:ui && npm run test:mascara:build:background && npm run test:mascara:build:tests", + "test:mascara:build": "mkdirp dist/mascara && npm run test:mascara:build:ui && npm run test:mascara:build:background && npm run test:mascara:build:tests && npm run test:mascara:build:locales", "test:mascara:build:ui": "browserify mascara/test/test-ui.js -o dist/mascara/ui.js", + "test:mascara:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales", "test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js", "test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js", "sentry": "export RELEASE=`cat app/manifest.json| jq -r .version` && npm run sentry:release && npm run sentry:upload", From 9482af61576972c29b35eb9a542724005d8fd47a Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 17:52:26 -0700 Subject: [PATCH 32/38] i18n - add locales index json --- app/_locales/index.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/_locales/index.json diff --git a/app/_locales/index.json b/app/_locales/index.json new file mode 100644 index 000000000..4f3662fa4 --- /dev/null +++ b/app/_locales/index.json @@ -0,0 +1,19 @@ +[ + { "code": "de", "name": "German" }, + { "code": "en", "name": "English" }, + { "code": "es", "name": "Spanish" }, + { "code": "fr", "name": "French" }, + { "code": "hn", "name": "Hindi" }, + { "code": "it", "name": "Italian" }, + { "code": "ja", "name": "Japanese" }, + { "code": "ko", "name": "Korean" }, + { "code": "nl", "name": "Dutch" }, + { "code": "ph", "name": "Tagalog" }, + { "code": "pt", "name": "Portuguese" }, + { "code": "ru", "name": "Russian" }, + { "code": "sl", "name": "Slovenian" }, + { "code": "th", "name": "Thai" }, + { "code": "vi", "name": "Vietnamese" }, + { "code": "zh_CN", "name": "Mandarin" }, + { "code": "zh_TW", "name": "Taiwanese" }, +] From 5c521775f6426556664f114ecbc07e13b8272cb9 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 18:02:25 -0700 Subject: [PATCH 33/38] development - genStates - simplify locale importing --- development/genStates.js | 4 ++-- development/get-locale-messages.js | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 development/get-locale-messages.js diff --git a/development/genStates.js b/development/genStates.js index 1b21a42e5..0ac1059be 100644 --- a/development/genStates.js +++ b/development/genStates.js @@ -1,7 +1,8 @@ const fs = require('fs') const path = require('path') const promisify = require('pify') -const getLocaleMessages = require('./get-locale-messages') +const enLocaleMessages = require('../app/_locales/en/messages.json') + start().catch(console.error) @@ -14,7 +15,6 @@ async function start () { const stateFileContent = await promisify(fs.readFile)(stateFilePath, 'utf8') const state = JSON.parse(stateFileContent) - const enLocaleMessages = await getLocaleMessages() state.localeMessages = { en: enLocaleMessages, current: {} } const stateName = stateFileName.split('.')[0].replace(/-/g, ' ', 'g') diff --git a/development/get-locale-messages.js b/development/get-locale-messages.js deleted file mode 100644 index 3b76a851d..000000000 --- a/development/get-locale-messages.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require('fs') -const path = require('path') -const promisify = require('pify') - -async function getLocaleMessages () { - const localeMessagesPath = path.join(process.cwd(), 'app', '_locales', 'en', 'messages.json') - const enLocaleMessagesJSON = await promisify(fs.readFile)(localeMessagesPath) - const enLocaleMessages = JSON.parse(enLocaleMessagesJSON) - return enLocaleMessages -} - -module.exports = getLocaleMessages From 165ae7d193ba2d5f29e0a6472bb26fa13efd1625 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 18:07:24 -0700 Subject: [PATCH 34/38] i18n - derrive locale codes from index --- app/scripts/lib/get-first-preferred-lang-code.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js index 849018f26..28612f763 100644 --- a/app/scripts/lib/get-first-preferred-lang-code.js +++ b/app/scripts/lib/get-first-preferred-lang-code.js @@ -1,9 +1,8 @@ -const fs = require('fs') -const path = require('path') const extension = require('extensionizer') const promisify = require('pify') +const allLocales = require('../../_locales/index.json') -const existingLocaleCodes = fs.readdirSync(path.join(__dirname, '..', '..', '_locales')) +const existingLocaleCodes = allLocales.map(locale => locale.code) async function getFirstPreferredLangCode () { const userPreferredLocaleCodes = await promisify( From e3881143cb010c47464bf9af01014fe5bb045621 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 18:10:13 -0700 Subject: [PATCH 35/38] ui - settings - derrive locales from index --- ui/app/settings.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ui/app/settings.js b/ui/app/settings.js index 7443f2bd4..e855d6324 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -9,6 +9,7 @@ const { exportAsFile } = require('./util') const TabBar = require('./components/tab-bar') const SimpleDropdown = require('./components/dropdowns/simple-dropdown') const ToggleButton = require('react-toggle-button') +const locales = require('../../app/_locales/index.json') const { OLD_UI_NETWORK_TYPE } = require('../../app/scripts/config').enums const getInfuraCurrencyOptions = () => { @@ -25,13 +26,6 @@ const getInfuraCurrencyOptions = () => { }) } -const locales = [ - { name: 'English', code: 'en' }, - { name: 'Japanese', code: 'ja' }, - { name: 'French', code: 'fr' }, - { name: 'Spanish', code: 'es' }, -] - const getLocaleOptions = () => { return locales.map((locale) => { return { @@ -491,4 +485,3 @@ const mapDispatchToProps = dispatch => { } module.exports = connect(mapStateToProps, mapDispatchToProps)(Settings) - From 1a5eccdfc0610133a552fbcdc9353f66603af920 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 18:21:22 -0700 Subject: [PATCH 36/38] ui - settings - fix for currentLocale --- ui/app/settings.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/app/settings.js b/ui/app/settings.js index e855d6324..8764dcafe 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -107,11 +107,12 @@ 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', `${currentLocale.name}`), + h('span.settings__content-description', `${currentLocaleMeta.name}`), ]), h('div.settings__content-item', [ h('div.settings__content-item-col', [ @@ -452,7 +453,7 @@ Settings.propTypes = { goHome: PropTypes.func, isMascara: PropTypes.bool, updateCurrentLocale: PropTypes.func, - currentLocale: PropTypes.object, + currentLocale: PropTypes.string, t: PropTypes.func, } From ff26042b0c5456711210f5fd4e086e9f41bcb475 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 18:21:46 -0700 Subject: [PATCH 37/38] ui - actions - fix log for background call --- ui/app/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/actions.js b/ui/app/actions.js index 0c0b97a98..58240054d 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -1803,9 +1803,9 @@ function setUseBlockie (val) { function updateCurrentLocale (key) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - log.debug(`background.updateCurrentLocale`) fetchLocale(key) .then((localeMessages) => { + log.debug(`background.setCurrentLocale`) background.setCurrentLocale(key, (err) => { dispatch(actions.hideLoadingIndication()) if (err) { From b4ec68b2d4b6713e0a203df88eb4a8982c2cf2c6 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 18:29:54 -0700 Subject: [PATCH 38/38] i18n - fix locales inde --- app/_locales/index.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/_locales/index.json b/app/_locales/index.json index 4f3662fa4..c085deb72 100644 --- a/app/_locales/index.json +++ b/app/_locales/index.json @@ -15,5 +15,5 @@ { "code": "th", "name": "Thai" }, { "code": "vi", "name": "Vietnamese" }, { "code": "zh_CN", "name": "Mandarin" }, - { "code": "zh_TW", "name": "Taiwanese" }, + { "code": "zh_TW", "name": "Taiwanese" } ]