24 lines
464 B
TypeScript
Raw Permalink Normal View History

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';
export function setLocale(desiredLocale: string) {
2019-12-07 13:28:52 +02:00
return async (
dispatch: (action: { [key: string]: any }) => any,
): Promise<string> => {
const locale = i18n.detectLanguage(desiredLocale);
2016-11-05 12:11:41 +02:00
dispatch(_setLocale(locale));
2016-05-19 22:41:43 +03: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) {
return {
type: SET_LOCALE,
payload: {
locale,
},
};
2016-11-05 12:11:41 +02:00
}