Files
PrivyDrop/frontend/hooks/useLocale.ts
T
2025-05-23 22:41:56 +08:00

16 lines
389 B
TypeScript

'use client';
//获取当前语言bn
import { usePathname } from 'next/navigation';
import { i18n } from '@/constants/i18n-config'
export function useLocale() {
const pathname = usePathname();
const locale = pathname?.split('/')[1];
// 验证是否为支持的语言
if (locale && i18n.locales.includes(locale as any)) {
return locale;
}
return i18n.defaultLocale;
}