mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Added helper methods for locales.
This commit is contained in:
parent
ef616cc98d
commit
0a8c06b1f8
4 changed files with 18 additions and 10 deletions
|
|
@ -4,7 +4,7 @@ import { setLocale } from 'redux/actions/app';
|
|||
import { useRouter } from 'next/router';
|
||||
import { get, setItem } from 'lib/web';
|
||||
import { LOCALE_CONFIG } from 'lib/constants';
|
||||
import { languages } from 'lib/lang';
|
||||
import { getDateLocale, getTextDirection } from 'lib/lang';
|
||||
import useForceUpdate from 'hooks/useForceUpdate';
|
||||
import enUS from 'public/lang/en-US.json';
|
||||
|
||||
|
|
@ -17,7 +17,8 @@ export default function useLocale() {
|
|||
const dispatch = useDispatch();
|
||||
const { basePath } = useRouter();
|
||||
const forceUpdate = useForceUpdate();
|
||||
const dir = languages[locale]?.dir || 'ltr';
|
||||
const dir = getTextDirection(locale);
|
||||
const dateLocale = getDateLocale(locale);
|
||||
|
||||
async function loadMessages(locale) {
|
||||
const { ok, data } = await get(`${basePath}/lang/${locale}.json`);
|
||||
|
|
@ -47,5 +48,5 @@ export default function useLocale() {
|
|||
}
|
||||
}, [locale]);
|
||||
|
||||
return { locale, saveLocale, messages, dir };
|
||||
return { locale, saveLocale, messages, dir, dateLocale };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue