diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-03-08 15:23:26 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-03-08 15:57:29 +0100 |
| commit | c51eb69ea647e8762201a5f25ac1856b8fab9386 (patch) | |
| tree | 942ff96755f72d399c3c928e7491c2b9f5e6b97f /gui/src/main | |
| parent | 1245828c33bbb91dfcccc875a532ea046f4f74d1 (diff) | |
| download | mullvadvpn-c51eb69ea647e8762201a5f25ac1856b8fab9386.tar.xz mullvadvpn-c51eb69ea647e8762201a5f25ac1856b8fab9386.zip | |
Add locale override via env variable
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/index.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 87bd2d8165..0fc529e30a 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -112,6 +112,9 @@ class ApplicationMain { }; private latestVersionInterval?: NodeJS.Timeout; + // The UI locale which is set once from onReady handler + private locale = 'en'; + public run() { // Since electron's GPU blacklists are broken, GPU acceleration won't work on older distros if (process.platform === 'linux') { @@ -263,8 +266,24 @@ class ApplicationMain { } } + private getLocaleWithOverride(): string { + const localeOverride = process.env.MULLVAD_LOCALE; + if (localeOverride) { + const trimmedLocaleOverride = localeOverride.trim(); + if (trimmedLocaleOverride.length > 0) { + return trimmedLocaleOverride; + } + } + + return app.getLocale(); + } + private onReady = async () => { - loadTranslations(app.getLocale()); + this.locale = this.getLocaleWithOverride(); + + log.info(`Detected locale: ${this.locale}`); + + loadTranslations(this.locale); this.daemonRpc.addConnectionObserver( new ConnectionObserver(this.onDaemonConnected, this.onDaemonDisconnected), @@ -815,6 +834,7 @@ class ApplicationMain { private registerIpcListeners() { IpcMainEventChannel.state.handleGet(() => ({ + locale: this.locale, isConnected: this.connectedToDaemon, autoStart: getOpenAtLogin(), accountHistory: this.accountHistory, |
