aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-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