|
|
|
@ -34,7 +34,10 @@ const i18n = createI18n({
|
|
|
|
locale: getSavedLocale(),
|
|
|
|
locale: getSavedLocale(),
|
|
|
|
fallbackLocale: DEFAULT_LOCALE,
|
|
|
|
fallbackLocale: DEFAULT_LOCALE,
|
|
|
|
globalInjection: true,
|
|
|
|
globalInjection: true,
|
|
|
|
messages
|
|
|
|
messages,
|
|
|
|
|
|
|
|
missingWarn: false,
|
|
|
|
|
|
|
|
fallbackWarn: false,
|
|
|
|
|
|
|
|
missing: (locale, key) => key
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const literalMap = {
|
|
|
|
const literalMap = {
|
|
|
|
@ -81,6 +84,15 @@ const literalMap = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function applyTabBarLanguage() {
|
|
|
|
function applyTabBarLanguage() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const pages = getCurrentPages()
|
|
|
|
|
|
|
|
if (!pages || pages.length === 0) return
|
|
|
|
|
|
|
|
const currentPage = pages[pages.length - 1]
|
|
|
|
|
|
|
|
if (!currentPage) return
|
|
|
|
|
|
|
|
const route = currentPage.route || ''
|
|
|
|
|
|
|
|
const tabBarPages = ['pages/index', 'pages/report', 'pages/work', 'pages/mine']
|
|
|
|
|
|
|
|
if (!tabBarPages.includes(route)) return
|
|
|
|
|
|
|
|
|
|
|
|
const labels = [
|
|
|
|
const labels = [
|
|
|
|
i18n.global.t('tab.home'),
|
|
|
|
i18n.global.t('tab.home'),
|
|
|
|
i18n.global.t('tab.report'),
|
|
|
|
i18n.global.t('tab.report'),
|
|
|
|
@ -88,14 +100,13 @@ function applyTabBarLanguage() {
|
|
|
|
i18n.global.t('tab.mine')
|
|
|
|
i18n.global.t('tab.mine')
|
|
|
|
]
|
|
|
|
]
|
|
|
|
labels.forEach((text, index) => {
|
|
|
|
labels.forEach((text, index) => {
|
|
|
|
try {
|
|
|
|
|
|
|
|
uni.setTabBarItem({
|
|
|
|
uni.setTabBarItem({
|
|
|
|
index,
|
|
|
|
index,
|
|
|
|
text
|
|
|
|
text
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function getCurrentLocale() {
|
|
|
|
export function getCurrentLocale() {
|
|
|
|
@ -106,9 +117,6 @@ export function setLocale(locale) {
|
|
|
|
const nextLocale = normalizeLocale(locale)
|
|
|
|
const nextLocale = normalizeLocale(locale)
|
|
|
|
i18n.global.locale.value = nextLocale
|
|
|
|
i18n.global.locale.value = nextLocale
|
|
|
|
uni.setStorageSync(LOCALE_STORAGE_KEY, nextLocale)
|
|
|
|
uni.setStorageSync(LOCALE_STORAGE_KEY, nextLocale)
|
|
|
|
if (typeof uni.setLocale === 'function') {
|
|
|
|
|
|
|
|
uni.setLocale(nextLocale)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
applyTabBarLanguage()
|
|
|
|
applyTabBarLanguage()
|
|
|
|
uni.$emit(LOCALE_CHANGE_EVENT, nextLocale)
|
|
|
|
uni.$emit(LOCALE_CHANGE_EVENT, nextLocale)
|
|
|
|
return nextLocale
|
|
|
|
return nextLocale
|
|
|
|
|