Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 573c80b

Browse files
committed
Fix internationalization example
1 parent 2032a52 commit 573c80b

File tree

1 file changed

+69
-6
lines changed

1 file changed

+69
-6
lines changed

src/components/Calendar/README.md

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,75 @@
33
```jsx inside Markdown
44
import * as locales from 'react-date-range/dist/locale';
55

6-
const [locale, setLocale] = React.useState('ja');
6+
const nameMapper = {
7+
ar: 'Arabic',
8+
bg: 'Bulgarian',
9+
ca: 'Catalan',
10+
cs: 'Czech',
11+
cy: 'Welsh',
12+
da: 'Danish',
13+
de: 'German',
14+
el: 'Greek',
15+
enGB: 'English (United Kingdom)',
16+
enUS: 'English (United States)',
17+
eo: 'Esperanto',
18+
es: 'Spanish',
19+
et: 'Estonian',
20+
faIR: 'Persian',
21+
fi: 'Finnish',
22+
fil: 'Filipino',
23+
fr: 'French',
24+
hi: 'Hindi',
25+
hr: 'Croatian',
26+
hu: 'Hungarian',
27+
hy: 'Armenian',
28+
id: 'Indonesian',
29+
is: 'Icelandic',
30+
it: 'Italian',
31+
ja: 'Japanese',
32+
ka: 'Georgian',
33+
ko: 'Korean',
34+
lt: 'Lithuanian',
35+
lv: 'Latvian',
36+
mk: 'Macedonian',
37+
nb: 'Norwegian Bokmål',
38+
nl: 'Dutch',
39+
pl: 'Polish',
40+
pt: 'Portuguese',
41+
ro: 'Romanian',
42+
ru: 'Russian',
43+
sk: 'Slovak',
44+
sl: 'Slovenian',
45+
sr: 'Serbian',
46+
sv: 'Swedish',
47+
th: 'Thai',
48+
tr: 'Turkish',
49+
uk: 'Ukrainian',
50+
vi: 'Vietnamese',
51+
zhCN: 'Chinese Simplified',
52+
zhTW: 'Chinese Traditional'
53+
};
754

8-
<Calendar
9-
locale={locales[locale]}
10-
date={null}
11-
className={'PreviewArea'}
12-
/>
55+
const localeOptions = Object.keys(locales)
56+
.map(key => ({
57+
value: key,
58+
label: `${key} - ${nameMapper[key] || ''}`
59+
}))
60+
.filter(item => nameMapper[item.value]);
1361

62+
const [locale, setLocale] = React.useState('ja');
63+
<div style={{ display: 'flex', flexFlow: 'column nowrap' }}>
64+
<select
65+
style={{ margin: '20px auto' }}
66+
onChange={e => setLocale(e.target.value)}
67+
value={locale}
68+
>
69+
{localeOptions.map((option, i) => (
70+
<option value={option.value} key={i}>
71+
{option.label}
72+
</option>
73+
))}
74+
</select>
75+
<Calendar locale={locales[locale]} date={null} />
76+
</div>;
1477
```

0 commit comments

Comments
 (0)