[improvement] rename packages dir to src (#3659)

This commit is contained in:
neverland
2019-06-27 11:25:57 +08:00
committed by GitHub
parent 8489918dca
commit 75c79b7044
619 changed files with 21 additions and 21 deletions
+48
View File
@@ -0,0 +1,48 @@
# Internationalization
### Intro
The default language of Vant is Chinese. If you want to use other languages, you can follow the instructions below.
### Switch languages
Vant supports multiple languages with the Locale component, and the `Locale.use` method allows you to switch to diffrent languages.
```js
import { Locale } from 'vant';
import enUS from 'vant/lib/locale/lang/en-US';
Locale.use('en-US', enUS);
```
### Modify default configs
Use `Locale.add` method to modify the default configs.
```js
import { Locale } from 'vant';
const messages = {
'en-US': {
vanPicker: {
confirm: 'Close'
}
}
};
Locale.add(messages);
```
### Config files
Current supported languages:
| Language | Filename |
|------|------|
| Chinese | zh-CN |
| Traditional Chinese (HK) | zh-HK |
| Traditional Chinese (TW) | zh-TW |
| English | en-US |
| Turkish | tr-TR |
View all language configs [Here](https://github.com/youzan/vant/tree/dev/packages/locale/lang).
+34
View File
@@ -0,0 +1,34 @@
import Vue from 'vue';
import { deepAssign } from '../utils/deep-assign';
import defaultMessages from './lang/zh-CN';
declare module 'vue' {
interface VueConstructor {
util: {
defineReactive(obj: object, key: string, value: any): void;
};
}
}
const proto = Vue.prototype;
const { defineReactive } = Vue.util;
defineReactive(proto, '$vantLang', 'zh-CN');
defineReactive(proto, '$vantMessages', {
'zh-CN': defaultMessages
});
export default {
messages() {
return proto.$vantMessages[proto.$vantLang];
},
use(lang: string, messages?: object) {
proto.$vantLang = lang;
this.add({ [lang]: messages });
},
add(messages = {}) {
deepAssign(proto.$vantMessages, messages);
}
};
+68
View File
@@ -0,0 +1,68 @@
export default {
name: 'Name',
tel: 'Phone',
save: 'Save',
confirm: 'Confirm',
cancel: 'Cancel',
delete: 'Delete',
complete: 'Complete',
loading: 'Loading...',
telEmpty: 'Please fill in the tel',
nameEmpty: 'Please fill in the name',
confirmDelete: 'Are you sure you want to delete?',
telInvalid: 'Malformed phone number',
vanContactCard: {
addText: 'Add contact info'
},
vanContactList: {
addText: 'Add new contact'
},
vanPagination: {
prev: 'Previous',
next: 'Next'
},
vanPullRefresh: {
pulling: 'Pull to refresh...',
loosing: 'Loose to refresh...'
},
vanSubmitBar: {
label: 'Total'
},
vanCoupon: {
valid: 'Valid',
unlimited: 'Unlimited',
discount: (discount: number) => `${discount * 10}% off`,
condition: (condition: number) => `At least ${condition}`
},
vanCouponCell: {
title: 'Coupon',
tips: 'Select coupon',
count: (count: number) => `You have ${count} coupons`
},
vanCouponList: {
empty: 'No coupons',
exchange: 'Exchange',
close: 'Close',
enable: 'Available',
disabled: 'Unavailable',
placeholder: 'Coupon code'
},
vanAddressEdit: {
area: 'Area',
postal: 'Postal',
areaEmpty: 'Please select a receiving area',
addressEmpty: 'Address can not be empty',
postalEmpty: 'Wrong postal code',
defaultAddress: 'Set as the default address',
telPlaceholder: 'Phone',
namePlaceholder: 'Name',
areaPlaceholder: 'Area'
},
vanAddressEditDetail: {
label: 'Address',
placeholder: 'Address'
},
vanAddressList: {
add: 'Add new address'
}
};
+68
View File
@@ -0,0 +1,68 @@
export default {
name: 'İsim',
tel: 'Telefon',
save: 'Kaydet',
confirm: 'Onayla',
cancel: 'İptal',
delete: 'Sil',
complete: 'Tamamla',
loading: 'Yükleniyor...',
telEmpty: 'Lütfen tel. no giriniz',
nameEmpty: 'Lütfen isim giriniz',
confirmDelete: 'Silmek istediğinize emin misiniz?',
telInvalid: 'Geçersiz tel. numarası',
vanContactCard: {
addText: 'Kişi bilgisi ekle'
},
vanContactList: {
addText: 'Yeni kişi ekle'
},
vanPagination: {
prev: 'Önceki',
next: 'Sonraki'
},
vanPullRefresh: {
pulling: 'Yenilemek için çekin...',
loosing: 'Yenilemek için bırakın...'
},
vanSubmitBar: {
label: 'Toplam:'
},
vanCoupon: {
valid: 'Geçerli',
unlimited: 'Sınırsız',
discount: (discount: number) => `%${discount * 10} indirim`,
condition: (condition: number) => `En az ${condition}`
},
vanCouponCell: {
title: 'Kupon',
tips: 'Kupon seç',
count: (count: number) => `${count} adet teklif var`
},
vanCouponList: {
empty: 'Kupon yok',
exchange: 'Takas',
close: 'Kapat',
enable: 'Mevcut',
disabled: 'Mevcut değil',
placeholder: 'Kupon kodu'
},
vanAddressEdit: {
area: 'Alan',
postal: 'Posta',
areaEmpty: 'Lütfen alıcı alanını seçin',
addressEmpty: 'Adres boş olamaz!',
postalEmpty: 'Yanlış posta kodu',
defaultAddress: 'Varsayılan adres olarak ayarla',
telPlaceholder: 'Telefone',
namePlaceholder: 'İsim',
areaPlaceholder: 'Alan'
},
vanAddressEditDetail: {
label: 'Adres',
placeholder: 'Adres'
},
vanAddressList: {
add: 'Yeni adres ekle'
}
};
+68
View File
@@ -0,0 +1,68 @@
export default {
name: '姓名',
tel: '电话',
save: '保存',
confirm: '确认',
cancel: '取消',
delete: '删除',
complete: '完成',
loading: '加载中...',
telEmpty: '请填写电话',
nameEmpty: '请填写姓名',
confirmDelete: '确定要删除么',
telInvalid: '请填写正确的电话',
vanContactCard: {
addText: '添加联系人'
},
vanContactList: {
addText: '新建联系人'
},
vanPagination: {
prev: '上一页',
next: '下一页'
},
vanPullRefresh: {
pulling: '下拉即可刷新...',
loosing: '释放即可刷新...'
},
vanSubmitBar: {
label: '合计:'
},
vanCoupon: {
valid: '有效期',
unlimited: '无使用门槛',
discount: (discount: number) => `${discount}`,
condition: (condition: number) => `${condition}元可用`
},
vanCouponCell: {
title: '优惠券',
tips: '使用优惠',
count: (count: number) => `${count}张可用`
},
vanCouponList: {
empty: '暂无优惠券',
exchange: '兑换',
close: '不使用优惠',
enable: '可使用优惠券',
disabled: '不可使用优惠券',
placeholder: '请输入优惠码'
},
vanAddressEdit: {
area: '地区',
postal: '邮政编码',
areaEmpty: '请选择地区',
addressEmpty: '请填写详细地址',
postalEmpty: '邮政编码格式不正确',
defaultAddress: '设为默认收货地址',
telPlaceholder: '收货人手机号',
namePlaceholder: '收货人姓名',
areaPlaceholder: '选择省 / 市 / 区'
},
vanAddressEditDetail: {
label: '详细地址',
placeholder: '街道门牌、楼层房间号等信息'
},
vanAddressList: {
add: '新增地址'
}
};
+68
View File
@@ -0,0 +1,68 @@
export default {
name: '姓名',
tel: '電話',
save: '保存',
confirm: '確認',
cancel: '取消',
delete: '刪除',
complete: '完成',
loading: '加載中...',
telEmpty: '請填寫電話',
nameEmpty: '請填寫姓名',
confirmDelete: '確定要刪除麽',
telInvalid: '請填寫正確的電話',
vanContactCard: {
addText: '添加聯系人'
},
vanContactList: {
addText: '新建聯系人'
},
vanPagination: {
prev: '上一頁',
next: '下一頁'
},
vanPullRefresh: {
pulling: '下拉即可刷新...',
loosing: '釋放即可刷新...'
},
vanSubmitBar: {
label: '合計:'
},
vanCoupon: {
valid: '有效期',
unlimited: '無使用門檻',
discount: (discount: number) => `${discount}`,
condition: (condition: number) => `滿${condition}元可用`
},
vanCouponCell: {
title: '優惠券',
tips: '使用優惠',
count: (count: number) => `${count}張可用`
},
vanCouponList: {
empty: '暫無優惠券',
exchange: '兌換',
close: '不使用優惠',
enable: '可使用優惠券',
disabled: '不可使用優惠券',
placeholder: '請輸入優惠碼'
},
vanAddressEdit: {
area: '地區',
postal: '郵政編碼',
areaEmpty: '請選擇地區',
addressEmpty: '請填寫詳細地址',
postalEmpty: '郵政編碼格式不正確',
defaultAddress: '設為默認收貨地址',
telPlaceholder: '收貨人手機號',
namePlaceholder: '收貨人姓名',
areaPlaceholder: '選擇省 / 市 / 區'
},
vanAddressEditDetail: {
label: '詳細地址',
placeholder: '街道門牌、樓層房間號等信息'
},
vanAddressList: {
add: '新增地址'
}
};
+68
View File
@@ -0,0 +1,68 @@
export default {
name: '姓名',
tel: '電話',
save: '儲存',
confirm: '確認',
cancel: '取消',
delete: '刪除',
complete: '完成',
loading: '載入中...',
telEmpty: '請填寫電話',
nameEmpty: '請填寫姓名',
confirmDelete: '確定要刪除嗎',
telInvalid: '請填寫正確的電話',
vanContactCard: {
addText: '新增聯絡人'
},
vanContactList: {
addText: '建立聯絡人'
},
vanPagination: {
prev: '上一頁',
next: '下一頁'
},
vanPullRefresh: {
pulling: '下拉即可刷新...',
loosing: '釋放即可刷新...'
},
vanSubmitBar: {
label: '合計:'
},
vanCoupon: {
valid: '有效期限',
unlimited: '無使用門檻',
discount: (discount: number) => `${discount}`,
condition: (condition: number) => `滿${condition}元可用`
},
vanCouponCell: {
title: '優惠券',
tips: '使用優惠',
count: (count: number) => `${count}張可用`
},
vanCouponList: {
empty: '暫無優惠券',
exchange: '兌換',
close: '不使用優惠',
enable: '可使用優惠券',
disabled: '不可使用優惠券',
placeholder: '請輸入優惠代碼'
},
vanAddressEdit: {
area: '地區',
postal: '郵遞區號',
areaEmpty: '請選擇地區',
addressEmpty: '請填寫詳細地址',
postalEmpty: '郵遞區號格式不正確',
defaultAddress: '設為預設收貨地址',
telPlaceholder: '收貨人手機號碼',
namePlaceholder: '收貨人姓名',
areaPlaceholder: '選擇縣 / 市'
},
vanAddressEditDetail: {
label: '詳細地址',
placeholder: '街道門牌、樓層房號等資訊'
},
vanAddressList: {
add: '新增地址'
}
};
+48
View File
@@ -0,0 +1,48 @@
# 国际化
### 介绍
Vant 默认采用中文作为语言,如果需要使用其他语言,可以参考下面的方案
### 多语言切换
Vant 通过 Locale 组件实现多语言支持,使用 `Locale.use` 方法可以切换当前使用的语言。
```js
import { Locale } from 'vant';
import enUS from 'vant/lib/locale/lang/en-US';
Locale.use('en-US', enUS);
```
### 修改默认文案
通过 `Locale.add` 方法可以实现文案的修改和扩展,示例如下:
```js
import { Locale } from 'vant';
const messages = {
'zh-CN': {
vanPicker: {
confirm: '关闭' // 将'确认'修改为'关闭'
}
}
};
Locale.add(messages);
```
### 配置文件
目前支持的语言:
| 语言 | 文件名 |
|------|------|
| 简体中文 | zh-CN |
| 繁體中文(港) | zh-HK |
| 繁體中文(台) | zh-TW |
| 英语 | en-US |
| 土耳其语 | tr-TR |
在 [这里](https://github.com/youzan/vant/tree/dev/packages/locale/lang) 查看所有的 i18n 配置文件。