import ar from "./ar.json"; import cn from "./cn.json"; import de from "./de.json"; import en from "./en.json"; import es from "./es.json"; import fa from "./fa.json"; import ko from "./ko.json"; import ms from "./ms.json"; import pt from "./pt.json"; import th from "./th.json"; import tr from "./tr.json"; import vn from "./vn.json"; import id from "./id.json"; import ug from "./ug.json"; import zhHant from "./zhHant.json"; const localesList = [ "en", "cn", "zhHant", "ug", "de", "es", "ar", "id", "ms", "th", "vn", "ko", "pt", "fa", "tr", ]; const messages = { ar, cn, de, en, es, fa, ko, ms, pt, th, tr, vn, zhHant, id, ug }; const LANG_MAP = { cn: 'zh-Hans', zh: 'zh-Hans', zhHans: 'zh-Hans', zhHant: 'zh-Hant', en: 'en', ar: 'ar', de: 'de', es: 'es', fa: 'fa', ko: 'ko', ms: 'ms', pt: 'pt', th: 'th', tr: 'tr', vn: 'vi', vi: 'vi', id: 'id', ug: 'ug', }; /** * 切换应用语言(vue-i18n + 本地存储) * App 端勿调用 uni.setLocale,否则会触发原生重启 */ function switchAppLanguage(type, { locale, lang }) { if (!type || !locale || !lang) return locale.value = type lang.value = type // #ifdef H5 const localeValue = LANG_MAP[type] || 'zh-Hans' uni.setLocale(localeValue) // #endif } export { messages, localesList, LANG_MAP, switchAppLanguage };