MCPcopy
hub / github.com/ant-design/ant-design-mobile-rn / getComponentLocale

Function getComponentLocale

components/_util/getLocale.tsx:1–33  ·  view source on GitHub ↗
(
  props: any,
  context: any,
  componentName: string,
  getDefaultLocale: () => any,
)

Source from the content-addressed store, hash-verified

1export 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
35export function getLocaleCode(context: any) {
36 const localeCode = context.antLocale && context.antLocale.locale

Callers 8

Picker.tsxFile · 0.90
renderMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
date-picker.tsxFile · 0.90
renderMethod · 0.90
renderMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected