Add files via upload

This commit is contained in:
公明
2026-07-16 19:30:29 +08:00
committed by GitHub
parent 2147623543
commit 8e42e72e42
13 changed files with 2283 additions and 67 deletions
+4 -3
View File
@@ -66,7 +66,9 @@
const skipText = el.getAttribute('data-i18n-skip-text') === 'true';
const isFormControl = (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA');
const attrList = el.getAttribute('data-i18n-attr');
const text = i18next.t(key);
const translated = i18next.t(key);
// 缺键时保留模板中的后备文案,避免页面直接显示 assets.project 一类内部键名。
const text = translated && translated !== key ? translated : '';
// 仅当元素无子元素(仅文本或空)时才替换文本,避免覆盖卡片内的数字、子节点等;input/textarea 永不设置 textContent
const hasNoElementChildren = !el.querySelector('*');
if (!skipText && !isFormControl && hasNoElementChildren && text && typeof text === 'string') {
@@ -80,7 +82,7 @@
var val = text;
if (attr === 'title' && titleKey) {
var titleText = i18next.t(titleKey);
if (titleText && typeof titleText === 'string') val = titleText;
if (titleText && titleText !== titleKey && typeof titleText === 'string') val = titleText;
}
if (val && typeof val === 'string') {
el.setAttribute(attr, val);
@@ -233,4 +235,3 @@
});
});
})();