fix: update titles in locale files and set document title on language change

This commit is contained in:
2026-06-15 12:29:41 +03:30
parent 744ab78c14
commit 71b8077296
5 changed files with 11 additions and 4 deletions

View File

@@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> -->
<link rel="icon" href="/favicon.ico" sizes="any" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Harmony Accounts</title>
<title>حساب‌های هارمونی</title>
<!-- this script add for preventing initial theme flashing -->
<script>
(function () {

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,4 +1,7 @@
{
"app": {
"title": "Harmony Accounts"
},
"labels": {
"search": "search"
},

View File

@@ -1,4 +1,7 @@
{
"app": {
"title": "حساب‌های هارمونی"
},
"labels": {
"search": "جست و جو"
},

View File

@@ -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;
};