feat: implement internationalization support by updating locale files and adding language switch component
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
export default function LanguageSwitch() {
|
||||
const pathname = usePathname();
|
||||
|
||||
const pathWithoutLocale = pathname.replace(/^\/(en|fa)/, '');
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center">
|
||||
<Link
|
||||
href={`/en${pathWithoutLocale === '/' ? '' : pathWithoutLocale}`}
|
||||
className="mx-2 text-gray-800 hover:text-blue-500"
|
||||
>
|
||||
EN
|
||||
</Link>
|
||||
<span className="text-gray-800">|</span>
|
||||
<Link
|
||||
href={`/fa${pathWithoutLocale === '/' ? '' : pathWithoutLocale}`}
|
||||
className="mx-2 text-gray-800 hover:text-blue-500"
|
||||
>
|
||||
FA
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user