Skip to content

Commit f3c5b26

Browse files
roberttwangclaude
andcommitted
fix(web): translate 我的知识库 in English mode and stop mangling user titles
The personal knowledge connector view (#1434) shipped copy that is not in i18n-en.js, so English mode showed Chinese headings, buttons, form hints and connector-type field labels, and the fragment translator turned interpolated sentences into mixed text such as "单用户保留最Last 30 days内最多 2000" or "累计调用 6 times · 文档命中/Read 6 times". - Add the missing static copy (gallery, cards, drawer, connector-type fields, notices, toasts) to i18n-en.js. - Render sentences with numbers through lfT() instead of relying on fragment rewrites. - Mark connector names, document/source titles and caller labels with data-i18n-data so a chat title like "…规则(INV-RULE-9),然后…" is no longer rewritten into "…规则 (INV-RULE-9), 然后…". - Drop caller sub-labels that only repeat the role/node name or the kind already shown on the badge ("开发实现 · 开发实现"). Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent fd039e5 commit f3c5b26

4 files changed

Lines changed: 251 additions & 42 deletions

File tree

‎web/app/knowledge-refs.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ window.editKnowledgeRefs = async function editKnowledgeRefs(project, refs, save)
9292
enabled.type = 'checkbox';
9393
const previous = (refs || []).find(r => getRefId(r) === s.id);
9494
enabled.checked = !!previous;
95+
srvTitle.dataset.i18nData = '';
9596
srvTitle.append(enabled, document.createTextNode(s.name || s.id));
9697
const srvId = document.createElement('span');
9798
srvId.className = 'kr-service-id';
@@ -135,7 +136,8 @@ window.editKnowledgeRefs = async function editKnowledgeRefs(project, refs, save)
135136
const sourcesInput = document.createElement('input');
136137
sourcesInput.className = 'kr-control';
137138
sourcesInput.placeholder = '来源 ID,以逗号分隔';
138-
sourcesInput.setAttribute('aria-label', (s.name || s.id) + '允许的来源 ID');
139+
sourcesInput.dataset.i18nData = '';
140+
sourcesInput.setAttribute('aria-label', lfT(`${s.name || s.id}允许的来源 ID`, `Allowed source IDs for ${s.name || s.id}`));
139141
sourcesInput.value = (previous?.sources || []).join(', ');
140142
adv.append(advSum, sourcesInput);
141143

@@ -163,7 +165,7 @@ window.editKnowledgeRefs = async function editKnowledgeRefs(project, refs, save)
163165
allowCount.textContent = '请选择至少一个子知识库';
164166
allowCount.className = 'kr-count warn';
165167
} else {
166-
allowCount.textContent = `已选 ${ids.size} 个子知识库`;
168+
allowCount.textContent = lfT(`已选 ${ids.size} 个子知识库`, `${ids.size} ${ids.size === 1 ? 'sub-source' : 'sub-sources'} selected`);
167169
allowCount.className = 'kr-count ok';
168170
}
169171
} else {
@@ -203,10 +205,12 @@ window.editKnowledgeRefs = async function editKnowledgeRefs(project, refs, save)
203205
box.className = 'kr-source-info';
204206
const nm = document.createElement('span');
205207
nm.className = 'kr-source-name';
208+
nm.dataset.i18nData = '';
206209
nm.textContent = info.name;
207210
const meta = document.createElement('span');
208211
meta.className = 'kr-source-meta';
209-
meta.textContent = info.space ? `空间:${info.space}` : source.id;
212+
meta.dataset.i18nData = '';
213+
meta.textContent = info.space ? lfT(`空间:${info.space}`, `Space: ${info.space}`) : source.id;
210214
box.append(nm, meta);
211215
row.append(cb, box);
212216

@@ -248,7 +252,7 @@ window.editKnowledgeRefs = async function editKnowledgeRefs(project, refs, save)
248252
const selected = mode.value === 'allowlist' ? [...selectedSet()] : [];
249253
if (mode.value === 'allowlist' && !selected.length) {
250254
if (silent) return { error: '请选择至少一个子知识库' };
251-
throw new Error(`请为「${s.name || s.id}」选择至少一个子知识库`);
255+
throw new Error(lfT(`请为「${s.name || s.id}」选择至少一个子知识库`, `Select at least one sub-source for “${s.name || s.id}”`));
252256
}
253257
return { connectorId: s.id, mode: mode.value, sources: selected };
254258
});

0 commit comments

Comments
 (0)