fix: update titles in locale files and set document title on language change
This commit is contained in:
@@ -6,12 +6,13 @@ import { useTranslation } from 'react-i18next';
|
||||
* side effects to the document. It renders no visible UI.
|
||||
*/
|
||||
export const LanguageManager = () => {
|
||||
const { i18n } = useTranslation();
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const handleLanguageChange = (lng: string) => {
|
||||
document.documentElement.setAttribute('dir', i18n.dir(lng));
|
||||
document.documentElement.setAttribute('lang', lng);
|
||||
document.title = t('app.title', { lng });
|
||||
};
|
||||
|
||||
// Set initial values on component mount
|
||||
@@ -24,7 +25,7 @@ export const LanguageManager = () => {
|
||||
return () => {
|
||||
i18n.off('languageChanged', handleLanguageChange);
|
||||
};
|
||||
}, [i18n]);
|
||||
}, [i18n, t]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user