diff --git a/electron/createWindow.js b/electron/createWindow.js index 6c7034f3a..1e6df6867 100644 --- a/electron/createWindow.js +++ b/electron/createWindow.js @@ -88,6 +88,8 @@ export default appState => { window.loadURL(rendererURL + deepLinkingURI); setupBarMenu(); + setLanguage(window); + window.on('close', event => { if (!appState.isQuitting && !appState.autoUpdateAccepted) { event.preventDefault(); @@ -144,3 +146,16 @@ export default appState => { return window; }; + +async function setLanguage(window) { + const storedLanguage = await window.webContents.executeJavaScript("localStorage.getItem('language')"); + const lang = storedLanguage || app.getLocale().slice(0, 2) || 'en'; + if (['pl', 'id', 'de'].includes(lang)) { + const response = await fetch('https://lbry.com/i18n/get/lbry-desktop/app-strings/' + lang + '.json'); + const json = await response.json(); + const messages = {}; + messages[lang] = json; + // Send message to render layer to update language. + window.webContents.send('language-update', messages, lang); + } +} diff --git a/static/index-electron.html b/static/index-electron.html index 3b8b8e263..c30ddb9e6 100644 --- a/static/index-electron.html +++ b/static/index-electron.html @@ -8,28 +8,9 @@