2016-03-03 16:28:02 +08:00
# LocaleProvider
- category: Components
- chinese: 国际化
- cols: 1
2016-03-10 12:16:27 +08:00
- type: 其它
2016-03-03 16:28:02 +08:00
---
2016-03-03 21:00:38 +08:00
为组件内建文案提供统一的国际化支持。
2016-03-03 16:28:02 +08:00
2016-03-07 15:18:39 +08:00
## 使用
LocaleProvider 使用 React 的 [context ](https://facebook.github.io/react/docs/context.html ) 特性,只需在应用外围包裹一次即可全局生效。
2016-03-03 16:28:02 +08:00
```jsx
2016-03-07 15:18:39 +08:00
import enUS from 'antd/lib/locale-provider/en_US';
...
return < LocaleProvider locale = {enUS} > < App / > < / LocaleProvider > ;
2016-03-03 16:28:02 +08:00
```
### Add a language
2016-03-07 15:18:39 +08:00
We supply an English locale package by now. Other language users can custumize your locale package as [en_US ](https://github.com/ant-design/ant-design/blob/26b1f37392a278285aec6c573b99c6feea09e218/components/locale-provider/en_US.js ) and ask a pull request to us.
### 其他国际化需求
本模块仅用于组件的内建文案,若有业务文案的国际化需求,建议使用 [react-intl ](https://github.com/yahoo/react-intl ),可参考示例:[Intl demo 1](http://github.com/ant-design/intl-example) 和 [Intl demo 2 ](http://yiminghe.me/learning-react/examples/react-intl.html?locale=en-US )。
## API
| 参数 | 说明 | 类型 | 默认值 |
|--------|----------------|------------------|--------------|
| locale | 语言包配置,语言包可到 `antd/lib/locale-provider/` 目录下寻找 | Object | - |