You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/_util/getLocale.js

31 lines
874 B

export function getComponentLocale(props, context, componentName, getDefaultLocale) {
let locale = {};
7 years ago
if (context && context.antLocale && context.antLocale[componentName]) {
locale = context.antLocale[componentName];
7 years ago
} else {
const defaultLocale = getDefaultLocale();
7 years ago
// TODO: make default lang of antd be English
// https://github.com/ant-design/ant-design/issues/6334
locale = defaultLocale.default || defaultLocale;
7 years ago
}
const result = {
...locale,
...props.locale,
};
7 years ago
result.lang = {
...locale.lang,
...props.locale.lang,
};
return result;
7 years ago
}
export function getLocaleCode(context) {
const localeCode = context.antLocale && context.antLocale.locale;
7 years ago
// Had use LocaleProvide but didn't set locale
if (context.antLocale && context.antLocale.exist && !localeCode) {
return 'zh-cn';
7 years ago
}
return localeCode;
7 years ago
}