Quick fix for i18n

Just use the english locale for now. Load locale data from the
filesystem in the main process and pass it to the renderer preload
script via ipc. Note that we need the locale data to be available by the
time view scripts are loaded.

// FREEBIE
This commit is contained in:
lilia 2017-04-03 23:32:46 -07:00 committed by Scott Nonnenberg
parent 88893079d2
commit 63657db3be
No known key found for this signature in database
GPG key ID: A4931C09644C654B
5 changed files with 51 additions and 12 deletions

13
main.js
View file

@ -6,6 +6,7 @@ const url = require('url')
const fs = require('fs')
const autoUpdater = require('electron-updater').autoUpdater
const autoUpdaterInterval = 60 * 60 * 1000;
const ipc = electron.ipcMain;
app.setAppUserModelId('org.whispersystems.signal-desktop')
@ -47,12 +48,22 @@ function createWindow () {
}
})
// Load locale
const locale = 'en'; // FIXME
const localeData = JSON.parse(fs.readFileSync(path.join(__dirname, '_locales', locale, 'messages.json'), 'utf-8'))
ipc.on('locale-data', function(event, arg) {
event.returnValue = localeData;
});
// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'background.html'),
protocol: 'file:',
slashes: true,
query: { node_env: NODE_ENV }
query: {
node_env: NODE_ENV,
locale: locale
}
}))
// Open the DevTools.