mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 04:29: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 GetStarted from './pages/GetStarted/get-started.js';
|
||||||
import SupportUs from './pages/SupportUs/SupportUs.js';
|
import SupportUs from './pages/SupportUs/SupportUs.js';
|
||||||
import { createContext } from 'preact';
|
import { createContext } from 'preact';
|
||||||
import { useRef } from 'preact/hooks';
|
import { useLayoutEffect, useRef } from 'preact/hooks';
|
||||||
import { changeLanguage } from 'i18next';
|
import { changeLanguage } from 'i18next';
|
||||||
import { extractLocaleFromUrl, initTranslations, LOCALES, mapLocale } from './i18n';
|
import { extractLocaleFromUrl, initTranslations, LOCALES, mapLocale } from './i18n';
|
||||||
|
|
||||||
@ -50,6 +50,13 @@ export function LocaleProvider({ children }) {
|
|||||||
changeLanguage(localeId);
|
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 (
|
return (
|
||||||
<LocaleContext.Provider value={localeId}>
|
<LocaleContext.Provider value={localeId}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user