accounts-frontend/packages/app/components/i18n/reducer.ts

20 lines
371 B
TypeScript
Raw Permalink Normal View History

import i18n from 'app/services/i18n';
2019-11-11 14:10:05 +05:30
import { Action } from './actions';
2016-05-20 01:11:43 +05:30
export interface State {
2020-05-24 04:38:24 +05:30
locale: string;
}
2019-11-11 14:10:05 +05:30
const defaultState: State = {
2020-05-24 04:38:24 +05:30
locale: i18n.detectLanguage(),
2019-11-11 14:10:05 +05:30
};
2020-05-24 04:38:24 +05:30
export default function (state: State = defaultState, { type, payload }: Action): State {
if (type === 'i18n:setLocale') {
return payload;
}
2016-05-20 01:11:43 +05:30
2020-05-24 04:38:24 +05:30
return state;
2016-05-20 01:11:43 +05:30
}