+
+
+
diff --git a/components/ui/language-switcher.tsx b/components/ui/language-switcher.tsx
new file mode 100644
index 0000000..b7276dd
--- /dev/null
+++ b/components/ui/language-switcher.tsx
@@ -0,0 +1,43 @@
+'use client'
+
+import i18nConfig from '@/i18nConfig'
+import { usePathname, useRouter } from 'next/navigation'
+import { useTransition } from 'react'
+import { Globe } from 'lucide-react'
+
+export function LanguageSwitcher() {
+ const router = useRouter()
+ const pathname = usePathname()
+ const [isPending, startTransition] = useTransition()
+
+ const currentLocale = pathname.split('/')[1] || i18nConfig.defaultLocale
+
+ const handleChange = (e: React.ChangeEvent
) => {
+ const newLocale = e.target.value
+ const segments = pathname.split('/')
+ segments[1] = newLocale
+ const newPath = segments.join('/')
+
+ startTransition(() => {
+ router.push(newPath)
+ })
+ }
+
+ return (
+
+
+
+
+ )
+}
diff --git a/i18nConfig.js b/i18nConfig.js
deleted file mode 100644
index 008f53d..0000000
--- a/i18nConfig.js
+++ /dev/null
@@ -1,25 +0,0 @@
-const i18nConfig = {
- defaultLocale: "en",
- locales: [
- "ar",
- "bn",
- "de",
- "en",
- "es",
- "fr",
- "he",
- "id",
- "it",
- "ja",
- "ko",
- "pt",
- "ru",
- "si",
- "sv",
- "te",
- "vi",
- "zh"
- ]
-}
-
-module.exports = i18nConfig
diff --git a/i18nConfig.ts b/i18nConfig.ts
new file mode 100644
index 0000000..6985533
--- /dev/null
+++ b/i18nConfig.ts
@@ -0,0 +1,30 @@
+const i18nConfig = {
+ defaultLocale: 'en',
+ locales: [
+ 'ar', 'bn', 'de', 'en', 'es', 'fr',
+ 'he', 'id', 'it', 'ja', 'ko', 'pt',
+ 'ru', 'si', 'sv', 'te', 'vi', 'zh'
+ ],
+ languageNames: {
+ ar: 'العربية',
+ bn: 'বাংলা',
+ de: 'Deutsch',
+ en: 'English',
+ es: 'Español',
+ fr: 'Français',
+ he: 'עברית',
+ id: 'Bahasa Indonesia',
+ it: 'Italiano',
+ ja: '日本語',
+ ko: '한국어',
+ pt: 'Português',
+ ru: 'Русский',
+ si: 'සිංහල',
+ sv: 'Svenska',
+ te: 'తెలుగు',
+ vi: 'Tiếng Việt',
+ zh: '中文'
+ }
+} as const
+
+export default i18nConfig
diff --git a/tsconfig.json b/tsconfig.json
index e3e1f45..221b9e3 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -28,7 +28,7 @@
"**/*.tsx",
".next/types/**/*.ts",
"./.next/types/**/*.ts",
- "i18nConfig.js"
+ "i18nConfig.ts"
],
"exclude": ["node_modules"]
}