From 888c6080cebcdfba36415c2b9e5cda9fbc222b77 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Fri, 28 Nov 2025 00:26:28 +0100 Subject: [PATCH] yxc --- public/assets/i18n/de.json | 2 +- tools/i18n_collect_keys.php | 64 +++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/public/assets/i18n/de.json b/public/assets/i18n/de.json index 2a9f11e..8e9dd01 100644 --- a/public/assets/i18n/de.json +++ b/public/assets/i18n/de.json @@ -5,4 +5,4 @@ "flag": "🇩🇪", "enabled": true } -} +} \ No newline at end of file diff --git a/tools/i18n_collect_keys.php b/tools/i18n_collect_keys.php index d40e63b..8da1d9b 100644 --- a/tools/i18n_collect_keys.php +++ b/tools/i18n_collect_keys.php @@ -148,6 +148,11 @@ function addKeyToData(array &$data, string $key, ?string $defaultValue = null): return; } + // Dynamische Keys mit Variablen wie pages.$pageKey.meta.title ignorieren + if (strpos($key, '$') !== false) { + return; + } + $default = ($defaultValue !== null && $defaultValue !== '') ? $defaultValue : $key; @@ -161,7 +166,7 @@ function addKeyToData(array &$data, string $key, ?string $defaultValue = null): /** * Extrahiert den „aktuellen Inhalt“ eines data-i18n-Elements - * ganz grob über Regex: + * grob über Regex: * ... data-i18n="key"> Inhalt $defaultText) { } } +// ------------------------------- +// 5b) Metadaten für alle Landingpages ergänzen +// /public/landingpage/{slug}/ → pages.{slug}.meta.{title,description} +// ------------------------------- +$landingRoot = $baseDir . '/public/landingpage'; +if (is_dir($landingRoot)) { + foreach (new DirectoryIterator($landingRoot) as $entry) { + if ($entry->isDot() || !$entry->isDir()) { + continue; + } + + $slug = $entry->getFilename(); + + // sehr simple Heuristik: Landingpage gilt als "aktiv", wenn irgendeine .php drin liegt + $hasPhp = false; + foreach (new DirectoryIterator($entry->getPathname()) as $file) { + if ($file->isFile() && strtolower($file->getExtension()) === 'php') { + $hasPhp = true; + break; + } + } + if (!$hasPhp) { + continue; + } + + $titleKey = "pages.$slug.meta.title"; + $descKey = "pages.$slug.meta.description"; + + if (!dotKeyExists($data, $titleKey)) { + $defaultTitle = '{{primary_domain}} – ' . ucfirst($slug); + addDotKey($data, $titleKey, $defaultTitle); + $newKeys[] = $titleKey; + $addedCount++; + } + + if (!dotKeyExists($data, $descKey)) { + $defaultDesc = 'Beschreibung für ' . ucfirst($slug) . ' auf {{primary_domain}}'; + addDotKey($data, $descKey, $defaultDesc); + $newKeys[] = $descKey; + $addedCount++; + } + } +} + // ------------------------------- // 6) de.json zurückschreiben // ------------------------------- @@ -373,7 +434,6 @@ if (!empty($newKeys)) { if ($isCli) { echo $output; } else { - // Header nur setzen, wenn noch nichts gesendet wurde if (!headers_sent()) { header('Content-Type: text/plain; charset=utf-8'); }