mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
17 lines
431 B
TypeScript
17 lines
431 B
TypeScript
import { useLocale as useDumiLocale } from 'dumi';
|
|
|
|
export interface LocaleMap<Key extends string> {
|
|
cn: Record<Key, string>;
|
|
en: Record<Key, string>;
|
|
}
|
|
|
|
function useLocale<Key extends string>(
|
|
localeMap?: LocaleMap<Key>,
|
|
): [Record<Key, string>, 'cn' | 'en'] {
|
|
const { id } = useDumiLocale();
|
|
const localeType = id === 'zh-CN' ? 'cn' : 'en';
|
|
return [localeMap?.[localeType]!, localeType];
|
|
}
|
|
|
|
export default useLocale;
|