fix: translate dynamic menu labels in Navbar and Footer
This commit is contained in:
1 parent
a46fa3f0d4
commit
ef89731c86
2 files changed
+35
-4
No files matched your search
@@ -44,6 +44,21 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' }
|
||||
localStorage.setItem('homaroma_lang', code)
|
||||
setLangSheetOpen(false)
|
||||
}
|
||||
|
||||
const translateMenuLabel = (label: string) => {
|
||||
const map: Record<string, string> = {
|
||||
'Home': 'nav.home',
|
||||
'Shop': 'nav.shop',
|
||||
'Scent Guide': 'nav.scentGuide',
|
||||
'About Us': 'nav.about',
|
||||
'FAQ': 'nav.faq',
|
||||
'Contact': 'nav.contact',
|
||||
'Contact Us': 'nav.contact',
|
||||
'Track Order': 'nav.trackOrder',
|
||||
'Delivery & Returns': 'nav.delivery'
|
||||
}
|
||||
return map[label] ? t(map[label]) : label
|
||||
}
|
||||
// Detect scroll and announcement bar presence
|
||||
useEffect(() => {
|
||||
const checkAnnouncement = () => {
|
||||
@@ -130,7 +145,7 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' }
|
||||
{menuItems.length > 0 ? (
|
||||
menuItems.map(item => (
|
||||
<NavLink key={item.id} to={item.url} end={item.url === '/'} className={navLinkClass}>
|
||||
{item.label}
|
||||
{translateMenuLabel(item.label)}
|
||||
</NavLink>
|
||||
))
|
||||
) : (
|
||||
@@ -418,7 +433,7 @@ export default function Navbar({ categories = [], topOffsetClassName = 'top-0' }
|
||||
{/* Drawer Nav Links */}
|
||||
<div className="flex-1 overflow-y-auto px-4 py-6 space-y-1">
|
||||
{(menuItems.length > 0 ? [
|
||||
...menuItems.map(item => ({ to: item.url, label: item.label, end: item.url === '/' })),
|
||||
...menuItems.map(item => ({ to: item.url, label: translateMenuLabel(item.label), end: item.url === '/' })),
|
||||
...(customer ? [{ to: '/profile', label: `👤 ${t('nav.profile') || 'My Profile'}` }] : []),
|
||||
] : [
|
||||
{ to: '/', label: t('nav.home'), end: true },
|
||||
|
||||
Reference in new issue
Block a user