summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-03-08 16:30:46 +0100
committerAndrej Mihajlov <and@mullvad.net>2019-03-08 16:30:46 +0100
commitc4ddb07adede3d46dd80dbda66aa560c9e6487ef (patch)
tree08b739c937db5469b2fc2fc1061e67621dc9bdca /gui/src
parent1245828c33bbb91dfcccc875a532ea046f4f74d1 (diff)
parent43f0fa67de4c7013f59bce9e3d59fb77ddf2f2f7 (diff)
downloadmullvadvpn-c4ddb07adede3d46dd80dbda66aa560c9e6487ef.tar.xz
mullvadvpn-c4ddb07adede3d46dd80dbda66aa560c9e6487ef.zip
Merge branch 'add-ui-language-env-switch'
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts22
-rw-r--r--gui/src/renderer/app.tsx10
-rw-r--r--gui/src/shared/ipc-event-channel.ts1
3 files changed, 28 insertions, 5 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,
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 770f148c77..4176575d97 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -3,7 +3,7 @@ import {
push as pushHistory,
replace as replaceHistory,
} from 'connected-react-router';
-import { ipcRenderer, remote, webFrame } from 'electron';
+import { ipcRenderer, webFrame } from 'electron';
import log from 'electron-log';
import { createMemoryHistory } from 'history';
import * as React from 'react';
@@ -64,6 +64,7 @@ export default class AppRenderer {
},
);
+ private locale: string;
private tunnelState: TunnelStateTransition;
private settings: ISettings;
private guiSettings: IGuiSettingsState;
@@ -145,6 +146,7 @@ export default class AppRenderer {
// Request the initial state from the main process
const initialState = IpcRendererEventChannel.state.get();
+ this.locale = initialState.locale;
this.tunnelState = initialState.tunnelState;
this.settings = initialState.settings;
this.guiSettings = initialState.guiSettings;
@@ -172,7 +174,7 @@ export default class AppRenderer {
webFrame.setVisualZoomLevelLimits(1, 1);
// Load translations
- loadTranslations(remote.app.getLocale());
+ loadTranslations(this.locale);
}
public renderView() {
@@ -181,7 +183,7 @@ export default class AppRenderer {
<ConnectedRouter history={this.memoryHistory}>
{makeRoutes({
app: this,
- locale: remote.app.getLocale(),
+ locale: this.locale,
})}
</ConnectedRouter>
</Provider>
@@ -570,7 +572,7 @@ export default class AppRenderer {
}
private setAccountExpiry(expiry?: string) {
- this.accountExpiry = expiry ? new AccountExpiry(expiry, remote.app.getLocale()) : undefined;
+ this.accountExpiry = expiry ? new AccountExpiry(expiry, this.locale) : undefined;
this.reduxActions.account.updateAccountExpiry(expiry);
}
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index 02480d8150..8cf09078cd 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -15,6 +15,7 @@ import {
} from './daemon-rpc-types';
export interface IAppStateSnapshot {
+ locale: string;
isConnected: boolean;
autoStart: boolean;
accountHistory: AccountToken[];