mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 21:19:01 +01:00 
			
		
		
		
	fix(website/i18n): header sometimes not correctly translated
This commit is contained in:
		
							parent
							
								
									a4d92e12be
								
							
						
					
					
						commit
						71cd92e0b5
					
				@ -23,11 +23,14 @@ export function Header(props: {repoStargazersCount: number}) {
 | 
			
		||||
    const locale = useContext(LocaleContext);
 | 
			
		||||
    const [ mobileMenuShown, setMobileMenuShown ] = useState(false);
 | 
			
		||||
 | 
			
		||||
    const HEADER_LINKS = useMemo<HeaderLink[]>(() => [
 | 
			
		||||
    const [ headerLinks, setHeaderLinks ] = useState<HeaderLink[]>([]);
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        setHeaderLinks([
 | 
			
		||||
            { url: "/get-started/", text: t("header.get-started") },
 | 
			
		||||
            { url: "https://docs.triliumnotes.org/", text: t("header.documentation"), external: true },
 | 
			
		||||
            { url: "/support-us/", text: t("header.support-us") }
 | 
			
		||||
    ], [ locale ]);
 | 
			
		||||
        ]);
 | 
			
		||||
    }, [ locale ]);
 | 
			
		||||
 | 
			
		||||
	return (
 | 
			
		||||
		<header>
 | 
			
		||||
@ -50,7 +53,7 @@ export function Header(props: {repoStargazersCount: number}) {
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <nav className={`${mobileMenuShown ? "mobile-shown" : ""}`}>
 | 
			
		||||
                    {HEADER_LINKS.map(link => (
 | 
			
		||||
                    {headerLinks.map(link => (
 | 
			
		||||
                        <Link
 | 
			
		||||
                            href={link.external ? link.url : `/${locale}${link.url}`}
 | 
			
		||||
                            className={url === link.url ? "active" : ""}
 | 
			
		||||
 | 
			
		||||
@ -54,12 +54,13 @@ export function LocaleProvider({ children }) {
 | 
			
		||||
    }).then(() => setLoaded(true))
 | 
			
		||||
}, []);
 | 
			
		||||
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
  useLayoutEffect(() => {
 | 
			
		||||
    if (!loaded) return;
 | 
			
		||||
    changeLanguage(localeId);
 | 
			
		||||
    const correspondingLocale = LOCALES.find(l => l.id === localeId);
 | 
			
		||||
    document.documentElement.lang = localeId;
 | 
			
		||||
    document.documentElement.dir = correspondingLocale?.rtl ? "rtl" : "ltr";
 | 
			
		||||
  }, [ localeId ]);
 | 
			
		||||
  }, [ loaded, localeId ]);
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <LocaleContext.Provider value={localeId}>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user