From 6551b466adf96d7c4da711dd9a33d0ab43ce445b Mon Sep 17 00:00:00 2001 From: Mahyar Khanbolooki Date: Thu, 24 Jul 2025 15:16:54 +0330 Subject: [PATCH] add: SideMenu & BottomNavbar locales --- src/app/[locale]/layout.tsx | 2 +- src/components/menu/SideMenu.tsx | 56 ++++++++++++++-------- src/components/navigation/BottomNavBar.tsx | 14 ++++-- src/locales/fa/common.json | 32 +++++++++++++ 4 files changed, 78 insertions(+), 26 deletions(-) create mode 100644 src/locales/fa/common.json diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 9256933..29bbe70 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -11,7 +11,7 @@ export const metadata: Metadata = { description: 'Webapp dashboard' } -const i18nNamespaces = ['auth']; +const i18nNamespaces = ['auth', 'common']; export default async function RootLayout({ children, diff --git a/src/components/menu/SideMenu.tsx b/src/components/menu/SideMenu.tsx index 242d839..f6e8e74 100644 --- a/src/components/menu/SideMenu.tsx +++ b/src/components/menu/SideMenu.tsx @@ -20,6 +20,7 @@ import Button from '../button/PrimaryButton'; import { useAuthStore } from '@/zustand/authStore'; import { useParams, usePathname, useRouter } from 'next/navigation'; import clsx from 'clsx'; +import { useTranslation } from 'react-i18next'; type MenuItemType = { href: string | undefined; @@ -30,20 +31,20 @@ type MenuItemType = { const menuItems: Array> = [ [ - { href: '/', title: 'اعلان ها', icon: }, - { href: 'my-services', title: 'باشگاه مشتریان', icon: }, - { href: 'services', title: 'کد های تخفیف', icon: }, - { href: 'orders', title: 'لیست سفارشات', icon: }, - { href: 'transactions', title: 'لیست تراکنش ها', icon: }, - { href: '/', title: 'بازی و سرگرمی ها', icon: }, - { href: 'my-services', title: 'معرفی به دوستان', icon: }, - { href: 'services', title: 'گزارش اشکال', icon: }, - { href: 'invoices', title: 'نصب اپلیکیشن', icon: } + { href: '/', title: 'Notifications', icon: }, + { href: 'my-services', title: 'CustomerClub', icon: }, + { href: 'services', title: 'Discounts', icon: }, + { href: 'orders', title: 'Orders', icon: }, + { href: 'transactions', title: 'Transactions', icon: }, + { href: '/', title: 'Games', icon: }, + { href: 'my-services', title: 'ShareWithFriends', icon: }, + { href: 'services', title: 'ReportProblem', icon: }, + { href: 'invoices', title: 'InstallApp', icon: } ], [], [ - { auth: true, href: undefined, title: 'تنظیمات', icon: }, - { auth: true, href: '?logout', title: 'خروج', icon: } + { auth: true, href: undefined, title: 'Preferences', icon: }, + { auth: true, href: '?logout', title: 'Logout', icon: } ] ]; @@ -64,6 +65,12 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS const params = useParams(); const { name } = params; const pathname = usePathname(); + const { t: tMenu } = useTranslation('common', { + keyPrefix: 'SideMenu' + }); + const { t: tLogoutModal } = useTranslation('common', { + keyPrefix: 'LogoutModal' + }); const variants: Variants = { hidden: { x: '100%', transition: { duration: 0.1, ease: 'easeInOut' } }, @@ -95,7 +102,7 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS <>
-
-
+
    {menuItems[2] .filter(item => !item.auth || (item.auth && userIsAuthenticated)) @@ -154,7 +161,8 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS typeof item.href === 'string' ? hrefOnClicks.find((i) => i.href === item.href)?.handler : undefined - } title={item.title} + } + title={tMenu(item.title)} icon={{item.icon}} /> ))} @@ -177,11 +185,19 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS transition={{ duration: 0.1, ease: 'easeInOut' }} className="top-1/2 min-w-xs w-full max-w-sm text-center -translate-y-1/2 px-6 pt-8 pb-9 drop-shadow-container bg-white/63 rounded-4xl" > -

    خروج از سیستم

    -

    آیا میخواهید از سیستم خارج شوید؟

    +

    + {tLogoutModal('Heading')} +

    +

    + {tLogoutModal('Description')} +

    - - + +
    diff --git a/src/components/navigation/BottomNavBar.tsx b/src/components/navigation/BottomNavBar.tsx index 7e7f7dc..e4d8c5c 100644 --- a/src/components/navigation/BottomNavBar.tsx +++ b/src/components/navigation/BottomNavBar.tsx @@ -9,12 +9,16 @@ import BagIcon from '../icons/BagIcon' import HeartIcon from '../icons/HeartIcon' import { useParams, usePathname } from 'next/navigation' import HomeIcon from '../icons/HomeIcon' +import { useTranslation } from 'react-i18next'; function BottomNavBar() { const params = useParams(); const { name } = params; const pathname = usePathname(); const isHomeRoute = pathname === `/${name}`; + const { t } = useTranslation('common', { + keyPrefix: 'BottomNavbar' + }); return (
    @@ -38,8 +42,8 @@ function BottomNavBar() { diff --git a/src/locales/fa/common.json b/src/locales/fa/common.json new file mode 100644 index 0000000..2983799 --- /dev/null +++ b/src/locales/fa/common.json @@ -0,0 +1,32 @@ +{ + "BottomNavbar": { + "Menu": "منو", + "Cart": "سبد خرید", + "Pager": "پیجر", + "Notifications": "اعلان ها", + "Favorites": "پسند ها", + "AriaLabel": "" + }, + "SideMenu": { + "Notifications": "اعلان ها", + "CustomerClub": "باشگاه مشتریان", + "Discounts": "کد های تخفیف", + "Orders": "لیست سفارشات", + "Transactions": "لیست تراکنش ها", + "Games": "بازی و سرگرمی ها", + "ShareWithFriends": "معرفی به دوستان", + "ReportProblem": "گزارش اشکال", + "InstallApp": "نصب اپلیکیشن", + "Preferences": "تنظیمات", + "Logout": "خروج", + "AriaLabel": "منوی کناری", + "NavAriaLabel": "لینک‌های اصلی", + "ControlsAriaLabel": "پایین منو" + }, + "LogoutModal": { + "Heading": "خروج از سیستم", + "Description": "آیا میخواهید از سیستم خارج شوید؟", + "ButtonOk": "بله خارج می‌شوم", + "ButtonCancel": "منصرف شدم" + } +} \ No newline at end of file