Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
6cb65c85
U
uni-app
项目概览
genary
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6cb65c85
编写于
9月 28, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): i18n
上级
82fe3bc3
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
214 addition
and
169 deletion
+214
-169
packages/uni-app-plus/dist/style.css
packages/uni-app-plus/dist/style.css
+1
-1
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+35
-28
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+1
-1
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+16
-18
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+16
-18
packages/uni-i18n/build.json
packages/uni-i18n/build.json
+3
-0
packages/uni-i18n/dist/uni-i18n.cjs.js
packages/uni-i18n/dist/uni-i18n.cjs.js
+35
-28
packages/uni-i18n/dist/uni-i18n.es.js
packages/uni-i18n/dist/uni-i18n.es.js
+35
-28
packages/uni-i18n/src/vue-i18n.ts
packages/uni-i18n/src/vue-i18n.ts
+33
-40
packages/uni-mp-alipay/build.json
packages/uni-mp-alipay/build.json
+1
-0
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+4
-1
packages/uni-mp-baidu/build.json
packages/uni-mp-baidu/build.json
+1
-0
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+4
-1
packages/uni-mp-core/src/api/locale.ts
packages/uni-mp-core/src/api/locale.ts
+4
-0
packages/uni-mp-kuaishou/build.json
packages/uni-mp-kuaishou/build.json
+1
-0
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+4
-1
packages/uni-mp-qq/build.json
packages/uni-mp-qq/build.json
+1
-0
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+4
-1
packages/uni-mp-toutiao/build.json
packages/uni-mp-toutiao/build.json
+1
-0
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+4
-1
packages/uni-mp-weixin/build.json
packages/uni-mp-weixin/build.json
+1
-0
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+4
-1
packages/uni-quickapp-webview/build.json
packages/uni-quickapp-webview/build.json
+1
-0
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+4
-1
未找到文件。
packages/uni-app-plus/dist/style.css
浏览文件 @
6cb65c85
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
6cb65c85
...
...
@@ -1482,7 +1482,6 @@ var serviceContext = (function (vue) {
}
}
const ignoreVueI18n = true;
function watchAppLocale(appVm, i18n) {
// 需要保证 watch 的触发在组件渲染之前
if (appVm.$watchLocale) {
...
...
@@ -1497,6 +1496,16 @@ var serviceContext = (function (vue) {
});
}
}
function getDefaultLocale() {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 window 上挂了 getLocale
if (typeof window !== 'undefined' && window.getLocale) {
return window.getLocale();
}
return LOCALE_EN;
}
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
// 兼容旧版本入参
if (typeof locale !== 'string') {
...
...
@@ -1506,9 +1515,8 @@ var serviceContext = (function (vue) {
];
}
if (typeof locale !== 'string') {
locale =
(typeof uni !== 'undefined' && uni.getLocale && uni.getLocale()) ||
LOCALE_EN;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale = getDefaultLocale();
}
if (typeof fallbackLocale !== 'string') {
fallbackLocale =
...
...
@@ -1530,33 +1538,32 @@ var serviceContext = (function (vue) {
};
}
else {
const appVm = getApp().$vm;
watchAppLocale(appVm, i18n);
if (!appVm.$t || !appVm.$i18n || ignoreVueI18n) {
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t = function (key, values) {
let isWatchedAppLocale = false;
t = function (key, values) {
const appVm = getApp().$vm;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if (appVm) {
// 触发响应式
appVm.$locale;
return i18n.t(key, values);
};
}
else {
/* eslint-disable no-func-assign */
t = function (key, values) {
const $i18n = appVm.$i18n;
const silentTranslationWarn = $i18n.silentTranslationWarn;
$i18n.silentTranslationWarn = true;
const msg = appVm.$t(key, values);
$i18n.silentTranslationWarn = silentTranslationWarn;
if (msg !== key) {
return msg;
if (!isWatchedAppLocale) {
isWatchedAppLocale = true;
watchAppLocale(appVm, i18n);
}
return i18n.t(key, $i18n.locale, values);
}
;
}
}
return i18n.t(key, values)
;
}
;
}
return t(key, values);
};
...
...
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
6cb65c85
此差异已折叠。
点击以展开。
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
6cb65c85
...
...
@@ -2612,26 +2612,28 @@ var index$w = /* @__PURE__ */ defineBuiltInComponent({
const
{
fixSize
}
=
useImageSize
(
rootRef
,
props2
,
state
);
useImageLoader
(
state
,
{
trigger
,
fixSize
});
useImageLoader
(
state
,
fixSize
,
trigger
);
return
()
=>
{
const
{
mode
:
mode2
}
=
props2
;
const
{
imgSrc
,
modeStyle
modeStyle
,
src
}
=
state
;
let
imgTsx
;
{
imgTsx
=
vue
.
createVNode
(
"
img
"
,
{
"
src
"
:
src
,
"
draggable
"
:
props2
.
draggable
},
null
,
8
,
[
"
src
"
,
"
draggable
"
]);
}
return
vue
.
createVNode
(
"
uni-image
"
,
{
"
ref
"
:
rootRef
},
[
vue
.
createVNode
(
"
div
"
,
{
"
style
"
:
modeStyle
},
null
,
4
),
imgSrc
?
vue
.
createVNode
(
"
img
"
,
{
"
src
"
:
imgSrc
,
"
draggable
"
:
props2
.
draggable
},
null
,
8
,
[
"
src
"
,
"
draggable
"
])
:
vue
.
createVNode
(
"
img
"
,
null
,
null
),
FIX_MODES
[
mode2
]
?
vue
.
createVNode
(
ResizeSensor
,
{
},
null
,
4
),
imgTsx
,
FIX_MODES
[
mode2
]
?
vue
.
createVNode
(
ResizeSensor
,
{
"
onResize
"
:
fixSize
},
null
,
8
,
[
"
onResize
"
])
:
vue
.
createVNode
(
"
span
"
,
null
,
null
)],
512
);
};
...
...
@@ -2650,8 +2652,9 @@ function useImageState(rootRef, props2) {
opts
[
0
]
&&
(
position
=
opts
[
0
]);
opts
[
1
]
&&
(
size
=
opts
[
1
]);
}
const
srcVal
=
imgSrc
.
value
;
return
`background-image:
${
srcVal
?
'
url("
'
+
srcVal
+
'
")
'
:
"
none
"
}
;background-position:
${
position
}
;background-size:
${
size
}
;background-repeat:no-repeat;`
;
return
`background-image:
${
imgSrc
.
value
?
'
url("
'
+
imgSrc
.
value
+
'
")
'
:
"
none
"
}
;
background-position:
${
position
}
;
background-size:
${
size
}
;`
;
});
const
state
=
vue
.
reactive
({
rootEl
:
rootRef
,
...
...
@@ -2667,10 +2670,7 @@ function useImageState(rootRef, props2) {
});
return
state
;
}
function
useImageLoader
(
state
,
{
trigger
,
fixSize
})
{
function
useImageLoader
(
state
,
fixSize
,
trigger
)
{
let
img
;
const
setState
=
(
width
=
0
,
height
=
0
,
imgSrc
=
""
)
=>
{
state
.
origWidth
=
width
;
...
...
@@ -2683,9 +2683,7 @@ function useImageLoader(state, {
setState
();
return
;
}
if
(
!
img
)
{
img
=
new
Image
();
}
img
=
img
||
new
Image
();
img
.
onload
=
(
evt
)
=>
{
const
{
width
,
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
6cb65c85
...
...
@@ -7759,26 +7759,28 @@ var index$r = /* @__PURE__ */ defineBuiltInComponent({
const {
fixSize
} = useImageSize(rootRef, props2, state2);
useImageLoader(state2, {
trigger,
fixSize
});
useImageLoader(state2, fixSize, trigger);
return () => {
const {
mode: mode2
} = props2;
const {
imgSrc,
modeStyle
modeStyle,
src
} = state2;
let imgTsx;
{
imgTsx = imgSrc ? createVNode("img", {
"src": imgSrc,
"draggable": props2.draggable
}, null, 8, ["src", "draggable"]) : createVNode("img", null, null);
}
return createVNode("uni-image", {
"ref": rootRef
}, [createVNode("div", {
"style": modeStyle
}, null, 4), imgSrc ? createVNode("img", {
"src": imgSrc,
"draggable": props2.draggable
}, null, 8, ["src", "draggable"]) : createVNode("img", null, null), FIX_MODES[mode2] ? createVNode(ResizeSensor, {
}, null, 4), imgTsx, FIX_MODES[mode2] ? createVNode(ResizeSensor, {
"onResize": fixSize
}, null, 8, ["onResize"]) : createVNode("span", null, null)], 512);
};
...
...
@@ -7797,8 +7799,9 @@ function useImageState(rootRef, props2) {
opts[0] && (position = opts[0]);
opts[1] && (size = opts[1]);
}
const srcVal = imgSrc.value;
return `background-image:${srcVal ? 'url("' + srcVal + '")' : "none"};background-position:${position};background-size:${size};background-repeat:no-repeat;`;
return `background-image:${imgSrc.value ? 'url("' + imgSrc.value + '")' : "none"};
background-position:${position};
background-size:${size};`;
});
const state2 = reactive({
rootEl: rootRef,
...
...
@@ -7820,10 +7823,7 @@ function useImageState(rootRef, props2) {
});
return state2;
}
function useImageLoader(state2, {
trigger,
fixSize
}) {
function useImageLoader(state2, fixSize, trigger) {
let img;
const setState = (width = 0, height = 0, imgSrc = "") => {
state2.origWidth = width;
...
...
@@ -7836,9 +7836,7 @@ function useImageLoader(state2, {
setState();
return;
}
if (!img) {
img = new Image();
}
img = img || new Image();
img.onload = (evt) => {
const {
width,
...
...
packages/uni-i18n/build.json
浏览文件 @
6cb65c85
...
...
@@ -2,6 +2,9 @@
"input"
:
{
"src/index.ts"
:
[
"dist/uni-i18n.es.js"
,
"dist/uni-i18n.cjs.js"
]
},
"replacements"
:
{
"global"
:
"global"
},
"compilerOptions"
:
{
"declaration"
:
true
}
...
...
packages/uni-i18n/dist/uni-i18n.cjs.js
浏览文件 @
6cb65c85
...
...
@@ -221,7 +221,6 @@ class I18n {
}
}
const
ignoreVueI18n
=
true
;
function
watchAppLocale
(
appVm
,
i18n
)
{
// 需要保证 watch 的触发在组件渲染之前
if
(
appVm
.
$watchLocale
)
{
...
...
@@ -236,6 +235,16 @@ function watchAppLocale(appVm, i18n) {
});
}
}
function
getDefaultLocale
()
{
if
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
)
{
return
uni
.
getLocale
();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if
(
typeof
global
!==
'
undefined
'
&&
global
.
getLocale
)
{
return
global
.
getLocale
();
}
return
LOCALE_EN
;
}
function
initVueI18n
(
locale
,
messages
=
{},
fallbackLocale
,
watcher
)
{
// 兼容旧版本入参
if
(
typeof
locale
!==
'
string
'
)
{
...
...
@@ -245,9 +254,8 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
];
}
if
(
typeof
locale
!==
'
string
'
)
{
locale
=
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
&&
uni
.
getLocale
())
||
LOCALE_EN
;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale
=
getDefaultLocale
();
}
if
(
typeof
fallbackLocale
!==
'
string
'
)
{
fallbackLocale
=
...
...
@@ -269,33 +277,32 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
};
}
else
{
const
appVm
=
getApp
().
$vm
;
watchAppLocale
(
appVm
,
i18n
);
if
(
!
appVm
.
$t
||
!
appVm
.
$i18n
||
ignoreVueI18n
)
{
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
let
isWatchedAppLocale
=
false
;
t
=
function
(
key
,
values
)
{
const
appVm
=
getApp
().
$vm
;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if
(
appVm
)
{
// 触发响应式
appVm
.
$locale
;
return
i18n
.
t
(
key
,
values
);
};
}
else
{
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
const
$i18n
=
appVm
.
$i18n
;
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
;
$i18n
.
silentTranslationWarn
=
true
;
const
msg
=
appVm
.
$t
(
key
,
values
);
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
;
if
(
msg
!==
key
)
{
return
msg
;
if
(
!
isWatchedAppLocale
)
{
isWatchedAppLocale
=
true
;
watchAppLocale
(
appVm
,
i18n
);
}
return
i18n
.
t
(
key
,
$i18n
.
locale
,
values
);
}
;
}
}
return
i18n
.
t
(
key
,
values
)
;
}
;
}
return
t
(
key
,
values
);
};
...
...
packages/uni-i18n/dist/uni-i18n.es.js
浏览文件 @
6cb65c85
...
...
@@ -217,7 +217,6 @@ class I18n {
}
}
const
ignoreVueI18n
=
true
;
function
watchAppLocale
(
appVm
,
i18n
)
{
// 需要保证 watch 的触发在组件渲染之前
if
(
appVm
.
$watchLocale
)
{
...
...
@@ -232,6 +231,16 @@ function watchAppLocale(appVm, i18n) {
});
}
}
function
getDefaultLocale
()
{
if
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
)
{
return
uni
.
getLocale
();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if
(
typeof
global
!==
'
undefined
'
&&
global
.
getLocale
)
{
return
global
.
getLocale
();
}
return
LOCALE_EN
;
}
function
initVueI18n
(
locale
,
messages
=
{},
fallbackLocale
,
watcher
)
{
// 兼容旧版本入参
if
(
typeof
locale
!==
'
string
'
)
{
...
...
@@ -241,9 +250,8 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
];
}
if
(
typeof
locale
!==
'
string
'
)
{
locale
=
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
&&
uni
.
getLocale
())
||
LOCALE_EN
;
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale
=
getDefaultLocale
();
}
if
(
typeof
fallbackLocale
!==
'
string
'
)
{
fallbackLocale
=
...
...
@@ -265,33 +273,32 @@ function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
};
}
else
{
const
appVm
=
getApp
().
$vm
;
watchAppLocale
(
appVm
,
i18n
);
if
(
!
appVm
.
$t
||
!
appVm
.
$i18n
||
ignoreVueI18n
)
{
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
let
isWatchedAppLocale
=
false
;
t
=
function
(
key
,
values
)
{
const
appVm
=
getApp
().
$vm
;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if
(
appVm
)
{
// 触发响应式
appVm
.
$locale
;
return
i18n
.
t
(
key
,
values
);
};
}
else
{
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
const
$i18n
=
appVm
.
$i18n
;
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
;
$i18n
.
silentTranslationWarn
=
true
;
const
msg
=
appVm
.
$t
(
key
,
values
);
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
;
if
(
msg
!==
key
)
{
return
msg
;
if
(
!
isWatchedAppLocale
)
{
isWatchedAppLocale
=
true
;
watchAppLocale
(
appVm
,
i18n
);
}
return
i18n
.
t
(
key
,
$i18n
.
locale
,
values
);
}
;
}
}
return
i18n
.
t
(
key
,
values
)
;
}
;
}
return
t
(
key
,
values
);
};
...
...
packages/uni-i18n/src/vue-i18n.ts
浏览文件 @
6cb65c85
...
...
@@ -6,8 +6,6 @@ import {
LocaleWatcher
,
}
from
'
./I18n
'
const
ignoreVueI18n
=
true
type
Interpolate
=
(
key
:
string
,
values
?:
Record
<
string
,
unknown
>
|
Array
<
unknown
>
...
...
@@ -30,18 +28,16 @@ function watchAppLocale(appVm: any, i18n: I18n) {
}
}
// function getDefaultLocale() {
// if (typeof navigator !== 'undefined') {
// return (navigator as any).userLanguage || navigator.language
// }
// if (typeof plus !== 'undefined') {
// // TODO 待调整为最新的获取语言代码
// return plus.os.language
// }
// return uni.getSystemInfoSync().language
// }
const
i18nInstances
:
I18n
[]
=
[]
function
getDefaultLocale
():
string
{
if
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
)
{
return
uni
.
getLocale
()
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if
(
typeof
global
!==
'
undefined
'
&&
(
global
as
any
).
getLocale
)
{
return
(
global
as
any
).
getLocale
()
}
return
LOCALE_EN
}
export
function
initVueI18n
(
locale
?:
string
,
...
...
@@ -57,9 +53,8 @@ export function initVueI18n(
]
}
if
(
typeof
locale
!==
'
string
'
)
{
locale
=
(
typeof
uni
!==
'
undefined
'
&&
uni
.
getLocale
&&
uni
.
getLocale
())
||
LOCALE_EN
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale
=
getDefaultLocale
()
}
if
(
typeof
fallbackLocale
!==
'
string
'
)
{
fallbackLocale
=
...
...
@@ -74,8 +69,6 @@ export function initVueI18n(
watcher
,
})
i18nInstances
.
push
(
i18n
)
let
t
:
Interpolate
=
(
key
,
values
)
=>
{
if
(
typeof
getApp
!==
'
function
'
)
{
// app view
...
...
@@ -84,31 +77,31 @@ export function initVueI18n(
return
i18n
.
t
(
key
,
values
)
}
}
else
{
const
appVm
=
getApp
().
$vm
watchAppLocale
(
appVm
,
i18n
)
if
(
!
appVm
.
$t
||
!
appVm
.
$i18n
||
ignoreVueI18n
)
{
// if (!locale) {
// i18n.setLocale(getDefaultLocale())
// }
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
let
isWatchedAppLocale
=
false
t
=
function
(
key
,
values
)
{
const
appVm
=
getApp
().
$vm
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if
(
appVm
)
{
// 触发响应式
appVm
.
$locale
return
i18n
.
t
(
key
,
values
)
}
}
else
{
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
const
$i18n
=
appVm
.
$i18n
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
$i18n
.
silentTranslationWarn
=
true
const
msg
=
appVm
.
$t
(
key
,
values
)
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
if
(
msg
!==
key
)
{
return
msg
if
(
!
isWatchedAppLocale
)
{
isWatchedAppLocale
=
true
watchAppLocale
(
appVm
,
i18n
)
}
return
i18n
.
t
(
key
,
$i18n
.
locale
,
values
)
}
return
i18n
.
t
(
key
,
values
)
}
}
return
t
(
key
,
values
)
...
...
packages/uni-mp-alipay/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"my"
,
"__PLATFORM__"
:
"
\"
mp-alipay
\"
"
,
"__PLATFORM_TITLE__"
:
"支付宝小程序"
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -754,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
packages/uni-mp-baidu/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"swan"
,
"__PLATFORM__"
:
"
\"
mp-baidu
\"
"
,
"__PLATFORM_TITLE__"
:
"百度小程序"
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -754,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
packages/uni-mp-core/src/api/locale.ts
浏览文件 @
6cb65c85
...
...
@@ -28,3 +28,7 @@ export const onLocaleChange: typeof uni.onLocaleChange = (fn) => {
onLocaleChangeCallbacks
.
push
(
fn
)
}
}
if
(
typeof
global
!==
'
undefined
'
)
{
;(
global
as
any
).
getLocale
=
getLocale
}
packages/uni-mp-kuaishou/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"ks"
,
"__PLATFORM__"
:
"
\"
mp-kuaishou
\"
"
,
"__PLATFORM_TITLE__"
:
"快手小程序"
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -754,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
packages/uni-mp-qq/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"qq"
,
"__PLATFORM__"
:
"
\"
mp-qq
\"
"
,
"__PLATFORM_TITLE__"
:
"QQ小程序"
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -754,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
packages/uni-mp-toutiao/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"tt"
,
"__PLATFORM__"
:
"
\"
mp-toutiao
\"
"
,
"__PLATFORM_TITLE__"
:
"字节跳动小程序"
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -754,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
packages/uni-mp-weixin/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"wx"
,
"__PLATFORM__"
:
"
\"
mp-weixin
\"
"
,
"__PLATFORM_TITLE__"
:
"微信小程序"
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -718,7 +718,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
packages/uni-quickapp-webview/build.json
浏览文件 @
6cb65c85
...
...
@@ -16,6 +16,7 @@
]
},
"replacements"
:
{
"global"
:
"global"
,
"__GLOBAL__"
:
"qa"
,
"__PLATFORM__"
:
"
\"
quickapp-webview
\"
"
,
"__PLATFORM_TITLE__"
:
"快应用(Webview)版"
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
6cb65c85
...
...
@@ -754,7 +754,10 @@ const onLocaleChange = (fn) => {
if
(
onLocaleChangeCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onLocaleChangeCallbacks
.
push
(
fn
);
}
};
};
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
getLocale
=
getLocale
;
}
const
baseApis
=
{
$on
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录