2019-12-08 00:32:00 +05:30
|
|
|
import i18n from 'app/services/i18n';
|
2016-05-20 01:11:43 +05:30
|
|
|
|
2016-11-05 15:41:41 +05:30
|
|
|
export const SET_LOCALE = 'i18n:setLocale';
|
2019-05-21 20:53:13 +05:30
|
|
|
export function setLocale(desiredLocale: string) {
|
2019-12-07 16:58:52 +05:30
|
|
|
return async (
|
|
|
|
dispatch: (action: { [key: string]: any }) => any,
|
|
|
|
): Promise<string> => {
|
2019-11-27 14:33:32 +05:30
|
|
|
const locale = i18n.detectLanguage(desiredLocale);
|
2016-11-05 15:41:41 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
dispatch(_setLocale(locale));
|
2016-05-20 01:11:43 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
return locale;
|
|
|
|
};
|
2016-05-20 01:11:43 +05:30
|
|
|
}
|
2016-11-05 15:41:41 +05:30
|
|
|
|
2019-11-11 14:10:05 +05:30
|
|
|
function _setLocale(locale: string) {
|
2019-11-27 14:33:32 +05:30
|
|
|
return {
|
|
|
|
type: SET_LOCALE,
|
|
|
|
payload: {
|
|
|
|
locale,
|
|
|
|
},
|
|
|
|
};
|
2016-11-05 15:41:41 +05:30
|
|
|
}
|