fix: 增强国际化函数的健壮性,处理无效键值

This commit is contained in:
piexian committed 2026-04-11 22:04:10 +08:00
1 parent 7a01193593
commit e2931058cb
2 files changed
+6 -1

No files matched your search

+1
View File
@@ -647,6 +647,7 @@ let _dirty = {}; // { "section.key": newValue }
let _activeTab = SCHEMA_DEF[0].id;
function tr(key, params, fallback) {
if (!key) return fallback ?? '';
const value = t(key, params);
return value === key ? (fallback ?? key) : value;
}
+5 -1
View File
@@ -32,7 +32,11 @@
return b||'zh';
}
function get(o,k){ for(var p=k.split('.'),i=0;i<p.length;i++){if(o==null)return; o=o[p[i]];} return o; }
function get(o,k){
if(typeof k!=='string' || !k) return;
for(var p=k.split('.'),i=0;i<p.length;i++){if(o==null)return; o=o[p[i]];}
return o;
}
function merge(base, extra){
if(extra==null) return base;