feat(i18n): migrate route structure under [locale] parameter prefix

This commit is contained in:
Poyraz
2026-06-27 14:42:42 +03:00
parent 968ebb33c5
commit d3c56713fb
3 changed files with 163 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
"use client";
import { useLocale } from "next-intl";
import { useRouter, usePathname } from "@/i18n/routing";
export function LanguageSwitcher() {
const locale = useLocale();
const router = useRouter();
const pathname = usePathname();
const toggleLanguage = () => {
const nextLocale = locale === "tr" ? "en" : "tr";
router.replace(pathname, { locale: nextLocale });
};
return (
<button
onClick={toggleLanguage}
className="inline-flex h-8 min-w-[36px] cursor-pointer items-center justify-center rounded-sm border border-border px-2 text-xs font-semibold text-muted-foreground transition-colors hover:text-foreground"
aria-label={locale === "tr" ? "Switch to English" : "Türkçe'ye geç"}
title={locale === "tr" ? "Switch to English" : "Türkçe'ye geç"}
>
{locale === "tr" ? "EN" : "TR"}
</button>
);
}