mirror of
https://github.com/zadam/trilium.git
synced 2025-10-31 19:49:01 +01:00
fix(website): lang/dir not updating after switching language
This commit is contained in:
parent
4f72f81a95
commit
6bde264156
@ -8,7 +8,7 @@ import Footer from './components/Footer.js';
|
||||
import GetStarted from './pages/GetStarted/get-started.js';
|
||||
import SupportUs from './pages/SupportUs/SupportUs.js';
|
||||
import { createContext } from 'preact';
|
||||
import { useRef } from 'preact/hooks';
|
||||
import { useLayoutEffect, useRef } from 'preact/hooks';
|
||||
import { changeLanguage } from 'i18next';
|
||||
import { extractLocaleFromUrl, initTranslations, LOCALES, mapLocale } from './i18n';
|
||||
|
||||
@ -50,6 +50,13 @@ export function LocaleProvider({ children }) {
|
||||
changeLanguage(localeId);
|
||||
}
|
||||
|
||||
// Update html lang and dir attributes
|
||||
useLayoutEffect(() => {
|
||||
const correspondingLocale = LOCALES.find(l => l.id === localeId);
|
||||
document.documentElement.lang = localeId;
|
||||
document.documentElement.dir = correspondingLocale?.rtl ? "rtl" : "ltr";
|
||||
}, [localeId]);
|
||||
|
||||
return (
|
||||
<LocaleContext.Provider value={localeId}>
|
||||
{children}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user