提交 c7b74ad1 编写于 作者: Q qiang

feat(h5): picker i18n

上级 806ad9e4
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
"uni.showLoading.unpaired": "Please note showLoading must be paired with hideLoading", "uni.showLoading.unpaired": "Please note showLoading must be paired with hideLoading",
"uni.showModal.cancel": "cancel", "uni.showModal.cancel": "cancel",
"uni.showModal.confirm": "confirm", "uni.showModal.confirm": "confirm",
"uni.picker.done": "Done",
"uni.picker.cancel": "Cancel",
"uni.button.feedback.title": "feedback", "uni.button.feedback.title": "feedback",
"uni.button.feedback.send": "send" "uni.button.feedback.send": "send"
} }
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
"uni.showToast.unpaired": "Tenga en cuenta que showToast debe estar emparejado con hideToast", "uni.showToast.unpaired": "Tenga en cuenta que showToast debe estar emparejado con hideToast",
"uni.showLoading.unpaired": "Tenga en cuenta que showLoading debe estar emparejado con hideLoading", "uni.showLoading.unpaired": "Tenga en cuenta que showLoading debe estar emparejado con hideLoading",
"uni.showModal.cancel": "cancelar", "uni.showModal.cancel": "cancelar",
"uni.showModal.confirm": "confirmar", "uni.showModal.confirm": "confirmar",
"uni.button.feedback.title": "realimentación", "uni.picker.done": "OK",
"uni.picker.cancel": "Cancelar",
"uni.button.feedback.title": "realimentación",
"uni.button.feedback.send": "enviar" "uni.button.feedback.send": "enviar"
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
"uni.showLoading.unpaired": "Veuillez noter que showLoading doit être associé à hideLoading", "uni.showLoading.unpaired": "Veuillez noter que showLoading doit être associé à hideLoading",
"uni.showModal.cancel": "Annuler", "uni.showModal.cancel": "Annuler",
"uni.showModal.confirm": "confirmer", "uni.showModal.confirm": "confirmer",
"uni.picker.done": "OK",
"uni.picker.cancel": "Annuler",
"uni.button.feedback.title": "retour d'information", "uni.button.feedback.title": "retour d'information",
"uni.button.feedback.send": "envoyer" "uni.button.feedback.send": "envoyer"
} }
...@@ -21,4 +21,5 @@ const fallbackLocale = 'en' ...@@ -21,4 +21,5 @@ const fallbackLocale = 'en'
const i18n = initVueI18n(__PLATFORM__ === 'app-plus' || __PLATFORM__ === 'h5' ? messages : {}, fallbackLocale) const i18n = initVueI18n(__PLATFORM__ === 'app-plus' || __PLATFORM__ === 'h5' ? messages : {}, fallbackLocale)
export const t = i18n.t export const t = i18n.t
export const i18nMixin = i18n.mixin export const i18nMixin = i18n.mixin
export const setLocale = i18n.setLocale export const setLocale = i18n.setLocale
export const getLocale = i18n.getLocale
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
"uni.showLoading.unpaired": "请注意 showLoading 与 hideLoading 必须配对使用", "uni.showLoading.unpaired": "请注意 showLoading 与 hideLoading 必须配对使用",
"uni.showModal.cancel": "取消", "uni.showModal.cancel": "取消",
"uni.showModal.confirm": "确认", "uni.showModal.confirm": "确认",
"uni.picker.done": "完成",
"uni.picker.cancel": "取消",
"uni.button.feedback.title": "问题反馈", "uni.button.feedback.title": "问题反馈",
"uni.button.feedback.send": "发送" "uni.button.feedback.send": "发送"
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
"uni.showLoading.unpaired": "請注意 showLoading 與 hideLoading 必須配對使用", "uni.showLoading.unpaired": "請注意 showLoading 與 hideLoading 必須配對使用",
"uni.showModal.cancel": "取消", "uni.showModal.cancel": "取消",
"uni.showModal.confirm": "確認", "uni.showModal.confirm": "確認",
"uni.picker.done": "完成",
"uni.picker.cancel": "取消",
"uni.button.feedback.title": "問題反饋", "uni.button.feedback.title": "問題反饋",
"uni.button.feedback.send": "發送" "uni.button.feedback.send": "發送"
} }
...@@ -33,22 +33,23 @@ ...@@ -33,22 +33,23 @@
class="uni-picker-action uni-picker-action-cancel" class="uni-picker-action uni-picker-action-cancel"
@click="_cancel" @click="_cancel"
> >
取消 {{ $$t("uni.picker.cancel") }}
</div> </div>
<div <div
class="uni-picker-action uni-picker-action-confirm" class="uni-picker-action uni-picker-action-confirm"
@click="_change" @click="_change"
> >
确定 {{ $$t("uni.picker.done") }}
</div> </div>
</div> </div>
<v-uni-picker-view <v-uni-picker-view
v-if="contentVisible" v-if="contentVisible"
:value.sync="valueArray" :value="_l10nColumn(valueArray)"
class="uni-picker-content" class="uni-picker-content"
@change="_pickerViewChange"
> >
<v-uni-picker-view-column <v-uni-picker-view-column
v-for="(rangeItem, index0) in rangeArray" v-for="(rangeItem, index0) in _l10nColumn(rangeArray)"
:key="index0" :key="index0"
> >
<div <div
...@@ -56,8 +57,7 @@ ...@@ -56,8 +57,7 @@
:key="index" :key="index"
class="uni-picker-item" class="uni-picker-item"
> >
{{ typeof item === "object" ? item[rangeKey] || "" : item {{ typeof item === "object" ? item[rangeKey] || "" : _l10nItem(item, index0) }}
}}{{ units[index0] || "" }}
</div> </div>
</v-uni-picker-view-column> </v-uni-picker-view-column>
</v-uni-picker-view> </v-uni-picker-view>
...@@ -115,6 +115,10 @@ import { emitter } from 'uni-mixins' ...@@ -115,6 +115,10 @@ import { emitter } from 'uni-mixins'
import { formatDateTime } from 'uni-shared' import { formatDateTime } from 'uni-shared'
import popup from '../../../components/app/popup/mixins/popup' import popup from '../../../components/app/popup/mixins/popup'
import keypress from '../../../helpers/keypress' import keypress from '../../../helpers/keypress'
import {
i18nMixin,
getLocale
} from 'uni-core/helpers/i18n'
function getDefaultStartValue () { function getDefaultStartValue () {
if (this.mode === mode.TIME) { if (this.mode === mode.TIME) {
...@@ -172,7 +176,7 @@ const selectorType = { ...@@ -172,7 +176,7 @@ const selectorType = {
export default { export default {
name: 'Picker', name: 'Picker',
components: { keypress }, components: { keypress },
mixins: [emitter, popup], mixins: [i18nMixin, emitter, popup],
props: { props: {
name: { name: {
type: String, type: String,
...@@ -264,16 +268,6 @@ export default { ...@@ -264,16 +268,6 @@ export default {
endArray () { endArray () {
return this._getDateValueArray(this.end, getDefaultEndValue.bind(this)()) return this._getDateValueArray(this.end, getDefaultEndValue.bind(this)())
}, },
units () {
switch (this.mode) {
case mode.DATE:
return ['', '', '']
case mode.TIME:
return ['', '']
default:
return []
}
},
selectorTypeComputed () { selectorTypeComputed () {
const type = this.selectorType const type = this.selectorType
if (Object.values(selectorType).includes(type)) { if (Object.values(selectorType).includes(type)) {
...@@ -610,6 +604,50 @@ export default { ...@@ -610,6 +604,50 @@ export default {
style.left = `${$event.clientX - rect.left - fontSize * 1.5}px` style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`
style.top = `${$event.clientY - rect.top - fontSize * 0.5}px` style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`
} }
},
_pickerViewChange (event) {
this.valueArray == this._l10nColumn(event.detail.value, true)
},
_l10nColumn (array, normalize) {
if (this.mode === mode.DATE) {
const local = getLocale()
if (!local.startsWith('zh')) {
switch (local) {
case 'es':
case 'fr':
return [array[2], array[1], array[0]]
// case 'en':
default:
return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]]
}
}
}
return array
},
_l10nItem (item, index) {
if (this.mode === mode.DATE) {
const local = getLocale()
if (local.startsWith('zh')) {
const array = ['', '', '']
return item + array[index]
} else if (index === (local === 'es' || local === 'fr' ? 1 : 0)) {
let array
switch (local) {
case 'es':
array = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', '​​julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']
break
case 'fr':
array = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
break
// case 'en':
default:
array = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
break
}
return array[Number(item) - 1]
}
}
return item
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册