diff --git a/faq/index.html b/faq/index.html index 6aff435..0090ac7 100644 --- a/faq/index.html +++ b/faq/index.html @@ -137,6 +137,15 @@ function pick(it, field) { return it[field] ?? ''; } +// One field, two languages: "texto ES\n=== EN ===\ntext EN" +const LANG_SPLIT = /\n\s*===\s*EN\s*===\s*\n/i; +function content(it, field) { + const raw = pick(it, field); + if (typeof raw !== 'string' || !LANG_SPLIT.test(raw)) return raw; + const parts = raw.split(LANG_SPLIT); + return (state.lang === 'en' ? parts[1] : parts[0]) || parts[0] || ''; +} + // Optional language tag on an item (lang / language / idioma) function itemLang(it) { const key = Object.keys(it).find(k => ['lang', 'language', 'idioma'].includes(k.toLowerCase())); @@ -181,10 +190,10 @@ function render() { const card = document.createElement('details'); card.className = 'card'; const sum = document.createElement('summary'); - sum.textContent = pick(it, 'Question') || '—'; + sum.textContent = content(it, 'Question') || '—'; const ans = document.createElement('p'); ans.className = 'ans'; - ans.textContent = pick(it, 'Answer') || ''; + ans.textContent = content(it, 'Answer') || ''; card.append(sum, ans); sec.appendChild(card); });