Files
PrivyDrop/frontend/hooks/useLocale.ts
T
2025-06-22 10:05:00 +08:00

16 lines
401 B
TypeScript

'use client';
// Get the current language
import { usePathname } from 'next/navigation';
import { i18n } from '@/constants/i18n-config'
export function useLocale() {
const pathname = usePathname();
const locale = pathname?.split('/')[1];
// Validate if the language is supported
if (locale && i18n.locales.includes(locale as any)) {
return locale;
}
return i18n.defaultLocale;
}