mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
0aabdb3d8b
* fix: locale should follow LocaleProvider, close: #4495 * test: update snapshot * fix: fix some bugs
20 lines
672 B
TypeScript
20 lines
672 B
TypeScript
import assign from 'object-assign';
|
|
|
|
export function getComponentLocale(props, context, componentName, getDefaultLocale) {
|
|
const locale = context && context.antLocale && context.antLocale[componentName] ?
|
|
context.antLocale[componentName] : getDefaultLocale();
|
|
|
|
const result = assign({}, locale, props.locale);
|
|
result.lang = assign({}, locale.lang, props.locale.lang);
|
|
return result;
|
|
}
|
|
|
|
export function getLocaleCode(context) {
|
|
const localeCode = context.antLocale && context.antLocale.locale;
|
|
// Had use LocaleProvide but didn't set locale
|
|
if (context.antLocale && context.antLocale.exist && !localeCode) {
|
|
return 'zh-cn';
|
|
}
|
|
return localeCode;
|
|
}
|