( props: any, context: any, componentName: string, getDefaultLocale: () => any, )
| 1 | export function getComponentLocale( |
| 2 | props: any, |
| 3 | context: any, |
| 4 | componentName: string, |
| 5 | getDefaultLocale: () => any, |
| 6 | ) { |
| 7 | let locale: any = {} |
| 8 | if (context && context.antLocale && context.antLocale[componentName]) { |
| 9 | locale = context.antLocale[componentName] |
| 10 | } else { |
| 11 | const defaultLocale = getDefaultLocale() |
| 12 | // TODO: make default lang of antd be English |
| 13 | // https://github.com/ant-design/ant-design/issues/6334 |
| 14 | locale = defaultLocale.default || defaultLocale |
| 15 | } |
| 16 | |
| 17 | let result = { |
| 18 | ...locale, |
| 19 | } |
| 20 | if (props.locale) { |
| 21 | result = { |
| 22 | ...result, |
| 23 | ...props.locale, |
| 24 | } |
| 25 | if (props.locale.lang) { |
| 26 | result.lang = { |
| 27 | ...locale.lang, |
| 28 | ...props.locale.lang, |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | return result |
| 33 | } |
| 34 | |
| 35 | export function getLocaleCode(context: any) { |
| 36 | const localeCode = context.antLocale && context.antLocale.locale |
no outgoing calls
no test coverage detected