From f1e6938af4563b218daa9dca934903544968f5b3 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Thu, 27 Nov 2025 23:54:05 +0100 Subject: [PATCH] i18 --- tools/i18n_collect_keys.php | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/tools/i18n_collect_keys.php b/tools/i18n_collect_keys.php index a920a85..d40e63b 100644 --- a/tools/i18n_collect_keys.php +++ b/tools/i18n_collect_keys.php @@ -113,6 +113,9 @@ function simpleKeyExistsRecursive(array $data, string $key): bool /** * Fügt einen einfachen Key unter $data['auto'] hinzu, * sofern er nicht irgendwo in der Struktur bereits existiert. + * + * WICHTIG: $defaultValue ist explizit nullable, um + * deprecation unter PHP 8.4+ zu vermeiden. */ function addSimpleKey(array &$data, string $key, ?string $defaultValue = null): void { @@ -124,13 +127,12 @@ function addSimpleKey(array &$data, string $key, ?string $defaultValue = null): $data['auto'] = []; } - // Default: übergebener Wert oder der Key selbst - $value = ($defaultValue !== null && $defaultValue !== '') - ? $defaultValue - : $key; + if ($defaultValue === null || $defaultValue === '') { + $defaultValue = $key; + } if (!array_key_exists($key, $data['auto'])) { - $data['auto'][$key] = $value; + $data['auto'][$key] = $defaultValue; } } @@ -159,8 +161,9 @@ function addKeyToData(array &$data, string $key, ?string $defaultValue = null): /** * Extrahiert den „aktuellen Inhalt“ eines data-i18n-Elements - * grob über Regex: + * ganz grob über Regex: * ... data-i18n="key"> Inhalt Text< - $inlineText = extractInlineTextForDataI18n( - $content, - $fullOffset, - strlen($fullMatch) - ); + $inlineText = extractInlineTextForDataI18n($content, $fullOffset, strlen($fullMatch)); if (!array_key_exists($key, $keysWithDefaults)) { $keysWithDefaults[$key] = $inlineText; @@ -379,7 +373,7 @@ if (!empty($newKeys)) { if ($isCli) { echo $output; } else { - // Nur Header setzen, wenn noch keine gesendet wurden + // Header nur setzen, wenn noch nichts gesendet wurde if (!headers_sent()) { header('Content-Type: text/plain; charset=utf-8'); }