微信小程序发布试用版本
This commit is contained in:
44
lang/i18n.js
44
lang/i18n.js
@@ -69,20 +69,40 @@ if (i18nEnable) {
|
||||
`);
|
||||
let initLanguageAfter = () => {
|
||||
function $i18n(e) {
|
||||
// #ifdef VUE3
|
||||
return i18n.global.messages[i18n.global.locale][e]
|
||||
// #endif
|
||||
return i18n.messages[i18n.locale][e]
|
||||
try {
|
||||
// #ifdef VUE3
|
||||
// 安全检查:确保 i18n.global 存在
|
||||
if (i18n && i18n.global && i18n.global.messages && i18n.global.locale) {
|
||||
return i18n.global.messages[i18n.global.locale][e]
|
||||
}
|
||||
// #endif
|
||||
// VUE2 或 fallback
|
||||
if (i18n && i18n.messages && i18n.locale) {
|
||||
return i18n.messages[i18n.locale][e]
|
||||
}
|
||||
// 如果 i18n 未初始化,返回空字符串或默认值
|
||||
return ''
|
||||
} catch (error) {
|
||||
console.error('[i18n] 获取翻译文本失败:', error)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
setTimeout(function() {
|
||||
// 底部tabbar更新(仅处理国际化文本,不做权限控制)
|
||||
$i18n('tabbar').split(',').forEach((text, index) => {
|
||||
uni.setTabBarItem({
|
||||
index,
|
||||
text,
|
||||
complete: () => {}
|
||||
})
|
||||
})
|
||||
try {
|
||||
// 底部tabbar更新(仅处理国际化文本,不做权限控制)
|
||||
const tabbarText = $i18n('tabbar')
|
||||
if (tabbarText) {
|
||||
tabbarText.split(',').forEach((text, index) => {
|
||||
uni.setTabBarItem({
|
||||
index,
|
||||
text,
|
||||
complete: () => {}
|
||||
})
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[i18n] 更新 tabbar 失败:', error)
|
||||
}
|
||||
}, 1)
|
||||
}
|
||||
initLanguageAfter()
|
||||
|
||||
Reference in New Issue
Block a user