diff --git a/app/locale.js b/app/locale.js index cc2d7baf6f4d..b0d7b2a2b5cd 100644 --- a/app/locale.js +++ b/app/locale.js @@ -24,25 +24,31 @@ function getLocaleMessages(locale) { return JSON.parse(fs.readFileSync(targetFile, 'utf-8')); } -// Load locale - if we can't load messages for the current locale, we -// default to 'en' -// -// possible locales: -// https://github.com/electron/electron/blob/master/docs/api/locales.md -let localeName = normalizeLocaleName(app.getLocale()); -let messages; +function load() { + // Load locale - if we can't load messages for the current locale, we + // default to 'en' + // + // possible locales: + // https://github.com/electron/electron/blob/master/docs/api/locales.md + let localeName = normalizeLocaleName(app.getLocale()); + let messages; -try { - messages = getLocaleMessages(localeName); -} catch (e) { - console.log('Problem loading messages for locale ', localeName, e.stack); - console.log('Falling back to en locale'); + try { + messages = getLocaleMessages(localeName); + } catch (e) { + console.log('Problem loading messages for locale ', localeName, e.stack); + console.log('Falling back to en locale'); - localeName = 'en'; - messages = getLocaleMessages(localeName); + localeName = 'en'; + messages = getLocaleMessages(localeName); + } + + return { + name: localeName, + messages + }; } module.exports = { - name: localeName, - messages -} + load: load +}; diff --git a/main.js b/main.js index 56f9d3c6cbf5..e50c62962e51 100644 --- a/main.js +++ b/main.js @@ -40,9 +40,14 @@ if (config.environment === 'production' && !process.mas) { const userConfig = require('./app/user_config'); let windowConfig = userConfig.get('window'); -const locale = require('./app/locale'); +const loadLocale = require('./app/locale').load; +let locale; function createWindow () { + if (!locale) { + locale = loadLocale(); + } + const windowOptions = Object.assign({ width: 800, height: 610,