From 5fe28b539c2f44d216ca6b2211c068dabea3eeef Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 14 Dec 2017 17:36:55 +0800 Subject: [PATCH] [Doc] translate AddressList & Contact (#437) --- docs/demos/views/address-list.vue | 50 +++++++++++----- docs/demos/views/contact.vue | 18 +++--- docs/markdown/en-US/address-list.md | 36 ++++++------ docs/markdown/en-US/contact.md | 64 ++++++++++----------- docs/src/doc.config.js | 4 +- packages/address-list/index.vue | 15 +++-- packages/locale/lang/en-US.js | 74 ++++++++++++------------ packages/locale/lang/zh-CN.js | 76 +++++++++++++------------ packages/sku/components/SkuMessages.vue | 8 --- 9 files changed, 185 insertions(+), 160 deletions(-) diff --git a/docs/demos/views/address-list.vue b/docs/demos/views/address-list.vue index c6d56deb5..ded556935 100644 --- a/docs/demos/views/address-list.vue +++ b/docs/demos/views/address-list.vue @@ -3,7 +3,7 @@ @@ -15,16 +15,6 @@ export default { i18n: { 'zh-CN': { - - }, - 'en-US': { - - } - }, - - data() { - return { - chosenAddressId: '1', list: [ { id: '1', @@ -44,16 +34,48 @@ export default { tel: '1320000000', address: '浙江省杭州市滨江区江南大道 15 号' } - ] + ], + add: '新增收货地址', + edit: '编辑收货地址' + }, + 'en-US': { + list: [ + { + id: '1', + name: 'John Snow', + tel: '13000000000', + address: 'Somewhere' + }, + { + id: '2', + name: 'Ned Stark', + tel: '1310000000', + address: 'Somewhere' + }, + { + id: '3', + name: 'Tywin', + tel: '1320000000', + address: 'Somewhere' + } + ], + add: 'Add', + edit: 'Edit' + } + }, + + data() { + return { + chosenAddressId: '1' } }, methods: { onAdd() { - Toast('新增收货地址'); + Toast(this.$t('add')); }, onEdit(item, index) { - Toast('编辑收货地址:' + index); + Toast(this.$t('edit') + ':' + index); } } }; diff --git a/docs/demos/views/contact.vue b/docs/demos/views/contact.vue index 9ee1a7885..f4fc6e6b8 100644 --- a/docs/demos/views/contact.vue +++ b/docs/demos/views/contact.vue @@ -43,10 +43,10 @@ export default { i18n: { 'zh-CN': { - + name: '张三' }, 'en-US': { - + name: 'John Snow' } }, @@ -57,14 +57,18 @@ export default { showList: false, showEdit: false, isEdit: false, - list: [{ - name: '张三', - tel: '13000000000', - id: 0 - }] + list: [] }; }, + created() { + this.list.push({ + name: this.$t('name'), + tel: '13000000000', + id: 0 + }); + }, + computed: { cardType() { return this.chosenContactId !== null ? 'edit' : 'add'; diff --git a/docs/markdown/en-US/address-list.md b/docs/markdown/en-US/address-list.md index cf3856932..2f17e73ae 100644 --- a/docs/markdown/en-US/address-list.md +++ b/docs/markdown/en-US/address-list.md @@ -28,15 +28,15 @@ export default { list: [ { id: '1', - name: '张三', + name: 'John Snow', tel: '13000000000', - address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室' + address: 'Somewhere' }, { id: '2', - name: '李四', + name: 'Ned Stark', tel: '1310000000', - address: '浙江省杭州市拱墅区莫干山路 50 号' + address: 'Somewhere' } ] } @@ -44,10 +44,10 @@ export default { methods: { onAdd() { - Toast('新增收货地址'); + Toast('Add'); }, onEdit(item, index) { - Toast('编辑收货地址:' + index); + Toast('Edit:' + index); } } } @@ -57,23 +57,23 @@ export default { | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| -| v-model | 当前选中地址的 id | String | - | - | -| list | 地址列表 | Array | `[]` | - | -| addButtonText | 底部按钮文字 | String | `新增收货地址` | - | +| v-model | Id of chosen address | String | - | - | +| list | Address list | Array | `[]` | - | +| addButtonText | Add button text | String | `Add new address` | - | ### Event | Event | Description | Attribute | |-----------|-----------|-----------| -| add | 点击新增按钮时触发 | - | -| edit | 点击编辑按钮时触发 | item: 当前地址对象,index: 索引 | -| select | 切换选中的地址时触发 | item: 当前地址对象,index: 索引 | +| add | Triggered when click add button | - | +| edit | Triggered when click edit button | item: address object,index | +| select | Triggered when select address | item: address object,index | + +### Address Data Structure -### Data Structure -#### 地址列表字段说明 | key | Description | Type | |-----------|-----------|-----------| -| id | 每条地址的唯一标识 | `String | Number` | -| name | 收货人姓名 | `String` | -| tel | 收货人手机号 | `String` | -| address | 收货地址 | `String` | +| id | Id | `String | Number` | +| name | Name | `String` | +| tel | Phone | `String` | +| address | Address | `String` | diff --git a/docs/markdown/en-US/contact.md b/docs/markdown/en-US/contact.md index c4ef3ead3..2e1466669 100644 --- a/docs/markdown/en-US/contact.md +++ b/docs/markdown/en-US/contact.md @@ -1,5 +1,4 @@ ## Contact -通过 Contact 组件可以实现联系人的展示、选择、编辑等功能。 ### Install ``` javascript @@ -16,7 +15,7 @@ Vue.use(ContactEdit); ```html - + - + - + item.id !== info.id); @@ -124,7 +123,7 @@ export default { ```html @@ -134,47 +133,44 @@ export default { ### ContactCard API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| -| type | Type,分为添加和编辑两种样式 | `String` | `add` | `edit` | -| addText | 添加时的文案提示 | `String` | `添加订单联系人信息` | - | -| name | 联系人姓名 | `String` | - | - | -| tel | 联系人手机号 | `String` | - | - | +| type | Type | `String` | `add` | `edit` | +| addText | Add card text | `String` | `Add contact info` | - | +| name | Name | `String` | - | - | +| tel | Phone | `String` | - | - | ### ContactList API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| -| v-model | 当前选中联系人的 id | `String | Number` | - | - | -| addText | 新建按钮文案 | `String` | `新建联系人` | - | -| list | 联系人列表 | `Array` | `[]` | - | +| v-model | Id of chosen contact | `String | Number` | - | - | +| addText | Add button text | `String` | `Add new contact` | - | +| list | Contact list | `Array` | `[]` | - | ### ContactList Event | Event | Description | Attribute | |-----------|-----------|-----------| -| add | 点击新增按钮时触发 | - | -| edit | 点击编辑按钮时触发 | item: 当前联系人对象,index: 索引 | -| select | 切换选中的联系人时触发 | item: 当前联系人对象,index: 索引 | - +| add | Triggered when click add button | - | +| edit | Triggered when click edit button | item: contact object,index | +| select | Triggered when select contact | item: contact object | ### ContactEdit API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| -| contactInfo | 联系人信息 | `Object` | `[]` | - | -| isEdit | 是否为编辑联系人 | `Boolean` | `false` | - | -| isSaving | 是否显示保存按钮加载动画 | `Boolean` | `false` | - | -| isDeleting | 是否显示删除按钮加载动画 | `Boolean` | `false` | - | +| contactInfo | Contact Info | `Object` | `[]` | - | +| isEdit | Whether is editing | `Boolean` | `false` | - | +| isSaving | Whether to show save button loading status | `Boolean` | `false` | - | +| isDeleting | Whether to show delete button loading status | `Boolean` | `false` | - | ### ContactEdit Event | Event | Description | Attribute | |-----------|-----------|-----------| -| save | 点击保存按钮时触发 | content:表单内容 | -| delete | 点击删除按钮时触发 | content:表单内容 | +| save | Triggered when click save button | content:contact info | +| delete | Triggered when click delete button | content:contact info | -### Data Structure - -#### 联系人Data Structure +### Contact Data Structure | key | Description | Type | |-----------|-----------|-----------| -| id | 每位联系人的唯一标识 | `String | Number` | -| name | 联系人姓名 | `String` | -| tel | 联系人手机号 | `String` | +| id | ID | `String | Number` | +| name | Name | `String` | +| tel | Phone | `String` | diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js index 3ac593b55..3f95068f0 100644 --- a/docs/src/doc.config.js +++ b/docs/src/doc.config.js @@ -520,7 +520,7 @@ module.exports = { }, { path: '/address-list', - title: 'AddressList (In translation)' + title: 'AddressList' }, { path: '/area', @@ -528,7 +528,7 @@ module.exports = { }, { path: '/contact', - title: 'Contact (In translation)' + title: 'Contact' }, { path: '/coupon', diff --git a/packages/address-list/index.vue b/packages/address-list/index.vue index ee68f68b1..b7b99db90 100644 --- a/packages/address-list/index.vue +++ b/packages/address-list/index.vue @@ -5,13 +5,19 @@
{{ item.name }},{{ item.tel }}
-
收货地址:{{ item.address }}
+
{{ $t('address') }}:{{ item.address }}
- + @@ -33,14 +39,11 @@ export default create({ }, props: { + addButtonText: String, value: [String, Number], list: { type: Array, default: () => [] - }, - addButtonText: { - type: String, - default: '新增收货地址' } } }); diff --git a/packages/locale/lang/en-US.js b/packages/locale/lang/en-US.js index 10b729b37..a7464f7c9 100644 --- a/packages/locale/lang/en-US.js +++ b/packages/locale/lang/en-US.js @@ -3,41 +3,6 @@ export default { cancel: 'Cancel', save: 'Save', complete: 'Complete', - vanAddressEdit: { - areaTitle: 'Area', - areaWrong: 'Please select the correct receiving area', - areaEmpty: 'Please select a receiving area', - nameEmpty: 'Name can not be empty', - nameOverlimit: 'Name length exceeds limit', - telWrong: 'Wrong format of phone number', - addressOverlimit: 'The length of the address can not exceed 200 characters', - addressEmpty: 'Address can not be empty', - postalEmpty: 'Wrong postal code', - defaultAddress: 'Set as the default address', - deleteAddress: 'Delete the address', - confirmDelete: 'Are you sure you want to delete this address?', - label: { - name: 'Receiver', - tel: 'Phone', - postal: 'Postal' - }, - placeholder: { - name: 'Receiver name', - tel: 'Phone', - postal: 'Postal code (optional)', - province: 'Province', - city: 'City', - county: 'County' - } - }, - vanAddressEditDetail: { - label: { - address: 'Address' - }, - placeholder: { - address: 'Address' - } - }, vanContactCard: { name: 'Name', tel: 'Phone', @@ -89,5 +54,44 @@ export default { unlimited: 'Unlimited', discount: discount => `${discount * 10}% off`, condition: condition => `At least ${condition}` + }, + vanAddressEdit: { + areaTitle: 'Area', + areaWrong: 'Please select the correct receiving area', + areaEmpty: 'Please select a receiving area', + nameEmpty: 'Name can not be empty', + nameOverlimit: 'Name length exceeds limit', + telWrong: 'Wrong format of phone number', + addressOverlimit: 'The length of the address can not exceed 200 characters', + addressEmpty: 'Address can not be empty', + postalEmpty: 'Wrong postal code', + defaultAddress: 'Set as the default address', + deleteAddress: 'Delete the address', + confirmDelete: 'Are you sure you want to delete this address?', + label: { + name: 'Receiver', + tel: 'Phone', + postal: 'Postal' + }, + placeholder: { + name: 'Receiver name', + tel: 'Phone', + postal: 'Postal code (optional)', + province: 'Province', + city: 'City', + county: 'County' + } + }, + vanAddressEditDetail: { + label: { + address: 'Address' + }, + placeholder: { + address: 'Address' + } + }, + vanAddressList: { + address: 'Address', + add: 'Add new address' } }; diff --git a/packages/locale/lang/zh-CN.js b/packages/locale/lang/zh-CN.js index 008925f03..e22535a76 100644 --- a/packages/locale/lang/zh-CN.js +++ b/packages/locale/lang/zh-CN.js @@ -3,42 +3,6 @@ export default { cancel: '取消', save: '保存', complete: '完成', - vanAddressEdit: { - areaTitle: '收件地区', - addressText: '收货', - areaWrong: '请选择正确的收件地区', - areaEmpty: '请选择收件地区', - nameEmpty: '请填写名字', - nameOverlimit: '名字过长,请重新输入', - telWrong: '请填写正确的手机号码或电话号码', - addressOverlimit: '详细地址不能超过200个字符', - addressEmpty: '请填写详细地址', - postalEmpty: '邮政编码格式不正确', - defaultAddress: text => `设为默认${text}地址`, - deleteAddress: text => `删除${text}地址`, - confirmDelete: text => `确定要删除这个${text}地址么`, - label: { - name: text => `${text}人`, - tel: '联系电话', - postal: '邮政编码' - }, - placeholder: { - name: '名字', - tel: '手机或固定电话', - postal: '邮政编码(选填)', - province: '选择省', - city: '选择市', - county: '选择区' - } - }, - vanAddressEditDetail: { - label: { - address: '详细地址' - }, - placeholder: { - address: '如街道、楼层、门牌号等' - } - }, vanContactCard: { name: '联系人', tel: '联系电话', @@ -93,5 +57,45 @@ export default { unlimited: '无使用门槛', discount: discount => `${discount}折`, condition: (condition) => `满${condition}元可用` + }, + vanAddressEdit: { + areaTitle: '收件地区', + addressText: '收货', + areaWrong: '请选择正确的收件地区', + areaEmpty: '请选择收件地区', + nameEmpty: '请填写名字', + nameOverlimit: '名字过长,请重新输入', + telWrong: '请填写正确的手机号码或电话号码', + addressOverlimit: '详细地址不能超过200个字符', + addressEmpty: '请填写详细地址', + postalEmpty: '邮政编码格式不正确', + defaultAddress: text => `设为默认${text}地址`, + deleteAddress: text => `删除${text}地址`, + confirmDelete: text => `确定要删除这个${text}地址么`, + label: { + name: text => `${text}人`, + tel: '联系电话', + postal: '邮政编码' + }, + placeholder: { + name: '名字', + tel: '手机或固定电话', + postal: '邮政编码(选填)', + province: '选择省', + city: '选择市', + county: '选择区' + } + }, + vanAddressEditDetail: { + label: { + address: '详细地址' + }, + placeholder: { + address: '如街道、楼层、门牌号等' + } + }, + vanAddressList: { + address: '收货地址', + add: '新增收货地址' } }; diff --git a/packages/sku/components/SkuMessages.vue b/packages/sku/components/SkuMessages.vue index ada187b37..b58a8bced 100644 --- a/packages/sku/components/SkuMessages.vue +++ b/packages/sku/components/SkuMessages.vue @@ -49,13 +49,6 @@ export default { }; }, - // for debug - // watch: { - // messageValues() { - // console.log(this.messageValues); - // } - // }, - computed: { internalMessages() { if (Object.prototype.toString.call(this.messages) === '[object Array]') { @@ -115,7 +108,6 @@ export default { if (message.required == '1') { // eslint-disable-line if (message.type === 'image') { continue; - // return `请上传${message.name}`; } else { return `请填写${message.name}`; }