feat: add dynamic year based on locale (Gregorian for EN, Persian for FA)
This commit is contained in:
@@ -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..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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": "درحال انتقال..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
11
src/utils/getYear.ts
Normal 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());
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user