aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-03-16 08:29:45 +0800
committerDan <danjm.com@gmail.com>2018-03-16 08:29:45 +0800
commit5fe0be722b6514692a68e920ee8058c5d572237d (patch)
tree58da5c62f17cbd0160d24e44918aa34b4ee23300 /app/scripts
parenteb5a84975b490664aa6238be6ceab3d4749167ee (diff)
downloadtangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.tar
tangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.tar.gz
tangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.tar.bz2
tangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.tar.lz
tangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.tar.xz
tangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.tar.zst
tangerine-wallet-browser-5fe0be722b6514692a68e920ee8058c5d572237d.zip
Handle i18n with redux.
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/preferences.js5
-rw-r--r--app/scripts/metamask-controller.js10
-rw-r--r--app/scripts/popup-core.js4
-rw-r--r--app/scripts/popup.js14
4 files changed, 25 insertions, 8 deletions
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