docs: LocaleProvider translation (#2532)

pull/2537/head
ddcat1115 9 years ago committed by Benjy Cui
parent 2af8f6f95c
commit 634e836e8d

@ -1,10 +1,18 @@
---
order: 2
title: 所有组件
title:
zh-CN: 所有组件
en-US: All components
---
## zh-CN
此处列出 Ant Design 中需要国际化支持的组件,你可以在演示里切换语言。
## en-US
Components which need localization support are listed here, you can toggle the language in the demo.
````jsx
import { LocaleProvider, Pagination, DatePicker, TimePicker, Calendar,
Popconfirm, Table, Modal, Button, Select, Transfer, Radio } from 'antd';

@ -1,10 +1,18 @@
---
order: 1
title: 国际化
title:
zh-CN: 国际化
en-US: Localization
---
## zh-CN
`LocaleProvider` 包裹你的应用,并引用对应的语言包。
## en-US
Wrap you app with `LocaleProvider`, and apply the corresponding language package.
````jsx
import { Pagination, LocaleProvider } from 'antd';
import enUS from 'antd/lib/locale-provider/en_US';

@ -0,0 +1,35 @@
---
category: Components
type: Other
cols: 1
title: LocaleProvider
---
`LocaleProvider` provides a uniform localization support for built-in text of components.
## Usage
`LocaleProvider` takes use of [context](https://facebook.github.io/react/docs/context.html), a feature of React, to accomplish global effectiveness by wrapping the app only once.
```jsx
import enUS from 'antd/lib/locale-provider/en_US';
...
return <LocaleProvider locale={enUS}><App /></LocaleProvider>;
```
### Add a language
We supply an English locale package. Other language users can create a locale package based on [en_US](https://github.com/ant-design/ant-design/blob/26b1f37392a278285aec6c573b99c6feea09e218/components/locale-provider/en_US.js) and send us a pull request.
### Other localization needs
This component aims for localization of the built-in text, if you want to support other documents, we recommend using [react-intl](https://github.com/yahoo/react-intl), refer to [Intl demo 1](http://github.com/ant-design/intl-example) and [Intl demo 2](http://yiminghe.me/learning-react/examples/react-intl.html?locale=en-US).
## API
Property | Description | Type | Default
-----|-----|-----|------
locale | language package setting, you can find the packages in this path: `antd/lib/locale-provider/` | Object | -
Loading…
Cancel
Save