diff --git a/src/locale/README.md b/src/locale/README.md index b2844ed7b..34d053770 100644 --- a/src/locale/README.md +++ b/src/locale/README.md @@ -4,18 +4,20 @@ The default language of Vant is Chinese. If you want to use other languages, you can follow the instructions below. +## Usage + ### Switch languages Vant supports multiple languages with the Locale component, and the `Locale.use` method allows you to switch to different languages. ```js import { Locale } from 'vant'; -import enUS from 'vant/lib/locale/lang/en-US'; +import enUS from 'vant/es/locale/lang/en-US'; Locale.use('en-US', enUS); ``` -### Modify default configs +### Override default configs Use `Locale.add` method to modify the default configs. @@ -52,3 +54,7 @@ Current supported languages: | Turkish | tr-TR | > View all language configs [Here](https://github.com/youzan/vant/tree/dev/src/locale/lang). + +### Add new language + +If you can’t find the language you need, please send us a Pull Request to add the new language pack, you can refer to [Add German language pack](https://github.com/youzan/vant/pull/7245) PR. diff --git a/src/locale/README.zh-CN.md b/src/locale/README.zh-CN.md index 7b4b64e44..a34a39ae6 100644 --- a/src/locale/README.zh-CN.md +++ b/src/locale/README.zh-CN.md @@ -2,7 +2,9 @@ ### 介绍 -Vant 默认采用中文作为语言,如果需要使用其他语言,可以参考下面的方案。 +Vant 采用中文作为默认语言,同时支持多语言切换,请按照下方教程进行国际化设置。 + +## 使用方法 ### 多语言切换 @@ -10,12 +12,13 @@ Vant 通过 Locale 组件实现多语言支持,使用 `Locale.use` 方法可 ```js import { Locale } from 'vant'; -import enUS from 'vant/lib/locale/lang/en-US'; +// 引入英文语言包 +import enUS from 'vant/es/locale/lang/en-US'; Locale.use('en-US', enUS); ``` -### 修改默认文案 +### 覆盖语言包 通过 `Locale.add` 方法可以实现文案的修改和扩展,示例如下: @@ -33,7 +36,7 @@ const messages = { Locale.add(messages); ``` -### 配置文件 +### 语言包 目前支持的语言: @@ -51,8 +54,22 @@ Locale.add(messages); | 罗马尼亚语 | ro-RO | | 挪威语 | nb-NO | -> 在 [这里](https://github.com/youzan/vant/tree/dev/src/locale/lang) 查看所有的 i18n 配置文件。 +> 在 [这里](https://github.com/youzan/vant/tree/dev/src/locale/lang) 查看所有的语言包源文件。 -### Sku 组件 +## 常见问题 + +### 找不到所需的语言包? + +如果上方列表中没有你需要的语言,欢迎给我们提 Pull Request 来增加新的语言包,改动内容可以参考[增加德语语言包](https://github.com/youzan/vant/pull/7245) 的 PR。 + +### 业务代码如何实现国际化? + +可以使用 [vue-i18n](https://github.com/kazupon/vue-i18n) 来实现。 + +### 以 CDN 形式引入时,如何使用语言包? + +目前没有提供 CDN 形式的语言包,可以手动拷贝语言包的内容来使用。 + +### 语言包中不包含 Sku 组件? 语言包中默认不包含 Sku 业务组件的语言配置,因此如果有 Sku 组件的国际化需求,请自行配置国际化文案。