2019-12-07 21:02:00 +02:00
|
|
|
import i18n from 'app/services/i18n';
|
2016-05-19 22:41:43 +03:00
|
|
|
|
2016-11-05 12:11:41 +02:00
|
|
|
export const SET_LOCALE = 'i18n:setLocale';
|
2019-05-21 18:23:13 +03:00
|
|
|
export function setLocale(desiredLocale: string) {
|
2019-12-07 13:28:52 +02:00
|
|
|
return async (
|
|
|
|
dispatch: (action: { [key: string]: any }) => any,
|
|
|
|
): Promise<string> => {
|
2019-11-27 11:03:32 +02:00
|
|
|
const locale = i18n.detectLanguage(desiredLocale);
|
2016-11-05 12:11:41 +02:00
|
|
|
|
2019-11-27 11:03:32 +02:00
|
|
|
dispatch(_setLocale(locale));
|
2016-05-19 22:41:43 +03:00
|
|
|
|
2019-11-27 11:03:32 +02:00
|
|
|
return locale;
|
|
|
|
};
|
2016-05-19 22:41:43 +03:00
|
|
|
}
|
2016-11-05 12:11:41 +02:00
|
|
|
|
2019-11-11 10:40:05 +02:00
|
|
|
function _setLocale(locale: string) {
|
2019-11-27 11:03:32 +02:00
|
|
|
return {
|
|
|
|
type: SET_LOCALE,
|
|
|
|
payload: {
|
|
|
|
locale,
|
|
|
|
},
|
|
|
|
};
|
2016-11-05 12:11:41 +02:00
|
|
|
}
|