mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
separate out cross-browser i18n for extensions
This commit is contained in:
parent
99898ac775
commit
7da52c5997
@ -4,6 +4,7 @@ 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 HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts'
|
||||
|
||||
|
@ -3,6 +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')
|
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView)
|
||||
|
||||
|
@ -2,6 +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')
|
||||
|
||||
module.exports = connect(mapStateToProps)(SeedImportSubview)
|
||||
|
||||
|
@ -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 = require('../../../i18n')
|
||||
|
||||
class NewAccountCreateForm extends Component {
|
||||
constructor (props) {
|
||||
|
@ -3,6 +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 { getCurrentViewContext } = require('../../selectors')
|
||||
const classnames = require('classnames')
|
||||
|
||||
|
@ -6,6 +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')
|
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountMenu)
|
||||
|
||||
|
@ -3,6 +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 GasModalCard = require('./gas-modal-card')
|
||||
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
|
@ -10,6 +10,7 @@ const Identicon = require('../../identicon')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const copyToClipboard = require('copy-to-clipboard')
|
||||
const { formatBalance } = require('../../../util')
|
||||
const t = require('../../../../i18n')
|
||||
|
||||
class AccountDropdowns extends Component {
|
||||
constructor (props) {
|
||||
|
@ -6,6 +6,7 @@ const actions = require('../../actions')
|
||||
const Dropdown = require('./components/dropdown').Dropdown
|
||||
const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem
|
||||
const NetworkDropdownIcon = require('./components/network-dropdown-icon')
|
||||
const t = require('../../../i18n')
|
||||
const R = require('ramda')
|
||||
|
||||
// classes from nodes of the toggle element.
|
||||
|
@ -3,6 +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')
|
||||
|
||||
module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)
|
||||
|
||||
|
@ -8,6 +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')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
|
@ -5,6 +5,7 @@ const connect = require('react-redux').connect
|
||||
const actions = require('../../actions')
|
||||
const { getSelectedIdentity } = require('../../selectors')
|
||||
const Identicon = require('../identicon')
|
||||
const t = require('../../../i18n')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
|
@ -4,6 +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')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
|
@ -5,6 +5,7 @@ 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 DIRECT_DEPOSIT_ROW_TITLE = t('directDepositEther')
|
||||
const DIRECT_DEPOSIT_ROW_TEXT = t('directDepositEtherExplainer')
|
||||
|
@ -4,6 +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')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
|
@ -7,6 +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 copyToClipboard = require('copy-to-clipboard')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
|
@ -4,6 +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')
|
||||
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
|
@ -6,6 +6,7 @@ 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')
|
||||
|
@ -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 = require('../../../i18n')
|
||||
|
||||
class NewAccountModal extends Component {
|
||||
constructor (props) {
|
||||
|
@ -9,6 +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 { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||
|
||||
|
@ -9,6 +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 { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||
|
||||
|
@ -6,6 +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 clone = require('clone')
|
||||
const Identicon = require('../identicon')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
|
@ -6,17 +6,11 @@ const h = require('react-hyperscript')
|
||||
const Mascot = require('../components/mascot')
|
||||
const actions = require('../actions')
|
||||
const Tooltip = require('../components/tooltip')
|
||||
const t = require('../../i18n')
|
||||
const getCaretCoordinates = require('textarea-caret')
|
||||
|
||||
let isSubmitting = false
|
||||
|
||||
let t = chrome.i18n.getMessage || (function() {
|
||||
let msg = require('../../../app/_locales/en/messages.json');
|
||||
return (function(key) {
|
||||
return msg[key].message;
|
||||
});
|
||||
})();
|
||||
|
||||
module.exports = connect(mapStateToProps)(InitializeMenuScreen)
|
||||
|
||||
inherits(InitializeMenuScreen, Component)
|
||||
|
18
ui/i18n.js
Normal file
18
ui/i18n.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
// cross-browser connection to extension i18n API
|
||||
|
||||
var getMessage;
|
||||
|
||||
if ((chrome && chrome.i18n && chrome.i18n.getMessage) ||
|
||||
(browser && browser.i18n && browser.i18n.getMessage)) {
|
||||
getMessage = (chrome || browser).i18n.getMessage;
|
||||
} else {
|
||||
// fallback function
|
||||
console.warn('browser.i18n API not available?');
|
||||
let msg = require('../app/_locales/en/messages.json');
|
||||
getMessage = function(key) {
|
||||
return msg[key].message;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getMessage;
|
Loading…
Reference in New Issue
Block a user