fix(多语言): 将售后待付款组件的翻译放到zh-cn/common文件中

This commit is contained in:
2026-01-06 17:57:48 +08:00
parent 9a63b5ff4e
commit 618babf5bf
4 changed files with 29 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
import { langConfig } from './config-external.js';
var locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
// 缓存已加载的语言包
var loadedLangPacks = {};
const loadedLangPacks = {};
// 处理页面目录映射
function processRoutePath(route) {
@@ -64,6 +64,8 @@ export default {
let _this = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return;
const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
var value = '';
try {
//公共语言包(同步加载)
@@ -72,7 +74,7 @@ export default {
//当前页面语言包(同步加载)
let route = _this.route;
let langPath = processRoutePath(route);
// console.log(`当前页面语言包路径: ${langPath}`);
console.log(`当前语言: ${locale}, 当前页面语言包路径: ${langPath}`);
// 加载当前页面语言包
let currentPageLang = loadLangPackSync(locale, langPath);
@@ -113,7 +115,7 @@ export default {
if (value == undefined || (value == 'title' && field == 'title')) value = ''; // field
// 多语言调试,注释后可以关闭控制台输出
// console.log(`字段: ${field}, 值: ${value}`)
console.log(`字段: ${field}, 值: ${value}`)
return value;
},
/**
@@ -126,10 +128,14 @@ export default {
if (!_this) return;
uni.setStorageSync("lang", value);
locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
// 清空已加载的语言包缓存
loadedLangPacks = {};
for (let key in loadedLangPacks) {
if (!key.startsWith(locale)) {
delete loadedLangPacks[key];
}
}
this.refresh();
@@ -141,7 +147,7 @@ export default {
refresh() {
let _this = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return;
locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
this.title(this.lang("title"));