This commit is contained in:
2025-11-28 01:23:23 +01:00
parent 2e4bf5000c
commit 10932da99f
2 changed files with 38 additions and 220 deletions

View File

@@ -10,6 +10,12 @@
*
* und trägt fehlende Keys in public/assets/i18n/de.json ein.
*
* WICHTIG (angepasst):
* - partials/structure/{name}.php wird jetzt unter
* partials.structure.{name}.{key}
* abgelegt (nicht mehr im Root).
* - meta-Keys werden in jedem Block an erste Stelle gesetzt.
*
* Aufruf:
* - CLI: php tools/i18n_collect_keys.php
* - HTTP: https://.../tools/i18n_collect_keys.php
@@ -344,13 +350,12 @@ foreach ($scanDirs as $dir) {
$key = "pages.$slug.sections.main.$key";
// 4c) partials/structure/{name}.php → z.B. header.*, footer.*
// 4c) partials/structure/{name}.php → z.B. header.*, footer.*, layout_*
} elseif (preg_match('~^partials/structure/([^/]+)\.(php|html?|phtml)$~', $relPath, $m)) {
$section = $m[1]; // header, footer, layout_start, layout_end, app_config, ...
// Für header/footer/… legen wir den Root so an, wie die Datei heißt:
// header_slogan → header.header_slogan
$key = $section . '.' . $key;
// NEU: unter partials.structure.{section}.{key}
$key = "partials.structure.$section.$key";
}
}
@@ -434,6 +439,34 @@ if (is_dir($landingRoot)) {
}
}
// -------------------------------
// 5c) meta-Keys in jedem Block nach vorne ziehen
// -------------------------------
function reorderMetaFirstRecursive(array &$node): void
{
// Zuerst rekursiv in die Tiefe gehen
foreach ($node as $k => &$v) {
if (is_array($v)) {
reorderMetaFirstRecursive($v);
}
}
unset($v);
// Wenn es in diesem Block einen 'meta'-Key gibt, diesen an erste Stelle setzen
if (array_key_exists('meta', $node) && count($node) > 1) {
$metaValue = $node['meta'];
unset($node['meta']);
// Rest in aktueller Reihenfolge behalten
$rest = $node;
// Neu zusammensetzen: meta zuerst
$node = ['meta' => $metaValue] + $rest;
}
}
reorderMetaFirstRecursive($data);
// -------------------------------
// 6) de.json zurückschreiben
// -------------------------------