mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 19:50:05 +08:00
4b045fc43f
This reverts commit 89228118af
.
The original purpose to import locale from src is that some projects
adding `jsnext:main` to the `resolve.mainFields` config of webpack which leads
webpack load moment from `src/moment.js`. But import from `locale`
should works for most projects.
1.8 KiB
1.8 KiB
category | type | cols | title |
---|---|---|---|
Components | Other | 1 | LocaleProvider |
LocaleProvider
provides a uniform localization support for built-in text of components.
Usage
LocaleProvider
takes use of context, a feature of React, to accomplish global effectiveness by wrapping the app only once.
import { LocaleProvider } from 'antd';
import fr_FR from 'antd/lib/locale-provider/fr_FR';
import 'moment/locale/fr';
...
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.
Note: if you need to use antd's UMD dist file, please use antd/dist/antd-with-locales.js
and corresponding moment locale:
const { LocaleProvider, locales } = window.antd;
...
return <LocaleProvider locale={locales.fr_FR}><App /></LocaleProvider>;
Add a new language
If you can't find your language, you are welcome to create a locale package based on en_US 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, refer to Intl demo 1 and Intl demo 2.
API
Property | Description | Type | Default |
---|---|---|---|
locale | language package setting, you can find the packages in this path: antd/lib/locale-provider/ |
object | - |