mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-10-30 15:33:11 +05:30
24 lines
464 B
TypeScript
24 lines
464 B
TypeScript
import i18n from 'app/services/i18n';
|
|
|
|
export const SET_LOCALE = 'i18n:setLocale';
|
|
export function setLocale(desiredLocale: string) {
|
|
return async (
|
|
dispatch: (action: { [key: string]: any }) => any,
|
|
): Promise<string> => {
|
|
const locale = i18n.detectLanguage(desiredLocale);
|
|
|
|
dispatch(_setLocale(locale));
|
|
|
|
return locale;
|
|
};
|
|
}
|
|
|
|
function _setLocale(locale: string) {
|
|
return {
|
|
type: SET_LOCALE,
|
|
payload: {
|
|
locale,
|
|
},
|
|
};
|
|
}
|