mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 00:27:11 +01:00
Added useLocale hook.
This commit is contained in:
parent
7e26c9571e
commit
52acb691ad
5 changed files with 24 additions and 14 deletions
|
|
@ -1,23 +1,22 @@
|
|||
import React, { useEffect } from 'react';
|
||||
import { IntlProvider } from 'react-intl';
|
||||
import { Provider, useDispatch, useSelector } from 'react-redux';
|
||||
import { Provider } from 'react-redux';
|
||||
import { useStore } from 'redux/store';
|
||||
import { updateApp } from 'redux/actions/app';
|
||||
import useLocale from 'hooks/useLocale';
|
||||
import { messages } from 'lib/lang';
|
||||
import 'styles/variables.css';
|
||||
import 'styles/bootstrap-grid.css';
|
||||
import 'styles/index.css';
|
||||
|
||||
const Intl = ({ children }) => {
|
||||
const dispatch = useDispatch();
|
||||
const locale = useSelector(state => state.app.locale);
|
||||
const [locale, setLocale] = useLocale();
|
||||
|
||||
const Wrapper = ({ children }) => <span className={locale}>{children}</span>;
|
||||
|
||||
useEffect(() => {
|
||||
const saved = localStorage.getItem('locale');
|
||||
if (saved) {
|
||||
dispatch(updateApp({ locale: saved }));
|
||||
setLocale(saved);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue