import { useLocale as useDumiLocale } from 'dumi'; export interface LocaleMap< K extends PropertyKey = PropertyKey, V extends string | ((...params: any[]) => string) = string, > { cn: Record; en: Record; } const useLocale = < K extends PropertyKey = PropertyKey, V extends string | ((...params: any[]) => string) = string, >( localeMap?: LocaleMap, ): [Record, 'cn' | 'en'] => { const { id } = useDumiLocale(); const localeType = id === 'zh-CN' ? 'cn' : 'en'; return [localeMap?.[localeType]!, localeType] as const; }; export default useLocale;