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

21 lines
375 B
TypeScript
Raw Normal View History

import i18n from 'app/services/i18n';
2019-11-11 14:10:05 +05:30
2016-05-20 01:11:43 +05:30
import { SET_LOCALE } from './actions';
2019-12-07 16:58:52 +05:30
export type State = { locale: string };
2019-11-11 14:10:05 +05:30
const defaultState = {
locale: i18n.detectLanguage(),
2019-11-11 14:10:05 +05:30
};
export default function(
state: State = defaultState,
2019-12-07 16:58:52 +05:30
{ type, payload }: { type: string; payload: State },
2019-11-11 14:10:05 +05:30
): State {
if (type === SET_LOCALE) {
return payload;
}
2016-05-20 01:11:43 +05:30
return state;
2016-05-20 01:11:43 +05:30
}