mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
i18n - load locales manually
This commit is contained in:
parent
e2efc91aee
commit
34aeef50a0
@ -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 injectCss = require('inject-css')
|
||||||
const OldMetaMaskUiCss = require('../../old-ui/css')
|
const OldMetaMaskUiCss = require('../../old-ui/css')
|
||||||
const NewMetaMaskUiCss = require('../../ui/css')
|
const NewMetaMaskUiCss = require('../../ui/css')
|
||||||
@ -10,29 +16,36 @@ const NotificationManager = require('./lib/notification-manager')
|
|||||||
const notificationManager = new NotificationManager()
|
const notificationManager = new NotificationManager()
|
||||||
const setupRaven = require('./lib/setupRaven')
|
const setupRaven = require('./lib/setupRaven')
|
||||||
|
|
||||||
// create platform global
|
start().catch(log.error)
|
||||||
global.platform = new ExtensionPlatform()
|
|
||||||
|
|
||||||
// setup sentry error reporting
|
async function start() {
|
||||||
const release = global.platform.getVersion()
|
|
||||||
setupRaven({ release })
|
|
||||||
|
|
||||||
// inject css
|
// create platform global
|
||||||
// const css = MetaMaskUiCss()
|
global.platform = new ExtensionPlatform()
|
||||||
// injectCss(css)
|
|
||||||
|
|
||||||
// identify window type (popup, notification)
|
// setup sentry error reporting
|
||||||
const windowType = isPopupOrNotification()
|
const release = global.platform.getVersion()
|
||||||
global.METAMASK_UI_TYPE = windowType
|
setupRaven({ release })
|
||||||
closePopupIfOpen(windowType)
|
|
||||||
|
|
||||||
// setup stream to background
|
// Load translator
|
||||||
const extensionPort = extension.runtime.connect({ name: windowType })
|
await translator.setLocale('ja')
|
||||||
const connectionStream = new PortStream(extensionPort)
|
|
||||||
|
|
||||||
// start ui
|
// inject css
|
||||||
const container = document.getElementById('app-content')
|
// const css = MetaMaskUiCss()
|
||||||
startPopup({ container, connectionStream }, (err, store) => {
|
// injectCss(css)
|
||||||
|
|
||||||
|
// identify window type (popup, notification)
|
||||||
|
const windowType = isPopupOrNotification()
|
||||||
|
global.METAMASK_UI_TYPE = windowType
|
||||||
|
closePopupIfOpen(windowType)
|
||||||
|
|
||||||
|
// setup stream to background
|
||||||
|
const extensionPort = extension.runtime.connect({ name: windowType })
|
||||||
|
const connectionStream = new PortStream(extensionPort)
|
||||||
|
|
||||||
|
// start ui
|
||||||
|
const container = document.getElementById('app-content')
|
||||||
|
startPopup({ container, connectionStream }, (err, store) => {
|
||||||
if (err) return displayCriticalError(err)
|
if (err) return displayCriticalError(err)
|
||||||
|
|
||||||
// Code commented out until we begin auto adding users to NewUI
|
// Code commented out until we begin auto adding users to NewUI
|
||||||
@ -60,18 +73,20 @@ startPopup({ container, connectionStream }, (err, store) => {
|
|||||||
}
|
}
|
||||||
if (state.appState.shouldClose) notificationManager.closePopup()
|
if (state.appState.shouldClose) notificationManager.closePopup()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function closePopupIfOpen (windowType) {
|
function closePopupIfOpen (windowType) {
|
||||||
if (windowType !== 'notification') {
|
if (windowType !== 'notification') {
|
||||||
notificationManager.closePopup()
|
notificationManager.closePopup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayCriticalError (err) {
|
function displayCriticalError (err) {
|
||||||
container.innerHTML = '<div class="critical-error">The MetaMask app failed to load: please open and close MetaMask again to restart.</div>'
|
container.innerHTML = '<div class="critical-error">The MetaMask app failed to load: please open and close MetaMask again to restart.</div>'
|
||||||
container.style.height = '80px'
|
container.style.height = '80px'
|
||||||
log.error(err.stack)
|
log.error(err.stack)
|
||||||
throw err
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
10
package-lock.json
generated
10
package-lock.json
generated
@ -3929,6 +3929,16 @@
|
|||||||
"resolved": "https://registry.npmjs.org/debounce/-/debounce-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/debounce/-/debounce-1.1.0.tgz",
|
||||||
"integrity": "sha512-ZQVKfRVlwRfD150ndzEK8M90ABT+Y/JQKs4Y7U4MXdpuoUkkrr4DwKbVux3YjylA5bUMUj0Nc3pMxPJX6N2QQQ=="
|
"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": {
|
"debug": {
|
||||||
"version": "2.6.9",
|
"version": "2.6.9",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||||
|
@ -2,23 +2,21 @@ const inherits = require('util').inherits
|
|||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const t = require('../../../i18n')
|
|
||||||
import Select from 'react-select'
|
import Select from 'react-select'
|
||||||
|
|
||||||
// Subviews
|
// Subviews
|
||||||
const JsonImportView = require('./json.js')
|
const JsonImportView = require('./json.js')
|
||||||
const PrivateKeyImportView = require('./private-key.js')
|
const PrivateKeyImportView = require('./private-key.js')
|
||||||
|
|
||||||
const menuItems = [
|
|
||||||
t('privateKey'),
|
|
||||||
t('jsonFile'),
|
|
||||||
]
|
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(AccountImportSubview)
|
module.exports = connect(mapStateToProps)(AccountImportSubview)
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
menuItems,
|
menuItems: [
|
||||||
|
t('privateKey'),
|
||||||
|
t('jsonFile'),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ const h = require('react-hyperscript')
|
|||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const FileInput = require('react-simple-file-input').default
|
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'
|
const HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts'
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView)
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ const inherits = require('util').inherits
|
|||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(SeedImportSubview)
|
module.exports = connect(mapStateToProps)(SeedImportSubview)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ const PropTypes = require('prop-types')
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const { connect } = require('react-redux')
|
const { connect } = require('react-redux')
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
class NewAccountCreateForm extends Component {
|
class NewAccountCreateForm extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -3,7 +3,7 @@ const h = require('react-hyperscript')
|
|||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
const { getCurrentViewContext } = require('../../selectors')
|
const { getCurrentViewContext } = require('../../selectors')
|
||||||
const classnames = require('classnames')
|
const classnames = require('classnames')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ const connect = require('react-redux').connect
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const actions = require('./actions')
|
const actions = require('./actions')
|
||||||
const classnames = require('classnames')
|
const classnames = require('classnames')
|
||||||
const t = require('../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
// mascara
|
// mascara
|
||||||
const MascaraFirstTime = require('../../mascara/src/app/first-time').default
|
const MascaraFirstTime = require('../../mascara/src/app/first-time').default
|
||||||
|
@ -9,7 +9,6 @@ const DropdownMenuItem = require('./dropdown').DropdownMenuItem
|
|||||||
const Identicon = require('./identicon')
|
const Identicon = require('./identicon')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const copyToClipboard = require('copy-to-clipboard')
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
const t = require('../../i18n')
|
|
||||||
|
|
||||||
class AccountDropdowns extends Component {
|
class AccountDropdowns extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -6,7 +6,7 @@ const copyToClipboard = require('copy-to-clipboard')
|
|||||||
const actions = require('../actions')
|
const actions = require('../actions')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const t = require('../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(ExportAccountView)
|
module.exports = connect(mapStateToProps)(ExportAccountView)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const actions = require('../../actions')
|
|||||||
const { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu')
|
const { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu')
|
||||||
const Identicon = require('../identicon')
|
const Identicon = require('../identicon')
|
||||||
const { formatBalance } = require('../../util')
|
const { formatBalance } = require('../../util')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountMenu)
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountMenu)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ const inherits = require('util').inherits
|
|||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const BN = ethUtil.BN
|
const BN = ethUtil.BN
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const t = require('../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = BnAsDecimalInput
|
module.exports = BnAsDecimalInput
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ const h = require('react-hyperscript')
|
|||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../actions')
|
const actions = require('../actions')
|
||||||
const t = require('../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(CoinbaseForm)
|
module.exports = connect(mapStateToProps)(CoinbaseForm)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const copyToClipboard = require('copy-to-clipboard')
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
const t = require('../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
const Tooltip = require('./tooltip')
|
const Tooltip = require('./tooltip')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ const inherits = require('util').inherits
|
|||||||
|
|
||||||
const Tooltip = require('./tooltip')
|
const Tooltip = require('./tooltip')
|
||||||
const copyToClipboard = require('copy-to-clipboard')
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
const t = require('../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = Copyable
|
module.exports = Copyable
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ const h = require('react-hyperscript')
|
|||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
|
||||||
const GasModalCard = require('./gas-modal-card')
|
const GasModalCard = require('./gas-modal-card')
|
||||||
|
const t = global.getMessage
|
||||||
|
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ const Identicon = require('../../identicon')
|
|||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const copyToClipboard = require('copy-to-clipboard')
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
const { formatBalance } = require('../../../util')
|
const { formatBalance } = require('../../../util')
|
||||||
const t = require('../../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
|
|
||||||
class AccountDropdowns extends Component {
|
class AccountDropdowns extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -6,8 +6,9 @@ const actions = require('../../actions')
|
|||||||
const Dropdown = require('./components/dropdown').Dropdown
|
const Dropdown = require('./components/dropdown').Dropdown
|
||||||
const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem
|
const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem
|
||||||
const NetworkDropdownIcon = require('./components/network-dropdown-icon')
|
const NetworkDropdownIcon = require('./components/network-dropdown-icon')
|
||||||
const t = require('../../../i18n')
|
|
||||||
const R = require('ramda')
|
const R = require('ramda')
|
||||||
|
const t = global.getMessage
|
||||||
|
|
||||||
|
|
||||||
// classes from nodes of the toggle element.
|
// classes from nodes of the toggle element.
|
||||||
const notToggleElementClassnames = [
|
const notToggleElementClassnames = [
|
||||||
|
@ -3,7 +3,8 @@ const h = require('react-hyperscript')
|
|||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
|
|
||||||
module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)
|
module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ const ENS = require('ethjs-ens')
|
|||||||
const networkMap = require('ethjs-ens/lib/network-map.json')
|
const networkMap = require('ethjs-ens/lib/network-map.json')
|
||||||
const ensRE = /.+\..+$/
|
const ensRE = /.+\..+$/
|
||||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||||
const t = require('../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
|
|
||||||
module.exports = EnsInput
|
module.exports = EnsInput
|
||||||
|
@ -8,7 +8,7 @@ const { getSelectedIdentity } = require('../../selectors')
|
|||||||
const genAccountLink = require('../../../lib/account-link.js')
|
const genAccountLink = require('../../../lib/account-link.js')
|
||||||
const QrView = require('../qr-code')
|
const QrView = require('../qr-code')
|
||||||
const EditableLabel = require('../editable-label')
|
const EditableLabel = require('../editable-label')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -5,7 +5,7 @@ const connect = require('react-redux').connect
|
|||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const { getSelectedIdentity } = require('../../selectors')
|
const { getSelectedIdentity } = require('../../selectors')
|
||||||
const Identicon = require('../identicon')
|
const Identicon = require('../identicon')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -4,7 +4,7 @@ const inherits = require('util').inherits
|
|||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const networkNames = require('../../../../app/scripts/config.js').networkNames
|
const networkNames = require('../../../../app/scripts/config.js').networkNames
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -5,15 +5,16 @@ const connect = require('react-redux').connect
|
|||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const networkNames = require('../../../../app/scripts/config.js').networkNames
|
const networkNames = require('../../../../app/scripts/config.js').networkNames
|
||||||
const ShapeshiftForm = require('../shapeshift-form')
|
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) => {
|
const facuetRowText = (networkName) => {
|
||||||
return t('getEtherFromFaucet', [networkName])
|
return t('getEtherFromFaucet', [networkName])
|
||||||
}
|
}
|
||||||
@ -47,6 +48,15 @@ inherits(DepositEtherModal, Component)
|
|||||||
function DepositEtherModal () {
|
function DepositEtherModal () {
|
||||||
Component.call(this)
|
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 = {
|
this.state = {
|
||||||
buyingWithShapeshift: false,
|
buyingWithShapeshift: false,
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ const inherits = require('util').inherits
|
|||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const { getSelectedAccount } = require('../../selectors')
|
const { getSelectedAccount } = require('../../selectors')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -7,7 +7,7 @@ const actions = require('../../actions')
|
|||||||
const AccountModalContainer = require('./account-modal-container')
|
const AccountModalContainer = require('./account-modal-container')
|
||||||
const { getSelectedIdentity } = require('../../selectors')
|
const { getSelectedIdentity } = require('../../selectors')
|
||||||
const ReadOnlyInput = require('../readonly-input')
|
const ReadOnlyInput = require('../readonly-input')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
const copyToClipboard = require('copy-to-clipboard')
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
|
@ -4,7 +4,7 @@ const inherits = require('util').inherits
|
|||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const Identicon = require('../identicon')
|
const Identicon = require('../identicon')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -6,7 +6,6 @@ const FadeModal = require('boron').FadeModal
|
|||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const isMobileView = require('../../../lib/is-mobile-view')
|
const isMobileView = require('../../../lib/is-mobile-view')
|
||||||
const isPopupOrNotification = require('../../../../app/scripts/lib/is-popup-or-notification')
|
const isPopupOrNotification = require('../../../../app/scripts/lib/is-popup-or-notification')
|
||||||
const t = require('../../../i18n')
|
|
||||||
|
|
||||||
// Modal Components
|
// Modal Components
|
||||||
const BuyOptions = require('./buy-options-modal')
|
const BuyOptions = require('./buy-options-modal')
|
||||||
@ -174,8 +173,8 @@ const MODALS = {
|
|||||||
BETA_UI_NOTIFICATION_MODAL: {
|
BETA_UI_NOTIFICATION_MODAL: {
|
||||||
contents: [
|
contents: [
|
||||||
h(NotifcationModal, {
|
h(NotifcationModal, {
|
||||||
header: t('uiWelcome'),
|
header: 'uiWelcome',
|
||||||
message: t('uiWelcomeMessage'),
|
message: 'uiWelcomeMessage',
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
mobileModalStyle: {
|
mobileModalStyle: {
|
||||||
@ -191,8 +190,8 @@ const MODALS = {
|
|||||||
OLD_UI_NOTIFICATION_MODAL: {
|
OLD_UI_NOTIFICATION_MODAL: {
|
||||||
contents: [
|
contents: [
|
||||||
h(NotifcationModal, {
|
h(NotifcationModal, {
|
||||||
header: t('oldUI'),
|
header: 'oldUI',
|
||||||
message: t('oldUIMessage'),
|
message: 'oldUIMessage',
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
mobileModalStyle: {
|
mobileModalStyle: {
|
||||||
|
@ -3,7 +3,7 @@ const PropTypes = require('prop-types')
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const { connect } = require('react-redux')
|
const { connect } = require('react-redux')
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
class NewAccountModal extends Component {
|
class NewAccountModal extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -3,6 +3,7 @@ const PropTypes = require('prop-types')
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const { connect } = require('react-redux')
|
const { connect } = require('react-redux')
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
|
const t = global.getMessage
|
||||||
|
|
||||||
class NotificationModal extends Component {
|
class NotificationModal extends Component {
|
||||||
render () {
|
render () {
|
||||||
@ -22,12 +23,12 @@ class NotificationModal extends Component {
|
|||||||
}, [
|
}, [
|
||||||
|
|
||||||
h('div.notification-modal__header', {}, [
|
h('div.notification-modal__header', {}, [
|
||||||
header,
|
t(header),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
h('div.notification-modal__message-wrapper', {}, [
|
h('div.notification-modal__message-wrapper', {}, [
|
||||||
h('div.notification-modal__message', {}, [
|
h('div.notification-modal__message', {}, [
|
||||||
message,
|
t(message),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ const ethUtil = require('ethereumjs-util')
|
|||||||
const BN = ethUtil.BN
|
const BN = ethUtil.BN
|
||||||
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
||||||
const { conversionUtil } = require('../../conversion-util')
|
const { conversionUtil } = require('../../conversion-util')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ const ethUtil = require('ethereumjs-util')
|
|||||||
const BN = ethUtil.BN
|
const BN = ethUtil.BN
|
||||||
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
||||||
const { conversionUtil, addCurrencies } = require('../../conversion-util')
|
const { conversionUtil, addCurrencies } = require('../../conversion-util')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const tokenAbi = require('human-standard-token-abi')
|
|||||||
const abiDecoder = require('abi-decoder')
|
const abiDecoder = require('abi-decoder')
|
||||||
abiDecoder.addABI(tokenAbi)
|
abiDecoder.addABI(tokenAbi)
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
const clone = require('clone')
|
const clone = require('clone')
|
||||||
const Identicon = require('../identicon')
|
const Identicon = require('../identicon')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
@ -7,7 +7,7 @@ const inherits = require('util').inherits
|
|||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const selectors = require('../../selectors')
|
const selectors = require('../../selectors')
|
||||||
const { isValidAddress, allNull } = require('../../util')
|
const { isValidAddress, allNull } = require('../../util')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
// const BalanceComponent = require('./balance-component')
|
// const BalanceComponent = require('./balance-component')
|
||||||
const Identicon = require('../identicon')
|
const Identicon = require('../identicon')
|
||||||
|
@ -2,7 +2,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const CurrencyDisplay = require('./currency-display')
|
const CurrencyDisplay = require('./currency-display')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = GasFeeDisplay
|
module.exports = GasFeeDisplay
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const InputNumber = require('../input-number.js')
|
const InputNumber = require('../input-number.js')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = GasTooltip
|
module.exports = GasTooltip
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const AccountListItem = require('./account-list-item')
|
const AccountListItem = require('./account-list-item')
|
||||||
const t = require('../../../i18n')
|
const t = global.getMessage
|
||||||
|
|
||||||
module.exports = ToAutoComplete
|
module.exports = ToAutoComplete
|
||||||
|
|
||||||
|
43
ui/create-i18n.js
Normal file
43
ui/create-i18n.js
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user