fix: 🐛 Change Page direction based on the language dir property

This commit is contained in:
Mohanad Alrwaihy 2024-02-29 23:10:41 +03:00
parent 3e45c9d055
commit 354da4bc56

View File

@ -5,6 +5,7 @@ import { ReactBasicsProvider } from 'react-basics';
import ErrorBoundary from 'components/common/ErrorBoundary'; import ErrorBoundary from 'components/common/ErrorBoundary';
import { useLocale } from 'components/hooks'; import { useLocale } from 'components/hooks';
import 'chartjs-adapter-date-fns'; import 'chartjs-adapter-date-fns';
import { useEffect } from 'react';
const client = new QueryClient({ const client = new QueryClient({
defaultOptions: { defaultOptions: {
@ -16,7 +17,13 @@ const client = new QueryClient({
}); });
function MessagesProvider({ children }) { function MessagesProvider({ children }) {
const { locale, messages } = useLocale(); const { locale, messages, dir } = useLocale();
useEffect(() => {
document.documentElement.setAttribute('dir', dir);
document.documentElement.setAttribute('lang', locale);
}, [locale, dir]);
return ( return (
<IntlProvider locale={locale} messages={messages[locale]} onError={() => null}> <IntlProvider locale={locale} messages={messages[locale]} onError={() => null}>
{children} {children}