summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/shared')
-rw-r--r--gui/src/shared/gettext.ts18
-rw-r--r--gui/src/shared/gui-settings-state.ts17
-rw-r--r--gui/src/shared/ipc-event-channel.ts19
3 files changed, 46 insertions, 8 deletions
diff --git a/gui/src/shared/gettext.ts b/gui/src/shared/gettext.ts
index d7cd0f8b23..1f6af17aed 100644
--- a/gui/src/shared/gettext.ts
+++ b/gui/src/shared/gettext.ts
@@ -21,16 +21,21 @@ export function loadTranslations(currentLocale: string, catalogue: Gettext) {
preferredLocales.push(language);
}
- for (const locale of preferredLocales) {
- // NOTE: domain is not publicly exposed
- const domain = (catalogue as any).domain;
+ // NOTE: domain is not publicly exposed
+ const domain = (catalogue as any).domain;
+ for (const locale of preferredLocales) {
if (parseTranslation(locale, domain, catalogue)) {
- log.info(`Loaded translations for ${locale}`);
+ log.info(`Loaded translations ${locale}/${domain}`);
catalogue.setLocale(locale);
return;
}
}
+
+ // Reset the locale to source language if we couldn't load the catalogue for the requested locale
+ // Add empty translations to suppress some of the warnings produces by node-gettext
+ catalogue.addTranslations(SOURCE_LANGUAGE, domain, {});
+ catalogue.setLocale(SOURCE_LANGUAGE);
}
function parseTranslation(locale: string, domain: string, catalogue: Gettext): boolean {
@@ -66,7 +71,10 @@ function setErrorHandler(catalogue: Gettext) {
// Filter out the "no translation was found" errors for the source language.
// The catalogue's locale is set to an empty string when using the source translation.
- if (catalogueLocale === '' && error.indexOf('No translation was found') !== -1) {
+ if (
+ (catalogueLocale === '' || catalogueLocale === SOURCE_LANGUAGE) &&
+ error.indexOf('No translation was found') !== -1
+ ) {
return;
}
diff --git a/gui/src/shared/gui-settings-state.ts b/gui/src/shared/gui-settings-state.ts
index fdda92d830..043892f833 100644
--- a/gui/src/shared/gui-settings-state.ts
+++ b/gui/src/shared/gui-settings-state.ts
@@ -1,6 +1,23 @@
+// This is a special value which is when contained within IGuiSettingsState.preferredLocale
+// indicates that app should use the active operating system locale to determine the UI language.
+export const SYSTEM_PREFERRED_LOCALE_KEY = 'system';
+
export interface IGuiSettingsState {
+ // A user interface locale.
+ // Use 'system' to opt-in for active locale set in the operating system
+ // (see SYSTEM_PREFERRED_LOCALE_KEY)
+ preferredLocale: string;
+
+ // Enable or disable system notifications on tunnel state etc.
enableSystemNotifications: boolean;
+
+ // Tells the app to activate auto-connect feature in the mullvad-daemon, but only if the app is
+ // set to auto-start with the system.
autoConnect: boolean;
+
+ // Tells the app to use monochromatic set of icons for tray.
monochromaticIcon: boolean;
+
+ // Tells the app to hide the main window on start.
startMinimized: boolean;
}
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index 2800ab50ea..8a1a31c2d4 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -29,8 +29,7 @@ export interface IAppStateSnapshot {
tunnelState: TunnelState;
settings: ISettings;
location?: ILocation;
- relays: IRelayList;
- bridges: IRelayList;
+ relayListPair: IRelayListPair;
currentVersion: ICurrentAppVersionInfo;
upgradeVersion: IAppUpgradeInfo;
guiSettings: IGuiSettingsState;
@@ -89,6 +88,7 @@ interface IGuiSettingsMethods extends IReceiver<IGuiSettingsState> {
setAutoConnect(autoConnect: boolean): void;
setStartMinimized(startMinimized: boolean): void;
setMonochromaticIcon(monochromaticIcon: boolean): void;
+ setPreferredLocale(locale: string): void;
}
interface IGuiSettingsHandlers extends ISender<IGuiSettingsState> {
@@ -96,6 +96,7 @@ interface IGuiSettingsHandlers extends ISender<IGuiSettingsState> {
handleAutoConnect(fn: (autoConnect: boolean) => void): void;
handleStartMinimized(fn: (startMinimized: boolean) => void): void;
handleMonochromaticIcon(fn: (monochromaticIcon: boolean) => void): void;
+ handleSetPreferredLocale(fn: (locale: string) => void): void;
}
interface IAccountHandlers extends ISender<IAccountData | undefined> {
@@ -138,6 +139,7 @@ interface IWireguardKeyHandlers extends ISender<IWireguardPublicKey | undefined>
/// Events names
+const LOCALE_CHANGED = 'locale-changed';
const WINDOW_SHAPE_CHANGED = 'window-shape-changed';
const DAEMON_CONNECTED = 'daemon-connected';
@@ -166,6 +168,7 @@ const SET_ENABLE_SYSTEM_NOTIFICATIONS = 'set-enable-system-notifications';
const SET_AUTO_CONNECT = 'set-auto-connect';
const SET_MONOCHROMATIC_ICON = 'set-monochromatic-icon';
const SET_START_MINIMIZED = 'set-start-minimized';
+const SET_PREFERRED_LOCALE = 'set-preferred-locale';
const GET_APP_STATE = 'get-app-state';
@@ -197,6 +200,10 @@ export class IpcRendererEventChannel {
},
};
+ public static locale: IReceiver<string> = {
+ listen: listen(LOCALE_CHANGED),
+ };
+
public static windowShape: IReceiver<IWindowShapeParameters> = {
listen: listen(WINDOW_SHAPE_CHANGED),
};
@@ -248,6 +255,7 @@ export class IpcRendererEventChannel {
setAutoConnect: set(SET_AUTO_CONNECT),
setMonochromaticIcon: set(SET_MONOCHROMATIC_ICON),
setStartMinimized: set(SET_START_MINIMIZED),
+ setPreferredLocale: set(SET_PREFERRED_LOCALE),
};
public static autoStart: IAutoStartMethods = {
@@ -283,8 +291,12 @@ export class IpcMainEventChannel {
},
};
+ public static locale: ISender<string> = {
+ notify: sender(LOCALE_CHANGED),
+ };
+
public static windowShape: ISender<IWindowShapeParameters> = {
- notify: sender<IWindowShapeParameters>(WINDOW_SHAPE_CHANGED),
+ notify: sender(WINDOW_SHAPE_CHANGED),
};
public static daemonConnected: ISenderVoid = {
@@ -334,6 +346,7 @@ export class IpcMainEventChannel {
handleAutoConnect: handler(SET_AUTO_CONNECT),
handleMonochromaticIcon: handler(SET_MONOCHROMATIC_ICON),
handleStartMinimized: handler(SET_START_MINIMIZED),
+ handleSetPreferredLocale: handler(SET_PREFERRED_LOCALE),
};
public static autoStart: IAutoStartHandlers = {