fixed translation bug

This commit is contained in:
2026-05-22 17:18:14 +02:00
parent 472e45d730
commit be01b85569
4 changed files with 58 additions and 22 deletions

View File

@ -1103,12 +1103,13 @@ function bindEditorTransFiltering(entries) {
let visibleMissing = 0;
root.querySelectorAll('.trans-list-item').forEach(row => {
const key = row.dataset.key?.toLowerCase() || '';
const label = row.dataset.label?.toLowerCase() || '';
const rowType = row.dataset.type || '';
const german = row.querySelector('.trans-source-text')?.textContent?.toLowerCase()
|| row.querySelector('[data-field="german"]')?.value?.toLowerCase() || '';
const val = row.querySelector('[data-field="translation"]')?.value?.toLowerCase() || '';
const show = (!type || rowType === type) &&
(!text || key.includes(text) || german.includes(text) || val.includes(text));
(!text || key.includes(text) || label.includes(text) || german.includes(text) || val.includes(text));
row.classList.toggle('trans-row-hidden', !show);
if (show) {
visible++;

View File

@ -350,14 +350,15 @@ function applyFilters() {
let visibleMissing = 0;
items.forEach(row => {
const key = row.dataset.key?.toLowerCase()
const key = row.dataset.key?.toLowerCase() || '';
const label = row.dataset.label?.toLowerCase()
|| row.querySelector('.trans-key-text')?.textContent?.toLowerCase() || '';
const rowType = row.dataset.type || '';
const german = row.querySelector('.trans-source-text')?.textContent?.toLowerCase()
|| row.querySelector('[data-field="german"]')?.value?.toLowerCase() || '';
const val = row.querySelector('[data-field="translation"]')?.value?.toLowerCase() || '';
const show = (!type || rowType === type) &&
(!text || key.includes(text) || german.includes(text) || val.includes(text));
(!text || key.includes(text) || label.includes(text) || german.includes(text) || val.includes(text));
row.classList.toggle('trans-row-hidden', !show);
if (show) {
visible++;

View File

@ -25,6 +25,17 @@ export function germanFor(entry) {
return entry.germanText || normalizeTranslations(entry.translations)[SOURCE_LANG] || entry.key || '';
}
/** Key column label (short id for questions/options; catalog key for UI strings). */
export function entryDisplayKey(entry) {
if (entry.displayKey) return entry.displayKey;
if (entry.type === 'question' || entry.type === 'answer_option') {
const id = entry.entityId || '';
const sep = id.lastIndexOf('__');
return sep >= 0 ? id.slice(sep + 2) : id;
}
return entry.key || '';
}
export function translationFor(entry, lang) {
return normalizeTranslations(entry.translations)[lang] || '';
}
@ -188,7 +199,8 @@ export function translationListHeaderHTML(targetLangLabel, sourceLabel = 'German
}
export function translationRowHTML(entry, idx, { targetLang, editable = true }) {
const key = entry.key || '';
const lookupKey = entry.key || '';
const label = entryDisplayKey(entry);
const german = germanFor(entry);
const val = translationFor(entry, targetLang);
const missing = !val.trim();
@ -201,10 +213,10 @@ export function translationRowHTML(entry, idx, { targetLang, editable = true })
return `
<div class="trans-list-item ${missing ? 'trans-list-item-missing' : ''}"
data-idx="${idx}" data-type="${entry.type}" data-key="${escHtml(key)}" data-missing="${missing ? '1' : '0'}">
data-idx="${idx}" data-type="${entry.type}" data-key="${escHtml(lookupKey)}" data-label="${escHtml(label)}" data-missing="${missing ? '1' : '0'}">
<div class="trans-list-key">
${typeBadge(entry.type)}
<span class="trans-key-text" title="${escHtml(key)}">${escHtml(key)}</span>
<span class="trans-key-text" title="${escHtml(lookupKey)}">${escHtml(label)}</span>
</div>
<div class="trans-list-source">${sourceCell}</div>
<input type="text" class="trans-cell-input ${missing ? 'trans-input-missing' : ''}"