docs: Improve LocalProvider document

Close #8691
This commit is contained in:
Wei Zhu 2017-12-28 17:17:24 +08:00
parent 5881621f01
commit 18ba398f95
2 changed files with 10 additions and 7 deletions

View File

@ -13,23 +13,24 @@ title: LocaleProvider
```jsx
import { LocaleProvider } from 'antd';
import enUS from 'antd/lib/locale-provider/en_US';
import fr_FR from 'antd/lib/locale-provider/fr_FR';
import 'moment/locale/fr';
...
return <LocaleProvider locale={enUS}><App /></LocaleProvider>;
return <LocaleProvider locale={fr_FR}><App /></LocaleProvider>;
```
We provide some locale like English, Chinese, Russian, German, French and etc, all locale packages can be found in [here](https://github.com/ant-design/ant-design/blob/master/components/locale-provider/).
Note: if you need to use antd's UMD dist file, please import `antd/dist/antd-with-locales.js`:
Note: if you need to use antd's UMD dist file, please use `antd/dist/antd-with-locales.js` and corresponding moment locale:
```jsx
const { LocaleProvider, locales } = window.antd;
...
return <LocaleProvider locale={locales.en_US}><App /></LocaleProvider>;
return <LocaleProvider locale={locales.fr_FR}><App /></LocaleProvider>;
```
### Add a new language

View File

@ -13,16 +13,18 @@ title: LocaleProvider
LocaleProvider 使用 React 的 [context](https://facebook.github.io/react/docs/context.html) 特性,只需在应用外围包裹一次即可全局生效。
```jsx
import enUS from 'antd/lib/locale-provider/en_US';
import { LocaleProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
import 'moment/locale/zh-cn';
...
return <LocaleProvider locale={enUS}><App /></LocaleProvider>;
return <LocaleProvider locale={zh_CN}><App /></LocaleProvider>;
```
我们提供了英语,中文,俄语,法语,德语等多种语言支持,所有语言包可以在 [这里](https://github.com/ant-design/ant-design/blob/master/components/locale-provider/) 找到。
注意:如果你需要使用 UMD 版的 dist 文件,应该引入 `antd/dist/antd-with-locales.js`,然后按以下方式使用:
注意:如果你需要使用 UMD 版的 dist 文件,应该引入 `antd/dist/antd-with-locales.js`同时引入 moment 对应的 locale然后按以下方式使用:
```jsx
const { LocaleProvider, locales } = window.antd;