Translate pages, areas, menus, forms and posts field by field instead of rebuilding them

A site can have further languages (Settings → Languages). A page is built once; each language
adds only its texts, keyed by the stable block IDs, plus its own address under /en/… (ADR 111,
document schema v27, migration 20261009000100 for page_translation).

- Editor: DE | EN switch, a list of all texts with original, state (missing, translated,
  original changed) and filter; structure stays with the main language. Undo, drafts,
  publishing and revisions cover all languages at once.
- Website: /en and translated slugs, lang, canonical, hreflang with x-default, og:locale,
  sitemap; links to translated pages follow the language; a language switch block.
- Header, footer and linked sections translate the same way; menu entries carry labels per
  language; fixed template texts come from a small dictionary.
- Forms: labels, help, options, button and success message per language; messages and the
  step script speak the language, the submission and the email stay in the main language.
- Posts, archives, category names, consent text and the 404 page follow the language.
- Single-language sites see none of it and never touch the new table.

The forms administration becomes an overview with one row per form and its own edit page;
fields are one line each with details collapsed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5.5 committed 2026-10-09 16:56:52 +02:00
1 parent c7705b7083
commit e15b2517b1
51 files changed
+3045 -219

No files matched your search

+16 -10
View File
@@ -16,6 +16,10 @@
};
const setup = form => {
// Die Texte des Skripts. Auf einer übersetzten Seite bringt das Formular sie mit (ADR 111).
let texts = {};
try { texts = JSON.parse(form.dataset.texts || '{}'); } catch { texts = {}; }
const t = (key, fallback) => texts[key] || fallback;
const rules = [...form.querySelectorAll('[data-show-if]')];
const steps = [...form.querySelectorAll('[data-step]')];
const submit = form.querySelector('.cms-button[type="submit"]');
@@ -54,27 +58,27 @@
if (wantsSummary) {
summary = el('div', 'form-step form-summary');
summary.setAttribute('data-step', '');
const title = el('p', 'form-step-title', 'Zusammenfassung');
const title = el('p', 'form-step-title', t('summary', 'Zusammenfassung'));
title.tabIndex = -1;
summary.append(title, el('p', 'form-step-intro', 'Bitte prüfen Sie Ihre Angaben. Über „Ändern“ kommen Sie zum jeweiligen Schritt zurück.'));
summary.append(title, el('p', 'form-step-intro', t('summaryIntro', 'Bitte prüfen Sie Ihre Angaben. Über „Ändern“ kommen Sie zum jeweiligen Schritt zurück.')));
summary.append(el('div', 'form-summary-body'));
steps[steps.length - 1].after(summary);
steps.push(summary);
}
const progress = el('ol', 'form-progress');
progress.setAttribute('aria-label', 'Schritte des Formulars');
progress.setAttribute('aria-label', t('steps', 'Schritte des Formulars'));
steps.forEach((step, index) => {
const item = el('li', 'form-progress-step');
item.append(el('span', 'form-progress-number', String(index + 1)), el('span', 'form-progress-title', step.querySelector('.form-step-title')?.textContent.trim() || `Schritt ${index + 1}`));
item.append(el('span', 'form-progress-number', String(index + 1)), el('span', 'form-progress-title', step.querySelector('.form-step-title')?.textContent.trim() || `${t('step', 'Schritt')} ${index + 1}`));
progress.append(item);
});
form.insertBefore(progress, steps[0]);
const nav = el('div', 'form-step-nav');
const back = el('button', 'button cms-button form-step-back', 'Zurück');
const back = el('button', 'button cms-button form-step-back', t('back', 'Zurück'));
back.type = 'button';
const next = el('button', 'button cms-button form-step-next', 'Weiter');
const next = el('button', 'button cms-button form-step-next', t('next', 'Weiter'));
next.type = 'button';
nav.append(back, next);
(submit || form).before(nav);
@@ -90,8 +94,10 @@
if (!picked.length) return '';
const unit = field.querySelector('.form-unit')?.textContent || '';
return picked.map(input => {
if (input.type === 'checkbox' && input.value === 'ja' && field.querySelector('.check-row label')) return 'Ja';
if (input.type === 'checkbox' && input.value === 'ja' && field.querySelector('.check-row label')) return t('yes', 'Ja');
if (input.tagName === 'SELECT') return input.selectedOptions[0]?.textContent || input.value;
// Angezeigt wird die Beschriftung der Option - auf einer übersetzten Seite die übersetzte.
if (input.type === 'checkbox' || input.type === 'radio') return (input.labels?.[0]?.querySelector('.form-choice-text') ?? input.labels?.[0])?.textContent.trim() || input.value;
return input.value + (unit ? ` ${unit}` : '');
}).join(', ');
};
@@ -103,8 +109,8 @@
if (step === summary || step.hasAttribute('data-inactive')) return;
const block = el('section', 'form-summary-step');
const head = el('div', 'form-summary-head');
head.append(el('h4', 'form-summary-title', step.querySelector('.form-step-title')?.textContent.trim() || `Schritt ${index + 1}`));
const change = el('button', 'form-summary-change', 'Ändern');
head.append(el('h4', 'form-summary-title', step.querySelector('.form-step-title')?.textContent.trim() || `${t('step', 'Schritt')} ${index + 1}`));
const change = el('button', 'form-summary-change', t('change', 'Ändern'));
change.type = 'button';
change.setAttribute('aria-label', `${head.firstChild.textContent} ändern`);
change.addEventListener('click', () => show(index));
@@ -153,7 +159,7 @@
if (group.closest('[data-inactive]')) continue;
const note = group.querySelector('.field-error[data-live]');
if (!group.querySelector('input:checked')) {
if (!note) group.append(Object.assign(el('p', 'field-error', 'Bitte wähle mindestens eine Option.'), { dataset: { live: '' } }));
if (!note) group.append(Object.assign(el('p', 'field-error', t('chooseOne', 'Bitte wähle mindestens eine Option.')), { dataset: { live: '' } }));
else note.hidden = false;
group.classList.add('has-error');
group.querySelector('input')?.focus();