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

23 lines
363 B
TypeScript
Raw 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 {
locale: string;
}
2019-11-11 14:10:05 +05:30
const defaultState: State = {
locale: i18n.detectLanguage(),
2019-11-11 14:10:05 +05:30
};
export default function(
state: State = defaultState,
{ type, payload }: Action,
2019-11-11 14:10:05 +05:30
): State {
if (type === 'i18n:setLocale') {
return payload;
}
2016-05-20 01:11:43 +05:30
return state;
2016-05-20 01:11:43 +05:30
}