[Improvement] Locale: optimize i18 config (#701)

This commit is contained in:
neverland 2018-03-16 13:31:19 +08:00 committed by GitHub
parent 966c8afce0
commit f26ad3b912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 65 additions and 108 deletions

View File

@ -98,7 +98,7 @@ export default {
| address_detail | Detailed Address | `String` | | address_detail | Detailed Address | `String` |
| area_code | Area code | `String` | | area_code | Area code | `String` |
| postal_code | Postal code | `String` | | postal_code | Postal code | `String` |
| is_default | Is default address | `String` | | is_default | Is default address | `Boolean` |
#### searchResult Data Structure #### searchResult Data Structure
| key | Description | Type | | key | Description | Type |

View File

@ -101,7 +101,7 @@ export default {
| address_detail | 详细地址 | `String` | | address_detail | 详细地址 | `String` |
| area_code | 地区编码,通过省市区选择获取 | `String` | | area_code | 地区编码,通过省市区选择获取 | `String` |
| postal_code | 邮政编码 | `String` | | postal_code | 邮政编码 | `String` |
| is_default | 是否为默认地址 | `String` | | is_default | 是否为默认地址 | `Boolean` |
#### searchResult 数据格式 #### searchResult 数据格式
| key | 说明 | 类型 | | key | 说明 | 类型 |

View File

@ -131,7 +131,7 @@ export default {
| show-toolbar | 是否显示顶部栏 | `Boolean` | `false` | - | | show-toolbar | 是否显示顶部栏 | `Boolean` | `false` | - |
| title | 顶部栏标题 | `String` | `''` | - | | title | 顶部栏标题 | `String` | `''` | - |
| loading | 是否显示加载状态 | `Boolean` | `false` | - | | loading | 是否显示加载状态 | `Boolean` | `false` | - |
| confirm-button-text | 确认按钮文字 | `String` | `完成` | - | | confirm-button-text | 确认按钮文字 | `String` | `确认` | - |
| cancel-button-text | 取消按钮文字 | `String` | `取消` | - | | cancel-button-text | 取消按钮文字 | `String` | `取消` | - |
| item-height | 选项高度 | `Number` | `44` | - | | item-height | 选项高度 | `Number` | `44` | - |
| visible-item-count | 可见的选项个数 | `Number` | `5` | - | | visible-item-count | 可见的选项个数 | `Number` | `5` | - |

View File

@ -1,8 +1,8 @@
<template> <template>
<div ref="root"> <div ref="root">
<field <field
:label="$t('label.address')" :label="$t('label')"
:placeholder="$t('placeholder.address')" :placeholder="$t('placeholder')"
maxlength="200" maxlength="200"
type="textarea" type="textarea"
autosize autosize

View File

@ -3,7 +3,7 @@
<cell-group> <cell-group>
<field <field
maxlength="15" maxlength="15"
:placeholder="$t('placeholder.name')" :placeholder="$t('name')"
:label="$t('label.name', computedAddressText)" :label="$t('label.name', computedAddressText)"
v-model="currentInfo.name" v-model="currentInfo.name"
:error="errorInfo.name" :error="errorInfo.name"
@ -11,8 +11,8 @@
/> />
<field <field
type="tel" type="tel"
:label="$t('label.tel')" :label="$t('tel')"
:placeholder="$t('placeholder.tel')" :placeholder="$t('telPlaceholder')"
v-model="currentInfo.tel" v-model="currentInfo.tel"
:error="errorInfo.tel" :error="errorInfo.tel"
@focus="onFocus('tel')" @focus="onFocus('tel')"
@ -20,12 +20,12 @@
<cell <cell
clickable clickable
class="van-address-edit__area" class="van-address-edit__area"
:title="$t('areaTitle')" :title="$t('area')"
@click="showAreaSelect = true" @click="showArea = true"
> >
<span>{{ currentInfo.province || $t('placeholder.province') }}</span> <span>{{ currentInfo.province || $t('province') }}</span>
<span>{{ currentInfo.city || $t('placeholder.city') }}</span> <span>{{ currentInfo.city || $t('city') }}</span>
<span>{{ currentInfo.county || $t('placeholder.county') }}</span> <span>{{ currentInfo.county || $t('county') }}</span>
</cell> </cell>
<address-edit-detail <address-edit-detail
:value="currentInfo.address_detail" :value="currentInfo.address_detail"
@ -65,14 +65,14 @@
{{ $t('deleteAddress', computedAddressText) }} {{ $t('deleteAddress', computedAddressText) }}
</van-button> </van-button>
</div> </div>
<popup v-model="showAreaSelect" position="bottom"> <popup v-model="showArea" position="bottom">
<van-area <van-area
ref="area" ref="area"
:loading="!areaListLoaded" :loading="!areaListLoaded"
:value="currentInfo.area_code" :value="currentInfo.area_code"
:area-list="areaList" :area-list="areaList"
@confirm="onAreaConfirm" @confirm="onAreaConfirm"
@cancel="showAreaSelect = false" @cancel="showArea = false"
/> />
</popup> </popup>
</div> </div>
@ -143,7 +143,7 @@ export default create({
data() { data() {
return { return {
showAreaSelect: false, showArea: false,
currentInfo: { currentInfo: {
...defaultAddress, ...defaultAddress,
...this.addressInfo ...this.addressInfo
@ -214,11 +214,11 @@ export default create({
}, },
onAreaConfirm(values) { onAreaConfirm(values) {
if (values.length !== 3 || +values[0].code === -1 || +values[1].code === -1 || +values[2].code === -1) { if (values.length !== 3 || values.some(value => +value.code === -1)) {
return Toast(this.$t('areaWrong')); return Toast(this.$t('areaEmpty'));
} }
this.assignAreaValues(values); this.assignAreaValues(values);
this.showAreaSelect = false; this.showArea = false;
this.$emit('change-area', values); this.$emit('change-area', values);
}, },
@ -265,9 +265,9 @@ export default create({
case 'name': case 'name':
return value ? value.length <= 15 ? '' : $t('nameOverlimit') : $t('nameEmpty'); return value ? value.length <= 15 ? '' : $t('nameOverlimit') : $t('nameEmpty');
case 'tel': case 'tel':
return this.telValidator(value) ? '' : $t('telWrong'); return this.telValidator(value) ? '' : $t('telInvalid');
case 'area_code': case 'area_code':
return value ? +value !== -1 ? '' : $t('areaWrong') : $t('areaEmpty'); return value && +value !== -1 ? '' : $t('areaEmpty');
case 'address_detail': case 'address_detail':
return value ? value.length <= 200 ? '' : $t('addressOverlimit') : $t('addressEmpty'); return value ? value.length <= 200 ? '' : $t('addressOverlimit') : $t('addressEmpty');
case 'postal_code': case 'postal_code':

View File

@ -8,7 +8,7 @@
<template v-else-if="type === 'edit'"> <template v-else-if="type === 'edit'">
<icon class="van-contact-card__icon" name="contact" /> <icon class="van-contact-card__icon" name="contact" />
<div class="van-contact-card__text"> <div class="van-contact-card__text">
<div>{{ $t('name') }}{{ name }}</div> <div>{{ $t('contact') }}{{ name }}</div>
<div>{{ $t('tel') }}{{ tel }}</div> <div>{{ $t('tel') }}{{ tel }}</div>
</div> </div>
</template> </template>

View File

@ -4,8 +4,8 @@
<field <field
v-model="currentInfo.name" v-model="currentInfo.name"
maxlength="30" maxlength="30"
:label="$t('name')" :label="$t('contact')"
:placeholder="$t('namePlaceholder')" :placeholder="$t('name')"
:error="errorInfo.name" :error="errorInfo.name"
@focus="onFocus('name')" @focus="onFocus('name')"
/> />

View File

@ -4,7 +4,7 @@
<cell-group> <cell-group>
<cell v-for="(item, index) in list" :key="item.id" is-link> <cell v-for="(item, index) in list" :key="item.id" is-link>
<radio :name="item.id" @click="$emit('select', item, index)"> <radio :name="item.id" @click="$emit('select', item, index)">
<p class="van-contact-list__text">{{ $t('name') }}{{ item.name }}</p> <p class="van-contact-list__text">{{ $t('contact') }}{{ item.name }}</p>
<p class="van-contact-list__text">{{ $t('tel') }}{{ item.tel }}</p> <p class="van-contact-list__text">{{ $t('tel') }}{{ item.tel }}</p>
</radio> </radio>
<icon slot="right-icon" name="edit" class="van-contact-list__edit" @click="$emit('edit', item, index)" /> <icon slot="right-icon" name="edit" class="van-contact-list__edit" @click="$emit('edit', item, index)" />

View File

@ -1,28 +1,26 @@
export default { export default {
confirm: 'Confirm',
cancel: 'Cancel',
save: 'Save',
complete: 'Complete',
loadingTip: 'Loading...',
vanContactCard: {
name: 'Name', name: 'Name',
tel: 'Phone', tel: 'Phone',
save: 'Save',
confirm: 'Confirm',
cancel: 'Cancel',
complete: 'Complete',
contact: 'Name',
province: 'Province',
city: 'City',
county: 'District',
loadingTip: 'Loading...',
nameEmpty: 'Name can not be empty',
nameOverlimit: 'Name length exceeds limit',
telInvalid: 'Malformed phone number',
telPlaceholder: 'Phone',
vanContactCard: {
addText: 'Add contact info' addText: 'Add contact info'
}, },
vanContactList: { vanContactList: {
name: 'Name',
tel: 'Phone',
addText: 'Add new contact' addText: 'Add new contact'
}, },
vanContactEdit: { vanContactEdit: {
name: 'Name',
namePlaceholder: 'Name',
nameEmpty: 'Name can not be empty',
nameOverlimit: 'Name length exceeds limit',
tel: 'Phone',
telPlaceholder: 'Phone',
telInvalid: 'Malformed phone number',
save: 'Save',
delete: 'Delete', delete: 'Delete',
confirmDelete: 'Are you sure you want to delete this contact?' confirmDelete: 'Are you sure you want to delete this contact?'
}, },
@ -31,8 +29,8 @@ export default {
next: 'Next' next: 'Next'
}, },
vanPullRefresh: { vanPullRefresh: {
pullingText: 'Pull to refresh...', pulling: 'Pull to refresh...',
loosingText: 'Loose to refresh...' loosing: 'Loose to refresh...'
}, },
vanSubmitBar: { vanSubmitBar: {
label: 'Total' label: 'Total'
@ -55,18 +53,9 @@ export default {
discount: discount => `${discount * 10}% off`, discount: discount => `${discount * 10}% off`,
condition: condition => `At least ${condition}` condition: condition => `At least ${condition}`
}, },
vanArea: {
province: 'Province',
city: 'City',
county: 'District'
},
vanAddressEdit: { vanAddressEdit: {
areaTitle: 'Area', area: 'Area',
areaWrong: 'Please select the correct receiving area',
areaEmpty: 'Please select a 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', addressOverlimit: 'The length of the address can not exceed 200 characters',
addressEmpty: 'Address can not be empty', addressEmpty: 'Address can not be empty',
postalEmpty: 'Wrong postal code', postalEmpty: 'Wrong postal code',
@ -75,25 +64,15 @@ export default {
confirmDelete: 'Are you sure you want to delete this address?', confirmDelete: 'Are you sure you want to delete this address?',
label: { label: {
name: 'Receiver', name: 'Receiver',
tel: 'Phone',
postal: 'Postal' postal: 'Postal'
}, },
placeholder: { placeholder: {
name: 'Receiver name', postal: 'Postal code (optional)'
tel: 'Phone',
postal: 'Postal code (optional)',
province: 'Province',
city: 'City',
county: 'County'
} }
}, },
vanAddressEditDetail: { vanAddressEditDetail: {
label: { label: 'Address',
address: 'Address' placeholder: 'Address'
},
placeholder: {
address: 'Address'
}
}, },
vanAddressList: { vanAddressList: {
address: 'Address', address: 'Address',

View File

@ -1,41 +1,36 @@
export default { export default {
name: '名字',
tel: '联系电话',
save: '保存',
confirm: '确认', confirm: '确认',
cancel: '取消', cancel: '取消',
save: '保存',
complete: '完成', complete: '完成',
contact: '联系人',
province: '选择省份',
city: '选择城市',
county: '选择地区',
loadingTip: '加载中...', loadingTip: '加载中...',
nameEmpty: '请填写名字',
nameOverlimit: '名字过长,请重新输入',
telInvalid: '请填写正确的手机号码或电话号码',
telPlaceholder: '手机或固定电话',
vanContactCard: { vanContactCard: {
name: '联系人',
tel: '联系电话',
addText: '添加订单联系人信息' addText: '添加订单联系人信息'
}, },
vanContactList: { vanContactList: {
name: '联系人',
tel: '联系电话',
addText: '新建联系人' addText: '新建联系人'
}, },
vanContactEdit: { vanContactEdit: {
name: '联系人',
namePlaceholder: '名字',
nameEmpty: '请填写名字',
nameOverlimit: '名字过长,请重新输入',
tel: '联系电话',
telPlaceholder: '手机或固定电话',
telInvalid: '请填写正确的手机号码或电话号码',
save: '保存',
delete: '删除联系人', delete: '删除联系人',
confirmDelete: '确定要删除这个联系人么' confirmDelete: '确定要删除这个联系人么'
}, },
vanPicker: {
confirm: '完成'
},
vanPagination: { vanPagination: {
prev: '上一页', prev: '上一页',
next: '下一页' next: '下一页'
}, },
vanPullRefresh: { vanPullRefresh: {
pullingText: '下拉即可刷新...', pulling: '下拉即可刷新...',
loosingText: '释放即可刷新...' loosing: '释放即可刷新...'
}, },
vanSubmitBar: { vanSubmitBar: {
label: '合计:' label: '合计:'
@ -58,19 +53,10 @@ export default {
discount: discount => `${discount}`, discount: discount => `${discount}`,
condition: (condition) => `${condition}元可用` condition: (condition) => `${condition}元可用`
}, },
vanArea: {
province: '选择省份',
city: '选择城市',
county: '选择地区'
},
vanAddressEdit: { vanAddressEdit: {
areaTitle: '收件地区', area: '收件地区',
addressText: '收货', addressText: '收货',
areaWrong: '请选择正确的收件地区',
areaEmpty: '请选择收件地区', areaEmpty: '请选择收件地区',
nameEmpty: '请填写名字',
nameOverlimit: '名字过长,请重新输入',
telWrong: '请填写正确的手机号码或电话号码',
addressOverlimit: '详细地址不能超过200个字符', addressOverlimit: '详细地址不能超过200个字符',
addressEmpty: '请填写详细地址', addressEmpty: '请填写详细地址',
postalEmpty: '邮政编码格式不正确', postalEmpty: '邮政编码格式不正确',
@ -79,25 +65,15 @@ export default {
confirmDelete: text => `确定要删除这个${text}地址么`, confirmDelete: text => `确定要删除这个${text}地址么`,
label: { label: {
name: text => `${text}`, name: text => `${text}`,
tel: '联系电话',
postal: '邮政编码' postal: '邮政编码'
}, },
placeholder: { placeholder: {
name: '名字', postal: '邮政编码(选填)'
tel: '手机或固定电话',
postal: '邮政编码(选填)',
province: '选择省份',
city: '选择城市',
county: '选择地区'
} }
}, },
vanAddressEditDetail: { vanAddressEditDetail: {
label: { label: '详细地址',
address: '详细地址' placeholder: '如街道、楼层、门牌号等'
},
placeholder: {
address: '如街道、楼层、门牌号等'
}
}, },
vanAddressList: { vanAddressList: {
address: '收货地址', address: '收货地址',

View File

@ -11,10 +11,10 @@
<div class="van-pull-refresh__head"> <div class="van-pull-refresh__head">
<slot name="normal" v-if="status === 'normal'"/> <slot name="normal" v-if="status === 'normal'"/>
<slot name="pulling" v-if="status === 'pulling'"> <slot name="pulling" v-if="status === 'pulling'">
<span class="van-pull-refresh__text">{{ pullingText || $t('pullingText') }}</span> <span class="van-pull-refresh__text">{{ pullingText || $t('pulling') }}</span>
</slot> </slot>
<slot name="loosing" v-if="status === 'loosing'"> <slot name="loosing" v-if="status === 'loosing'">
<span class="van-pull-refresh__text">{{ loosingText || $t('loosingText') }}</span> <span class="van-pull-refresh__text">{{ loosingText || $t('loosing') }}</span>
</slot> </slot>
<slot name="loading" v-if="status === 'loading'"> <slot name="loading" v-if="status === 'loading'">
<div class="van-pull-refresh__loading"> <div class="van-pull-refresh__loading">

View File

@ -12,7 +12,9 @@
</template> </template>
<script> <script>
export default { import { create } from '../../utils';
export default create({
name: 'van-sku-row-item', name: 'van-sku-row-item',
props: { props: {
@ -55,5 +57,5 @@ export default {
} }
} }
} }
}; });
</script> </script>