提交 b6abfa4d 编写于 作者: fxy060608's avatar fxy060608

feat(i18n): init

上级 7e026746
const path = require('path')
const json = require('@rollup/plugin-json')
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
const nodeResolve = require('@rollup/plugin-node-resolve')
......@@ -88,7 +89,8 @@ module.exports = {
find: 'uni-api-protocol',
replacement: resolve('src/core/helpers/protocol')
}]
}),
}),
json(),
nodeResolve(),
requireContext(),
commonjs(),
......
......@@ -47,7 +47,7 @@ const provides = {
}
if (process.env.UNI_VIEW) { // 方便调试
delete provides.console
}
}
if (process.env.UNI_VIEW === 'true') {
alias.vue$ = resolve('packages/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js')
......@@ -66,7 +66,8 @@ module.exports = {
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
__VIEW__: JSON.stringify(!!process.env.UNI_VIEW)
}),
new webpack.ProvidePlugin(provides)
]
......
......@@ -34,6 +34,7 @@
"release:v3": "npm run lint:cli && lerna publish --no-git-tag-version --force-publish=* --npm-tag=v3"
},
"dependencies": {
"@dcloudio/uni-i18n": "^0.0.1",
"base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0",
"pako": "^1.0.11",
......@@ -43,6 +44,7 @@
"devDependencies": {
"@rollup/plugin-alias": "^3.1.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.1",
"@types/html5plus": "^1.0.0",
......@@ -118,6 +120,8 @@
"__registerPage": true,
"UniViewJSBridge": true,
"UniServiceJSBridge": true,
"__DEV__": true,
"__VIEW__": true,
"__PLATFORM__": true,
"__VERSION__": true,
"__GLOBAL__": true,
......@@ -144,4 +148,4 @@
"main": "index.js",
"description": "",
"author": ""
}
}
{
"uni.showActionSheet.cancel": "cancel",
"uni.showToast.unpaired": "Please note showToast must be paired with hideToast",
"uni.showLoading.unpaired": "Please note showLoading must be paired with hideLoading",
"uni.showModal.cancel": "cancel",
"uni.showModal.confirm": "confirm",
"uni.button.feedback.title": "feedback",
"uni.button.feedback.send": "send"
}
{
"uni.showActionSheet.cancel": "cancelar",
"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.showModal.cancel": "cancelar",
"uni.showModal.confirm": "confirmar",
"uni.button.feedback.title": "realimentación",
"uni.button.feedback.send": "enviar"
}
{
"uni.showActionSheet.cancel": "Annuler",
"uni.showToast.unpaired": "Veuillez noter que showToast doit être associé à hideToast",
"uni.showLoading.unpaired": "Veuillez noter que showLoading doit être associé à hideLoading",
"uni.showModal.cancel": "Annuler",
"uni.showModal.confirm": "confirmer",
"uni.button.feedback.title": "retour d'information",
"uni.button.feedback.send": "envoyer"
}
import i18n from '@dcloudio/uni-i18n'
import en from './en.json'
import es from './es.json'
import fr from './fr.json'
import zhHans from './zh-Hans.json'
import zhHant from './zh-Hant.json'
const messages = {
en,
es,
fr,
'zh-Hans': zhHans,
'zh-Hant': zhHant
}
const fallbackLocale = 'en'
export function initI18n (locale, onChange) {
i18n.init({
locale,
fallbackLocale,
messages
})
if (onChange) {
i18n.watchLocale((newLocale, oldLocale) => {
onChange(newLocale, oldLocale)
})
}
}
function initLocaleWatcher (app) {
app.$i18n.vm.$watch('locale', (newLocale) => {
i18n.setLocale(newLocale)
}, {
immediate: true
})
}
export function t (key, values) {
if (__VIEW__) {
return i18n.t(key, values)
}
const app = getApp()
if (!app.$t) {
/* eslint-disable no-func-assign */
t = function (key, values) {
return i18n.t(key, values)
}
} else {
initLocaleWatcher(app)
/* eslint-disable no-func-assign */
t = function (key, values) {
const $i18n = app.$i18n
const silentTranslationWarn = $i18n.silentTranslationWarn
$i18n.silentTranslationWarn = true
const msg = app.$t(key, values)
$i18n.silentTranslationWarn = silentTranslationWarn
if (msg !== key) {
return msg
}
return i18n.t(key, values)
}
}
return t(key, values)
}
{
"uni.showActionSheet.cancel": "取消",
"uni.showToast.unpaired": "请注意 showToast 与 hideToast 必须配对使用",
"uni.showLoading.unpaired": "请注意 showLoading 与 hideLoading 必须配对使用",
"uni.showModal.cancel": "取消",
"uni.showModal.confirm": "确认",
"uni.button.feedback.title": "问题反馈",
"uni.button.feedback.send": "发送"
}
{
"uni.showActionSheet.cancel": "取消",
"uni.showToast.unpaired": "請注意 showToast 與 hideToast 必須配對使用",
"uni.showLoading.unpaired": "請注意 showLoading 與 hideLoading 必須配對使用",
"uni.showModal.cancel": "取消",
"uni.showModal.confirm": "確認",
"uni.button.feedback.title": "問題反饋",
"uni.button.feedback.send": "發送"
}
import {
t
} from 'uni-core/helpers/i18n'
import getRealPath from 'uni-platform/helpers/get-real-path'
export const showModal = {
......@@ -15,7 +19,9 @@ export const showModal = {
},
cancelText: {
type: String,
default: '取消'
default () {
return t('uni.showModal.cancel')
}
},
cancelColor: {
type: String,
......@@ -23,7 +29,9 @@ export const showModal = {
},
confirmText: {
type: String,
default: '确定'
default () {
return t('uni.showModal.confirm')
}
},
confirmColor: {
type: String,
......@@ -114,4 +122,4 @@ export const showActionSheet = {
popover: {
type: Object
}
}
}
import {
t,
initI18n
} from 'uni-core/helpers/i18n'
import initRouterGuard from './router-guard'
let appVm = false
......@@ -23,7 +28,8 @@ export function getCurrentPages (isAll = false, ignoreError = false) {
childrenVm = layoutVm
}
childrenVm.$children.forEach(vm => {
if (tabBarVm !== vm && vm.$children.length && vm.$children[0].$options.name === 'Page' && vm.$children[0].$slots.page) {
if (tabBarVm !== vm && vm.$children.length && vm.$children[0].$options.name === 'Page' && vm.$children[0].$slots
.page) {
// vm.$children[0]=Page->PageBody->RealPage
const pageBody = vm.$children[0].$children.find(vm => vm.$options.name === 'PageBody')
const pageVm = pageBody && pageBody.$children.find(vm => !!vm.$page)
......@@ -64,8 +70,11 @@ export function getCurrentPages (isAll = false, ignoreError = false) {
export default function createApp (vm, routes) {
appVm = vm
appVm.$$t = t
appVm.globalData = appVm.$options.globalData || {}
// h5
initI18n(navigator.userLanguage || navigator.language)
// initEvents(appVm)
initRouterGuard(appVm, routes)
}
}
<script>
import { hover, emitter, listeners } from 'uni-mixins'
import {
t
} from 'uni-core/helpers/i18n'
import {
hover,
emitter,
listeners
} from 'uni-mixins'
export default {
name: 'Button',
mixins: [hover, emitter, listeners],
......@@ -58,8 +65,7 @@ export default {
if (this.formType) {
this.$dispatch(
'Form',
this.formType === 'submit' ? 'uni-form-submit' : 'uni-form-reset',
{
this.formType === 'submit' ? 'uni-form-submit' : 'uni-form-reset', {
type: this.formType
}
)
......@@ -68,15 +74,14 @@ export default {
if (this.openType === 'feedback' && __PLATFORM__ === 'app-plus') {
const feedback = plus.webview.create(
'https://service.dcloud.net.cn/uniapp/feedback.html',
'feedback',
{
'feedback', {
titleNView: {
titleText: '问题反馈',
titleText: t('uni.button.feedback.title'),
autoBackButton: true,
backgroundColor: '#F7F7F7',
titleColor: '#007aff',
buttons: [{
text: '发送',
text: t('uni.button.feedback.send'),
color: '#007aff',
fontSize: '16px',
fontWeight: 'bold',
......@@ -116,37 +121,35 @@ export default {
if (this.hoverClass && this.hoverClass !== 'none') {
return createElement(
'uni-button',
this._bindObjectListeners(
{
class: [this.hovering ? this.hoverClass : ''],
attrs: {
disabled: this.disabled
},
on: {
touchstart: this._hoverTouchStart,
touchend: this._hoverTouchEnd,
touchcancel: this._hoverTouchCancel,
click: this._onClick
}
this._bindObjectListeners({
class: [this.hovering ? this.hoverClass : ''],
attrs: {
disabled: this.disabled
},
$listeners
on: {
touchstart: this._hoverTouchStart,
touchend: this._hoverTouchEnd,
touchcancel: this._hoverTouchCancel,
click: this._onClick
}
},
$listeners
),
this.$slots.default
)
} else {
return createElement(
'uni-button',
this._bindObjectListeners(
{
class: [this.hovering ? this.hoverClass : ''],
attrs: {
disabled: this.disabled
},
on: {
click: this._onClick
}
this._bindObjectListeners({
class: [this.hovering ? this.hoverClass : ''],
attrs: {
disabled: this.disabled
},
$listeners
on: {
click: this._onClick
}
},
$listeners
),
this.$slots.default
)
......@@ -159,271 +162,271 @@ export default {
}
</script>
<style>
uni-button {
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
padding-left: 14px;
padding-right: 14px;
box-sizing: border-box;
font-size: 18px;
text-align: center;
text-decoration: none;
line-height: 2.55555556;
border-radius: 5px;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
color: #000000;
background-color: #f8f8f8;
cursor: pointer;
}
uni-button {
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
padding-left: 14px;
padding-right: 14px;
box-sizing: border-box;
font-size: 18px;
text-align: center;
text-decoration: none;
line-height: 2.55555556;
border-radius: 5px;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
color: #000000;
background-color: #f8f8f8;
cursor: pointer;
}
uni-button[hidden] {
display: none !important;
}
uni-button[hidden] {
display: none !important;
}
uni-button:after {
content: " ";
width: 200%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-transform: scale(0.5);
transform: scale(0.5);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
box-sizing: border-box;
border-radius: 10px;
}
uni-button:after {
content: " ";
width: 200%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-transform: scale(0.5);
transform: scale(0.5);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
box-sizing: border-box;
border-radius: 10px;
}
uni-button[native] {
padding-left: 0;
padding-right: 0;
}
uni-button[native] {
padding-left: 0;
padding-right: 0;
}
uni-button[native] .uni-button-cover-view-wrapper {
border: inherit;
border-color: inherit;
border-radius: inherit;
background-color: inherit;
}
uni-button[native] .uni-button-cover-view-wrapper {
border: inherit;
border-color: inherit;
border-radius: inherit;
background-color: inherit;
}
uni-button[native] .uni-button-cover-view-inner {
padding-left: 14px;
padding-right: 14px;
}
uni-button[native] .uni-button-cover-view-inner {
padding-left: 14px;
padding-right: 14px;
}
uni-button uni-cover-view {
line-height: inherit;
white-space: inherit;
}
uni-button uni-cover-view {
line-height: inherit;
white-space: inherit;
}
uni-button[type="default"] {
color: #000000;
background-color: #f8f8f8;
}
uni-button[type="default"] {
color: #000000;
background-color: #f8f8f8;
}
uni-button[type="primary"] {
color: #ffffff;
background-color: #007aff;
}
uni-button[type="primary"] {
color: #ffffff;
background-color: #007aff;
}
uni-button[type="warn"] {
color: #ffffff;
background-color: #e64340;
}
uni-button[type="warn"] {
color: #ffffff;
background-color: #e64340;
}
uni-button[disabled] {
color: rgba(255, 255, 255, 0.6);
cursor: not-allowed;
}
uni-button[disabled] {
color: rgba(255, 255, 255, 0.6);
cursor: not-allowed;
}
uni-button[disabled][type="default"],
uni-button[disabled]:not([type]) {
color: rgba(0, 0, 0, 0.3);
background-color: #f7f7f7;
}
uni-button[disabled][type="default"],
uni-button[disabled]:not([type]) {
color: rgba(0, 0, 0, 0.3);
background-color: #f7f7f7;
}
uni-button[disabled][type="primary"] {
background-color: rgba(0, 122, 255, 0.6);
}
uni-button[disabled][type="primary"] {
background-color: rgba(0, 122, 255, 0.6);
}
uni-button[disabled][type="warn"] {
background-color: #ec8b89;
}
uni-button[disabled][type="warn"] {
background-color: #ec8b89;
}
uni-button[type="primary"][plain] {
color: #007aff;
border: 1px solid #007aff;
background-color: transparent;
}
uni-button[type="primary"][plain] {
color: #007aff;
border: 1px solid #007aff;
background-color: transparent;
}
uni-button[type="primary"][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type="primary"][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type="primary"][plain]:after {
border-width: 0;
}
uni-button[type="primary"][plain]:after {
border-width: 0;
}
uni-button[type="default"][plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[type="default"][plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[type="default"][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type="default"][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type="default"][plain]:after {
border-width: 0;
}
uni-button[type="default"][plain]:after {
border-width: 0;
}
uni-button[plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[plain]:after {
border-width: 0;
}
uni-button[plain]:after {
border-width: 0;
}
uni-button[plain][native] .uni-button-cover-view-inner {
padding: 0;
}
uni-button[plain][native] .uni-button-cover-view-inner {
padding: 0;
}
uni-button[type="warn"][plain] {
color: #e64340;
border: 1px solid #e64340;
background-color: transparent;
}
uni-button[type="warn"][plain] {
color: #e64340;
border: 1px solid #e64340;
background-color: transparent;
}
uni-button[type="warn"][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type="warn"][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type="warn"][plain]:after {
border-width: 0;
}
uni-button[type="warn"][plain]:after {
border-width: 0;
}
uni-button[size="mini"] {
display: inline-block;
line-height: 2.3;
font-size: 13px;
padding: 0 1.34em;
}
uni-button[size="mini"] {
display: inline-block;
line-height: 2.3;
font-size: 13px;
padding: 0 1.34em;
}
uni-button[size="mini"][native] {
padding: 0;
}
uni-button[size="mini"][native] {
padding: 0;
}
uni-button[size="mini"][native] .uni-button-cover-view-inner {
padding: 0 1.34em;
}
uni-button[size="mini"][native] .uni-button-cover-view-inner {
padding: 0 1.34em;
}
uni-button[loading]:not([disabled]) {
cursor: progress;
}
uni-button[loading]:not([disabled]) {
cursor: progress;
}
uni-button[loading]:before {
content: " ";
display: inline-block;
width: 18px;
height: 18px;
vertical-align: middle;
-webkit-animation: uni-loading 1s steps(12, end) infinite;
animation: uni-loading 1s steps(12, end) infinite;
background-size: 100%;
}
uni-button[loading]:before {
content: " ";
display: inline-block;
width: 18px;
height: 18px;
vertical-align: middle;
-webkit-animation: uni-loading 1s steps(12, end) infinite;
animation: uni-loading 1s steps(12, end) infinite;
background-size: 100%;
}
uni-button[loading][type="primary"] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
uni-button[loading][type="primary"] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
uni-button[loading][type="primary"][plain] {
color: #007aff;
background-color: transparent;
}
uni-button[loading][type="primary"][plain] {
color: #007aff;
background-color: transparent;
}
uni-button[loading][type="default"] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
uni-button[loading][type="default"] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
uni-button[loading][type="default"][plain] {
color: #353535;
background-color: transparent;
}
uni-button[loading][type="default"][plain] {
color: #353535;
background-color: transparent;
}
uni-button[loading][type="warn"] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
uni-button[loading][type="warn"] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
uni-button[loading][type="warn"][plain] {
color: #e64340;
background-color: transparent;
}
uni-button[loading][type="warn"][plain] {
color: #e64340;
background-color: transparent;
}
uni-button[loading][native]:before {
content: none;
}
uni-button[loading][native]:before {
content: none;
}
.button-hover {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type="primary"] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
.button-hover[type="primary"] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
.button-hover[type="primary"][plain] {
color: rgba(26, 173, 25, 0.6);
border-color: rgba(26, 173, 25, 0.6);
background-color: transparent;
}
.button-hover[type="primary"][plain] {
color: rgba(26, 173, 25, 0.6);
border-color: rgba(26, 173, 25, 0.6);
background-color: transparent;
}
.button-hover[type="default"] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[type="default"] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[type="default"][plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type="default"][plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type="warn"] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
.button-hover[type="warn"] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
.button-hover[type="warn"][plain] {
color: rgba(230, 67, 64, 0.6);
border-color: rgba(230, 67, 64, 0.6);
background-color: transparent;
}
</style>
.button-hover[type="warn"][plain] {
color: rgba(230, 67, 64, 0.6);
border-color: rgba(230, 67, 64, 0.6);
background-color: transparent;
}
</style>
import i18n from '@dcloudio/uni-i18n'
import {
t
} from 'uni-core/helpers/i18n'
export default {
beforeCreate () {
const unwatch = i18n.watchLocale(() => {
this.$forceUpdate()
})
this.$once('hook:beforeDestroy', function () {
unwatch()
})
},
methods: {
$$t (key, values) {
return t(key, values)
}
}
}
......@@ -11,7 +11,9 @@ let toastType
let timeout
export function showLoading (args) {
return callApiSync(showToast, Object.assign({}, args, { type: 'loading' }), 'showToast', 'showLoading')
return callApiSync(showToast, Object.assign({}, args, {
type: 'loading'
}), 'showToast', 'showLoading')
}
export function hideLoading () {
......@@ -111,10 +113,10 @@ export function showModal ({
title = '',
content = '',
showCancel = true,
cancelText = '取消',
cancelColor = '#000000',
confirmText = '确定',
confirmColor = '#3CC51F'
cancelText,
cancelColor,
confirmText,
confirmColor
} = {}, callbackId) {
content = content || ' '
plus.nativeUI.confirm(content, (e) => {
......@@ -151,7 +153,9 @@ export function showActionSheet ({
options.cancel = ''
plus.nativeUI.actionSheet(Object.assign(options, { popover }), (e) => {
plus.nativeUI.actionSheet(Object.assign(options, {
popover
}), (e) => {
if (e.index > 0) {
invoke(callbackId, {
errMsg: 'showActionSheet:ok',
......@@ -163,4 +167,4 @@ export function showActionSheet ({
})
}
})
}
}
import {
t,
initI18n
} from 'uni-core/helpers/i18n'
import {
callAppHook
} from 'uni-core/service/plugins/util'
......@@ -206,7 +210,7 @@ export function registerApp (appVm) {
if (process.env.NODE_ENV !== 'production') {
console.log('[uni-app] registerApp')
}
appVm.$$t = t
appCtx = appVm
appCtx.$vm = appVm
......@@ -216,6 +220,9 @@ export function registerApp (appVm) {
// merge globalData
appCtx.globalData = Object.assign(globalData, appCtx.globalData)
// TODO
initI18n(plus.os.language)
initOn(UniServiceJSBridge.on, {
getApp,
getCurrentPages
......@@ -237,4 +244,4 @@ export function registerApp (appVm) {
__uniConfig.ready = true
process.env.NODE_ENV !== 'production' && perf('registerApp')
}
}
......@@ -25,11 +25,15 @@ import {
}
from '../../constants'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
import {
NAVBAR_HEIGHT
} from 'uni-helpers/constants'
import tabBar from '../tab-bar'
import { getStatusbarHeight } from 'uni-platform/helpers/status-bar'
import {
getStatusbarHeight
} from 'uni-platform/helpers/status-bar'
import {
preloadSubPackages
......@@ -51,6 +55,7 @@ function parsePageCreateOptions (vm, route) {
return {
version: VD_SYNC_VERSION,
locale: plus.os.language, // TODO
disableScroll,
onPageScroll,
onPageReachBottom,
......@@ -83,6 +88,10 @@ export function initLifecycle (Vue) {
}
if (this.mpType === 'page') {
const app = getApp()
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n
}
this.$scope = this.$options.pageInstance
this.$scope.$vm = this
delete this.$options.pageInstance
......@@ -112,4 +121,4 @@ export function initLifecycle (Vue) {
}
}
})
}
}
......@@ -2,6 +2,10 @@ import {
supportsPassive
} from 'uni-shared'
import {
initI18n
} from 'uni-core/helpers/i18n'
import {
disableScroll as disableScrollListener,
createScrollListener
......@@ -27,10 +31,10 @@ function onCssVar ({
global.__WINDOW_TOP = windowTop
global.__WINDOW_BOTTOM = windowBottom
if (uni.canIUse('css.var')) {
const style = document.documentElement.style
// TODO
style.setProperty('--window-left', '0px')
style.setProperty('--window-right', '0px')
const style = document.documentElement.style
// TODO
style.setProperty('--window-left', '0px')
style.setProperty('--window-right', '0px')
style.setProperty('--window-top', windowTop + 'px')
style.setProperty('--window-bottom', windowBottom + 'px')
......@@ -44,6 +48,7 @@ function onCssVar ({
}
function onPageCreate ({
locale,
statusbarHeight,
windowTop,
windowBottom,
......@@ -51,7 +56,9 @@ function onPageCreate ({
onPageScroll,
onPageReachBottom,
onReachBottomDistance
}, pageId) {
}, pageId) {
initI18n(locale)
onCssVar({
statusbarHeight,
windowTop,
......@@ -78,4 +85,4 @@ function onWebviewReady () { // service 主动发起检测
export default function initSubscribe (subscribe) {
subscribe(WEBVIEW_READY, onWebviewReady)
subscribe(ON_PAGE_CREATE, onPageCreate)
}
}
......@@ -53,7 +53,7 @@
class="uni-actionsheet__cell"
@click="_close(-1)"
>
取消
{{ $$t('uni.showActionSheet.cancel') }}
</div>
</div>
<div :style="popupStyle.triangle" />
......@@ -66,7 +66,8 @@
</template>
<script>
import popup from './mixins/popup'
import keypress from '../../../helpers/keypress'
import keypress from '../../../helpers/keypress'
import i18n from 'uni-mixins/i18n'
import touchtrack from 'uni-mixins/touchtrack'
import scroller from 'uni-mixins/scroller/index'
import {
......@@ -110,7 +111,7 @@ function initClick (dom) {
export default {
name: 'ActionSheet',
components: { keypress },
mixins: [popup, touchtrack, scroller],
mixins: [i18n, popup, touchtrack, scroller],
props: {
title: {
type: String,
......
import {
t
} from 'uni-core/helpers/i18n'
export default {
data () {
return {
......@@ -28,9 +31,9 @@ export default {
}
let warnMsg = ''
if (type === 'onHideToast' && showType !== 'onShowToast') {
warnMsg = '请注意 showToast 与 hideToast 必须配对使用'
warnMsg = t('uni.showToast.unpaired')
} else if (type === 'onHideLoading' && showType !== 'onShowLoading') {
warnMsg = '请注意 showLoading 与 hideLoading 必须配对使用'
warnMsg = t('uni.showLoading.unpaired')
}
if (warnMsg) {
return console.warn(warnMsg)
......
......@@ -743,6 +743,11 @@
exec-sh "^0.3.2"
minimist "^1.2.0"
"@dcloudio/uni-i18n@^0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@dcloudio/uni-i18n/-/uni-i18n-0.0.1.tgz#98367f8d4ba5d50ba7d60c9ab78cff27bfc0338b"
integrity sha512-4zD/+ZkMUo7puUwEyEhP134XBqEhADyOCw9PBS50MxUiuxTkWH0tzcZFJr4CV72NF9v3V9z+8IiFExxu+RVxoA==
"@hapi/address@2.x.x":
version "2.1.4"
resolved "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
......@@ -985,6 +990,13 @@
magic-string "^0.25.2"
resolve "^1.11.0"
"@rollup/plugin-json@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3"
integrity sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==
dependencies:
"@rollup/pluginutils" "^3.0.8"
"@rollup/plugin-node-resolve@^7.1.3":
version "7.1.3"
resolved "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz#80de384edfbd7bfc9101164910f86078151a3eca"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册