diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-11-10 13:32:16 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-11-16 12:34:34 +0100 |
| commit | ee710acafe628e60d3be4aff04dbe5130a64f39c (patch) | |
| tree | a4865b344c91e3ed1202030c08e7fe2eddfee477 /gui/src | |
| parent | a013d38cf4d0dbb1984fbd1022c08de9b5ae410c (diff) | |
| download | mullvadvpn-ee710acafe628e60d3be4aff04dbe5130a64f39c.tar.xz mullvadvpn-ee710acafe628e60d3be4aff04dbe5130a64f39c.zip | |
Store locations in english and translate for rendering
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/app.tsx | 30 | ||||
| -rw-r--r-- | gui/src/renderer/components/LocationList.tsx | 5 | ||||
| -rw-r--r-- | gui/src/renderer/components/TunnelControl.tsx | 9 |
3 files changed, 12 insertions, 32 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 0acbd25ab2..4de7bb8ca6 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -562,12 +562,6 @@ export default class AppRenderer { // load translations for new locale loadTranslations(messages, translations.locale, translations.messages); loadTranslations(relayLocations, translations.locale, translations.relayLocations); - - // refresh the relay list pair with the new translations - this.propagateRelayListPairToRedux(); - - // refresh the location with the new translations - this.propagateLocationToRedux(); } public getPreferredLocaleDisplayName(localeCode: string): string { @@ -837,37 +831,19 @@ export default class AppRenderer { private propagateLocationToRedux() { if (this.location) { - this.reduxActions.connection.newLocation(this.translateLocation(this.location)); + this.reduxActions.connection.newLocation(this.location); } } - private translateLocation(inputLocation: Partial<ILocation>): Partial<ILocation> { - const location = { ...inputLocation }; - - if (location.city) { - const city = location.city; - - location.city = relayLocations.gettext(city) || city; - } - - if (location.country) { - const country = location.country; - - location.country = relayLocations.gettext(country) || country; - } - - return location; - } - private convertRelayListToLocationList(relayList: IRelayList): IRelayLocationRedux[] { return relayList.countries .map((country) => ({ - name: relayLocations.gettext(country.name) || country.name, + name: country.name, code: country.code, hasActiveRelays: country.cities.some((city) => city.relays.some((relay) => relay.active)), cities: country.cities .map((city) => ({ - name: relayLocations.gettext(city.name) || city.name, + name: city.name, code: city.code, latitude: city.latitude, longitude: city.longitude, diff --git a/gui/src/renderer/components/LocationList.tsx b/gui/src/renderer/components/LocationList.tsx index c47312f158..6389784ecd 100644 --- a/gui/src/renderer/components/LocationList.tsx +++ b/gui/src/renderer/components/LocationList.tsx @@ -7,6 +7,7 @@ import { RelayLocation, relayLocationComponents, } from '../../shared/daemon-rpc-types'; +import { relayLocations } from '../../shared/gettext'; import { IRelayLocationRedux } from '../redux/settings/reducers'; import * as Cell from './cell'; import LocationRow from './LocationRow'; @@ -283,7 +284,7 @@ export class RelayLocations extends React.PureComponent<IRelayLocationsProps> { return ( <LocationRow key={getLocationKey(countryLocation)} - name={relayCountry.name} + name={relayLocations.gettext(relayCountry.name)} active={relayCountry.hasActiveRelays} expanded={this.isExpanded(countryLocation)} onSelect={this.handleSelection} @@ -299,7 +300,7 @@ export class RelayLocations extends React.PureComponent<IRelayLocationsProps> { return ( <LocationRow key={getLocationKey(cityLocation)} - name={relayCity.name} + name={relayLocations.gettext(relayCity.name)} active={relayCity.hasActiveRelays} expanded={this.isExpanded(cityLocation)} onSelect={this.handleSelection} diff --git a/gui/src/renderer/components/TunnelControl.tsx b/gui/src/renderer/components/TunnelControl.tsx index de3906c012..d0f36f8ec7 100644 --- a/gui/src/renderer/components/TunnelControl.tsx +++ b/gui/src/renderer/components/TunnelControl.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { sprintf } from 'sprintf-js'; import styled from 'styled-components'; import { TunnelState } from '../../shared/daemon-rpc-types'; -import { messages } from '../../shared/gettext'; +import { messages, relayLocations } from '../../shared/gettext'; import ConnectionPanelContainer from '../containers/ConnectionPanelContainer'; import * as AppButton from './AppButton'; import { bigText } from './common-styles'; @@ -197,11 +197,14 @@ export default class TunnelControl extends React.Component<ITunnelControlProps> } private renderCity() { - return <StyledMarquee>{this.props.city}</StyledMarquee>; + const city = this.props.city === undefined ? '' : relayLocations.gettext(this.props.city); + return <StyledMarquee>{city}</StyledMarquee>; } private renderCountry() { - return <StyledMarquee>{this.props.country}</StyledMarquee>; + const country = + this.props.country === undefined ? '' : relayLocations.gettext(this.props.country); + return <StyledMarquee>{country}</StyledMarquee>; } private switchLocationButton() { |
