mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
17 lines
462 B
JavaScript
17 lines
462 B
JavaScript
import { useDispatch, useSelector } from 'react-redux';
|
|
import { updateApp } from 'redux/actions/app';
|
|
import { setItem } from 'lib/web';
|
|
import { LOCALE_CONFIG } from 'lib/constants';
|
|
|
|
export default function useLocale() {
|
|
const locale = useSelector(state => state.app.locale);
|
|
const dispatch = useDispatch();
|
|
|
|
function setLocale(value) {
|
|
setItem(LOCALE_CONFIG, value);
|
|
dispatch(updateApp({ locale: value }));
|
|
}
|
|
|
|
return [locale, setLocale];
|
|
}
|