summaryrefslogtreecommitdiff
path: root/components/layout/command-menu.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/command-menu.tsx')
-rw-r--r--components/layout/command-menu.tsx26
1 files changed, 15 insertions, 11 deletions
diff --git a/components/layout/command-menu.tsx b/components/layout/command-menu.tsx
index 5537a042..d0c9c49a 100644
--- a/components/layout/command-menu.tsx
+++ b/components/layout/command-menu.tsx
@@ -1,12 +1,13 @@
"use client"
import * as React from "react"
-import { useRouter,usePathname } from "next/navigation"
+import { useRouter, usePathname, useParams } from "next/navigation"
import { type DialogProps } from "@radix-ui/react-dialog"
import { Circle, File, Laptop, Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { MenuSection, mainNav, additionalNav, MenuItem, mainNavVendor, additionalNavVendor } from "@/config/menuConfig";
+import { useTranslation } from "@/i18n/client"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
import {
@@ -24,6 +25,9 @@ export function CommandMenu({ ...props }: DialogProps) {
const router = useRouter()
const [open, setOpen] = React.useState(false)
const { setTheme } = useTheme()
+ const params = useParams()
+ const lng = (params?.lng as string) || "evcp"
+ const { t } = useTranslation(lng, "menu")
React.useEffect(() => {
const down = (e: KeyboardEvent) => {
@@ -81,20 +85,20 @@ const isPartnerRoute = pathname.includes("/partners");
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
- {main.map((group) => (
- <CommandGroup key={group.title} heading={group.title}>
+ {main.map((group: MenuSection) => (
+ <CommandGroup key={group.titleKey} heading={t(group.titleKey)}>
{group.items.map((navItem) => (
<CommandItem
- key={navItem.title}
- value={navItem.title}
+ key={`${navItem.titleKey}:${navItem.href}`}
+ value={t(navItem.titleKey)}
onSelect={() => {
- runCommand(() => router.push(navItem.href as string))
+ runCommand(() => router.push(`/${lng}${navItem.href}`))
}}
>
<div className="mr-2 flex h-4 w-4 items-center justify-center">
<Circle className="h-3 w-3" />
</div>
- {navItem.title}
+ {t(navItem.titleKey)}
</CommandItem>
))}
</CommandGroup>
@@ -104,14 +108,14 @@ const isPartnerRoute = pathname.includes("/partners");
// .filter((navitem) => !navitem.external)
.map((navItem) => (
<CommandItem
- key={navItem.title}
- value={navItem.title}
+ key={`${navItem.titleKey}:${navItem.href}`}
+ value={t(navItem.titleKey)}
onSelect={() => {
- runCommand(() => router.push(navItem.href as string))
+ runCommand(() => router.push(`/${lng}${navItem.href}`))
}}
>
<File />
- {navItem.title}
+ {t(navItem.titleKey)}
</CommandItem>
))}
</CommandGroup>