File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import Footer from './components/Footer.js';
88import GetStarted from './pages/GetStarted/get-started.js' ;
99import SupportUs from './pages/SupportUs/SupportUs.js' ;
1010import { createContext } from 'preact' ;
11- import { useRef } from 'preact/hooks' ;
11+ import { useLayoutEffect , useRef } from 'preact/hooks' ;
1212import { changeLanguage } from 'i18next' ;
1313import { extractLocaleFromUrl , initTranslations , LOCALES , mapLocale } from './i18n' ;
1414
@@ -50,6 +50,13 @@ export function LocaleProvider({ children }) {
5050 changeLanguage ( localeId ) ;
5151 }
5252
53+ // Update html lang and dir attributes
54+ useLayoutEffect ( ( ) => {
55+ const correspondingLocale = LOCALES . find ( l => l . id === localeId ) ;
56+ document . documentElement . lang = localeId ;
57+ document . documentElement . dir = correspondingLocale ?. rtl ? "rtl" : "ltr" ;
58+ } , [ localeId ] ) ;
59+
5360 return (
5461 < LocaleContext . Provider value = { localeId } >
5562 { children }
You can’t perform that action at this time.
0 commit comments