feat: add dynamic year based on locale (Gregorian for EN, Persian for FA)

This commit is contained in:
2026-06-13 11:52:08 +03:30
parent 50b16b5fe0
commit 4efa45b319
4 changed files with 17 additions and 5 deletions

View File

@@ -11,7 +11,7 @@
"googleAuthenticationFailed": "Login with google failed", "googleAuthenticationFailed": "Login with google failed",
"persian": "Persian (Fa)", "persian": "Persian (Fa)",
"english": "English (En)", "english": "English (En)",
"accountInfo": "Harmony Account - 2025" "accountInfo": "Harmony Account - {{year}}"
}, },
"verify": { "verify": {
"verify": "Verify", "verify": "Verify",
@@ -67,4 +67,4 @@
"redirectingTo": "Redirecting to", "redirectingTo": "Redirecting to",
"redirecting": "Redirecting..." "redirecting": "Redirecting..."
} }
} }

View File

@@ -11,7 +11,7 @@
"googleAuthenticationFailed": "ورود با گوگل با خطا مواجه شد", "googleAuthenticationFailed": "ورود با گوگل با خطا مواجه شد",
"persian": "فارسی (Fa)", "persian": "فارسی (Fa)",
"english": "انگلیسی (En)", "english": "انگلیسی (En)",
"accountInfo": "۱۴۰۴-هارمونی اکانت" "accountInfo": "{{year}}-هارمونی اکانت"
}, },
"verify": { "verify": {
"verify": "اعتبارسنجی", "verify": "اعتبارسنجی",
@@ -67,4 +67,4 @@
"redirectingTo": "در حال انتقال به", "redirectingTo": "در حال انتقال به",
"redirecting": "درحال انتقال..." "redirecting": "درحال انتقال..."
} }
} }

View File

@@ -2,6 +2,7 @@ import { Box, Typography, MenuItem, Select, Stack } from '@mui/material';
import { Icon } from '@harmony/kit'; import { Icon } from '@harmony/kit';
import { Global } from 'iconsax-react'; import { Global } from 'iconsax-react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { getYear } from '@/utils/getYear';
export default function LanguageAccountBar() { export default function LanguageAccountBar() {
const { t, i18n } = useTranslation('authentication'); const { t, i18n } = useTranslation('authentication');
@@ -25,7 +26,7 @@ export default function LanguageAccountBar() {
> >
<Stack direction="row" alignItems="center" spacing={1}> <Stack direction="row" alignItems="center" spacing={1}>
<Typography sx={{ pr: 4, color: 'secondary.light' }} variant="body2"> <Typography sx={{ pr: 4, color: 'secondary.light' }} variant="body2">
{t('loginForm.accountInfo')} {t('loginForm.accountInfo', { year: getYear(i18n.language) })}
</Typography> </Typography>
<Icon Component={Global} color="action.active" size="small" /> <Icon Component={Global} color="action.active" size="small" />

11
src/utils/getYear.ts Normal file
View File

@@ -0,0 +1,11 @@
export const getYear = (lang: string) => {
if (lang === 'fa') {
return new Intl.DateTimeFormat('fa-IR-u-ca-persian', {
year: 'numeric',
}).format(new Date());
}
return new Intl.DateTimeFormat('en-US', {
year: 'numeric',
}).format(new Date());
};