summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-01-31 12:55:05 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-01-31 12:58:08 +0100
commit4bc8afd9f1cfee956b0d54900d17aa452b0993df (patch)
treea813075850a91ce77f72902e6947fc290d19ed86 /gui
parent5771433c48651dcef3b2c533c49daaf4b188350b (diff)
downloadmullvadvpn-4bc8afd9f1cfee956b0d54900d17aa452b0993df.tar.xz
mullvadvpn-4bc8afd9f1cfee956b0d54900d17aa452b0993df.zip
Use language code to display selected language
Diffstat (limited to 'gui')
-rw-r--r--gui/src/renderer/app.tsx5
-rw-r--r--gui/src/renderer/containers/SettingsPage.tsx17
-rw-r--r--gui/src/renderer/redux/userinterface/actions.ts14
-rw-r--r--gui/src/renderer/redux/userinterface/reducers.ts5
4 files changed, 12 insertions, 29 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index b3a1b257bd..5fb48f701f 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -392,7 +392,7 @@ export default class AppRenderer {
IpcRendererEventChannel.guiSettings.setPreferredLocale(preferredLocale);
}
- private getPreferredLocaleDisplayName(localeCode: string): string {
+ public getPreferredLocaleDisplayName(localeCode: string): string {
const preferredLocale = this.getPreferredLocaleList().find((item) => item.code === localeCode);
return preferredLocale ? preferredLocale.name : '';
@@ -691,9 +691,6 @@ export default class AppRenderer {
private setGuiSettings(guiSettings: IGuiSettingsState) {
this.guiSettings = guiSettings;
this.reduxActions.settings.updateGuiSettings(guiSettings);
- this.reduxActions.userInterface.updatePreferredLocaleName(
- this.getPreferredLocaleDisplayName(guiSettings.preferredLocale),
- );
}
private setAccountExpiry(expiry?: string) {
diff --git a/gui/src/renderer/containers/SettingsPage.tsx b/gui/src/renderer/containers/SettingsPage.tsx
index b3cf582140..a1d65970a8 100644
--- a/gui/src/renderer/containers/SettingsPage.tsx
+++ b/gui/src/renderer/containers/SettingsPage.tsx
@@ -3,10 +3,13 @@ import { remote, shell } from 'electron';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Settings from '../components/Settings';
+import withAppContext, { IAppContext } from '../context';
import { IReduxState, ReduxDispatch } from '../redux/store';
-const mapStateToProps = (state: IReduxState) => ({
- preferredLocaleDisplayName: state.userInterface.preferredLocaleName,
+const mapStateToProps = (state: IReduxState, props: IAppContext) => ({
+ preferredLocaleDisplayName: props.app.getPreferredLocaleDisplayName(
+ state.settings.guiSettings.preferredLocale,
+ ),
loginState: state.account.status,
accountExpiry: state.account.expiry,
expiryLocale: state.userInterface.locale,
@@ -29,7 +32,9 @@ const mapDispatchToProps = (dispatch: ReduxDispatch) => {
};
};
-export default connect(
- mapStateToProps,
- mapDispatchToProps,
-)(Settings);
+export default withAppContext(
+ connect(
+ mapStateToProps,
+ mapDispatchToProps,
+ )(Settings),
+);
diff --git a/gui/src/renderer/redux/userinterface/actions.ts b/gui/src/renderer/redux/userinterface/actions.ts
index d9895625a3..2954161f89 100644
--- a/gui/src/renderer/redux/userinterface/actions.ts
+++ b/gui/src/renderer/redux/userinterface/actions.ts
@@ -5,11 +5,6 @@ export interface IUpdateLocaleAction {
locale: string;
}
-export interface IUpdatePreferredLocaleNameAction {
- type: 'UPDATE_PREFERRED_LOCALE_NAME';
- name: string;
-}
-
export interface IUpdateWindowArrowPositionAction {
type: 'UPDATE_WINDOW_ARROW_POSITION';
arrowPosition: number;
@@ -26,7 +21,6 @@ export interface ISetLocationScopeAction {
export type UserInterfaceAction =
| IUpdateLocaleAction
- | IUpdatePreferredLocaleNameAction
| IUpdateWindowArrowPositionAction
| IUpdateConnectionInfoOpenAction
| ISetLocationScopeAction;
@@ -38,13 +32,6 @@ function updateLocale(locale: string): IUpdateLocaleAction {
};
}
-function updatePreferredLocaleName(name: string): IUpdatePreferredLocaleNameAction {
- return {
- type: 'UPDATE_PREFERRED_LOCALE_NAME',
- name,
- };
-}
-
function updateWindowArrowPosition(arrowPosition: number): IUpdateWindowArrowPositionAction {
return {
type: 'UPDATE_WINDOW_ARROW_POSITION',
@@ -67,7 +54,6 @@ function setLocationScope(scope: LocationScope): ISetLocationScopeAction {
export default {
updateLocale,
- updatePreferredLocaleName,
updateWindowArrowPosition,
toggleConnectionPanel,
setLocationScope,
diff --git a/gui/src/renderer/redux/userinterface/reducers.ts b/gui/src/renderer/redux/userinterface/reducers.ts
index 6afaadde86..7941d6001b 100644
--- a/gui/src/renderer/redux/userinterface/reducers.ts
+++ b/gui/src/renderer/redux/userinterface/reducers.ts
@@ -7,7 +7,6 @@ export enum LocationScope {
export interface IUserInterfaceReduxState {
locale: string;
- preferredLocaleName: string;
arrowPosition?: number;
connectionPanelVisible: boolean;
locationScope: LocationScope;
@@ -15,7 +14,6 @@ export interface IUserInterfaceReduxState {
const initialState: IUserInterfaceReduxState = {
locale: 'en',
- preferredLocaleName: 'English',
connectionPanelVisible: false,
locationScope: LocationScope.relay,
};
@@ -28,9 +26,6 @@ export default function(
case 'UPDATE_LOCALE':
return { ...state, locale: action.locale };
- case 'UPDATE_PREFERRED_LOCALE_NAME':
- return { ...state, preferredLocaleName: action.name };
-
case 'UPDATE_WINDOW_ARROW_POSITION':
return { ...state, arrowPosition: action.arrowPosition };