translation bug fixed
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { Menu, X } from "lucide-react";
|
||||
import { motion } from "framer-motion";
|
||||
import { useTranslations } from "next-intl";
|
||||
import LanguageSwitcher from "./languageSwitcher";
|
||||
import { useLanguage } from "@/context/language-context";
|
||||
|
||||
interface NavLink {
|
||||
id: string;
|
||||
@@ -19,20 +19,15 @@ interface NavbarProps {
|
||||
|
||||
export function Navbar({ logoText = "FIRMA" }: NavbarProps) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const t = useTranslations();
|
||||
const pathname = usePathname();
|
||||
const { t } = useLanguage();
|
||||
|
||||
const navLinks: NavLink[] = [
|
||||
{ id: "about", labelKey: "nav.about", href: "#about" },
|
||||
{ id: "products", labelKey: "nav.products", href: "#products" },
|
||||
{ id: "faq", labelKey: "nav.faq", href: "#faq" },
|
||||
{ id: "contact", labelKey: "nav.contact", href: "#contact" },
|
||||
{ id: "about", labelKey: t.nav.about, href: "#about" },
|
||||
{ id: "products", labelKey: t.nav.products, href: "#products" },
|
||||
{ id: "faq", labelKey: t.nav.faq, href: "#faq" },
|
||||
{ id: "contact", labelKey: t.nav.contact , href: "#contact" },
|
||||
];
|
||||
|
||||
const locale = pathname.split("/")[1];
|
||||
const otherLocale = locale === "uz" ? "ru" : "uz";
|
||||
const otherPath = pathname.replace(`/${locale}`, `/${otherLocale}`);
|
||||
|
||||
const handleScroll = (href: string) => {
|
||||
if (href.startsWith("#")) {
|
||||
const element = document.querySelector(href);
|
||||
@@ -50,7 +45,7 @@ export function Navbar({ logoText = "FIRMA" }: NavbarProps) {
|
||||
{/* Logo */}
|
||||
<motion.div whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }}>
|
||||
<Link
|
||||
href={`/${locale}`}
|
||||
href={`/`}
|
||||
className="text-2xl font-bold bg-linear-to-r from-blue-600 to-blue-800 bg-clip-text text-transparent"
|
||||
>
|
||||
{logoText}
|
||||
@@ -66,21 +61,14 @@ export function Navbar({ logoText = "FIRMA" }: NavbarProps) {
|
||||
onClick={() => handleScroll(link.href)}
|
||||
className="text-gray-700 hover:text-blue-600 transition-colors"
|
||||
>
|
||||
{t(link.labelKey)}
|
||||
{link.labelKey}
|
||||
</motion.button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Language & Mobile Menu */}
|
||||
<div className="flex items-center gap-4">
|
||||
<motion.a
|
||||
href={otherPath}
|
||||
whileHover={{ scale: 1.1 }}
|
||||
whileTap={{ scale: 0.95 }}
|
||||
className="px-3 py-1 bg-blue-600 text-white rounded-full text-sm font-medium hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
{otherLocale.toUpperCase()}
|
||||
</motion.a>
|
||||
<LanguageSwitcher />
|
||||
|
||||
{/* Mobile Menu Button */}
|
||||
<button
|
||||
@@ -106,7 +94,7 @@ export function Navbar({ logoText = "FIRMA" }: NavbarProps) {
|
||||
onClick={() => handleScroll(link.href)}
|
||||
className="block w-full text-left px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition-colors"
|
||||
>
|
||||
{t(link.labelKey)}
|
||||
{link.labelKey}
|
||||
</button>
|
||||
))}
|
||||
</motion.div>
|
||||
|
||||
Reference in New Issue
Block a user