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",
"persian": "Persian (Fa)",
"english": "English (En)",
"accountInfo": "Harmony Account - 2025"
"accountInfo": "Harmony Account - {{year}}"
},
"verify": {
"verify": "Verify",

View File

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

View File

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