summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-09-23 16:20:57 +0200
committerAndrej Mihajlov <and@mullvad.net>2019-09-25 10:50:58 +0200
commitfa7c1aca5568c1ce4f056c61d5edf5bcd620616d (patch)
tree67e6ba59d20080b851c987d6b4457cbde3efc4b1
parentc1b145a81a1d21622d8b486e3e23782d4cb8c8e2 (diff)
downloadmullvadvpn-fa7c1aca5568c1ce4f056c61d5edf5bcd620616d.tar.xz
mullvadvpn-fa7c1aca5568c1ce4f056c61d5edf5bcd620616d.zip
Move "system" constant to SYSTEM_PREFERRED_LOCALE_KEY and remove MULLVAD_LOCALE env variable
-rw-r--r--README.md5
-rw-r--r--gui/src/main/gui-settings.ts4
-rw-r--r--gui/src/main/index.ts26
-rw-r--r--gui/src/renderer/app.tsx8
-rw-r--r--gui/src/shared/gui-settings-state.ts2
5 files changed, 15 insertions, 30 deletions
diff --git a/README.md b/README.md
index 42f9134ed7..4516c40c6b 100644
--- a/README.md
+++ b/README.md
@@ -293,11 +293,6 @@ to do that before starting the GUI.
1. `MULLVAD_PATH` - Allows changing the path to the folder with the `problem-report` tool when
running in development mode. Defaults to: `<repo>/target/debug/`.
-1. `MULLVAD_LOCALE` - Allows changing the UI locale, for example:
- ```
- MULLVAD_LOCALE=en-US ./mullvad-vpn
- ```
-
## Building the Android app
diff --git a/gui/src/main/gui-settings.ts b/gui/src/main/gui-settings.ts
index 47f4e1bf83..c860bfe490 100644
--- a/gui/src/main/gui-settings.ts
+++ b/gui/src/main/gui-settings.ts
@@ -4,7 +4,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { validate } from 'validated/object';
import { boolean, partialObject, string } from 'validated/schema';
-import { IGuiSettingsState } from '../shared/gui-settings-state';
+import { IGuiSettingsState, SYSTEM_PREFERRED_LOCALE_KEY } from '../shared/gui-settings-state';
const settingsSchema = partialObject({
preferredLocale: string,
@@ -15,7 +15,7 @@ const settingsSchema = partialObject({
});
const defaultSettings: IGuiSettingsState = {
- preferredLocale: 'system',
+ preferredLocale: SYSTEM_PREFERRED_LOCALE_KEY,
autoConnect: true,
enableSystemNotifications: true,
monochromaticIcon: false,
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index d8e64ee123..5b5c58d108 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -23,6 +23,7 @@ import {
TunnelState,
} from '../shared/daemon-rpc-types';
import { loadTranslations, messages } from '../shared/gettext';
+import { SYSTEM_PREFERRED_LOCALE_KEY } from '../shared/gui-settings-state';
import { IpcMainEventChannel } from '../shared/ipc-event-channel';
import {
backupLogFile,
@@ -297,25 +298,12 @@ class ApplicationMain {
}
}
- private getLocaleWithOverride(): string {
- const localeOverride = process.env.MULLVAD_LOCALE;
- const systemLocale = app.getLocale();
-
- if (localeOverride) {
- const trimmedLocaleOverride = localeOverride.trim();
- if (trimmedLocaleOverride.length > 0) {
- return trimmedLocaleOverride;
- } else {
- return systemLocale;
- }
+ private detectLocale(): string {
+ const preferredLocale = this.guiSettings.preferredLocale;
+ if (preferredLocale === SYSTEM_PREFERRED_LOCALE_KEY) {
+ return app.getLocale();
} else {
- const preferredLocale = this.guiSettings.preferredLocale;
- log.info('preferredLocale = ', preferredLocale);
- if (preferredLocale === 'system') {
- return systemLocale;
- } else {
- return preferredLocale;
- }
+ return preferredLocale;
}
}
@@ -1210,7 +1198,7 @@ class ApplicationMain {
}
private updateCurrentLocale() {
- this.locale = this.getLocaleWithOverride();
+ this.locale = this.detectLocale();
log.info(`Detected locale: ${this.locale}`);
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index f6a7536edf..2613aacb88 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -23,7 +23,7 @@ import versionActions from './redux/version/actions';
import { IAppUpgradeInfo, ICurrentAppVersionInfo } from '../main';
import { cities, countries, loadTranslations, messages, relayLocations } from '../shared/gettext';
-import { IGuiSettingsState } from '../shared/gui-settings-state';
+import { IGuiSettingsState, SYSTEM_PREFERRED_LOCALE_KEY } from '../shared/gui-settings-state';
import { IpcRendererEventChannel, IRelayListPair } from '../shared/ipc-event-channel';
import { getRendererLogFile, setupLogging } from '../shared/logging';
@@ -48,7 +48,7 @@ interface IPreferredLocaleDescriptor {
code: string;
}
-const supportedLocaleList = [
+const SUPPORTED_LOCALE_LIST = [
{ name: 'Deutsche', code: 'de' },
{ name: 'English', code: 'en' },
{ name: 'Español', code: 'es' },
@@ -369,9 +369,9 @@ export default class AppRenderer {
// TRANSLATORS: The option that represents the active operating system language in the
// TRANSLATORS: user interface language selection list.
name: messages.gettext('System default'),
- code: 'system',
+ code: SYSTEM_PREFERRED_LOCALE_KEY,
},
- ...supportedLocaleList,
+ ...SUPPORTED_LOCALE_LIST,
];
}
diff --git a/gui/src/shared/gui-settings-state.ts b/gui/src/shared/gui-settings-state.ts
index b897d0e7b4..c99ac10506 100644
--- a/gui/src/shared/gui-settings-state.ts
+++ b/gui/src/shared/gui-settings-state.ts
@@ -1,3 +1,5 @@
+export const SYSTEM_PREFERRED_LOCALE_KEY = 'system';
+
export interface IGuiSettingsState {
preferredLocale: string;
enableSystemNotifications: boolean;