2019-12-07 21:02:00 +02:00
|
|
|
import i18n from 'app/services/i18n';
|
2019-11-11 10:40:05 +02:00
|
|
|
|
2016-05-19 22:41:43 +03:00
|
|
|
import { SET_LOCALE } from './actions';
|
|
|
|
|
2019-12-07 13:28:52 +02:00
|
|
|
export type State = { locale: string };
|
2019-11-11 10:40:05 +02:00
|
|
|
|
|
|
|
const defaultState = {
|
2019-11-27 11:03:32 +02:00
|
|
|
locale: i18n.detectLanguage(),
|
2019-11-11 10:40:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function(
|
2019-11-27 11:03:32 +02:00
|
|
|
state: State = defaultState,
|
2019-12-07 13:28:52 +02:00
|
|
|
{ type, payload }: { type: string; payload: State },
|
2019-11-11 10:40:05 +02:00
|
|
|
): State {
|
2019-11-27 11:03:32 +02:00
|
|
|
if (type === SET_LOCALE) {
|
|
|
|
return payload;
|
|
|
|
}
|
2016-05-19 22:41:43 +03:00
|
|
|
|
2019-11-27 11:03:32 +02:00
|
|
|
return state;
|
2016-05-19 22:41:43 +03:00
|
|
|
}
|