diff --git a/lib/actions/user.js b/lib/actions/user.js index 864dbfab1..de60ce093 100644 --- a/lib/actions/user.js +++ b/lib/actions/user.js @@ -16,7 +16,7 @@ import { isBlank } from '../util/ui' import { secureFetch } from '../util/middleware' import { TRIPS_PATH } from '../util/constants' -import { routeTo } from './ui' +import { routeTo, setLocale } from './ui' import { routingQuery } from './api' import { setQueryParam } from './form' @@ -232,7 +232,8 @@ export function fetchTripRequests() { /** * Updates the redux state with the provided user data, including * placing the Home and Work locations at the beginning of the list - * of saved places for rendering in several UI components. + * of saved places for rendering in several UI components, + * and applying accessibility and locale settings. * * Also, fetches monitored trips if requested, i.e. when * - initializing the user state with an existing persisted user, or @@ -248,10 +249,13 @@ function setUser(user, fetchTrips) { dispatch(fetchTripRequests()) } - const { accessibilityRoutingByDefault } = user + const { accessibilityRoutingByDefault, preferredLocale } = user if (accessibilityRoutingByDefault !== undefined) { dispatch(setQueryParam({ wheelchair: accessibilityRoutingByDefault })) } + if (!isBlank(preferredLocale)) { + dispatch(setLocale(preferredLocale)) + } } } diff --git a/lib/components/user/types.ts b/lib/components/user/types.ts index 5fc7e7040..f09a3abcf 100644 --- a/lib/components/user/types.ts +++ b/lib/components/user/types.ts @@ -41,6 +41,7 @@ export interface User { mobilityProfile?: MobilityProfile notificationChannel?: string phoneNumber?: string + preferredLocale?: string pushDevices?: number savedLocations?: UserSavedLocation[] storeTripHistory?: boolean