Files
Adminator 1e51ef7def Nachtrag: alle bisher untracked Ordner + hängende Änderungen mit-committen
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/
- 12 code-workspace-Files
- STATUS-*.md
- viele M/D/R-Änderungen an bereits getrackten Files
- .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-08 02:27:02 +02:00

59 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* Prüft i18n-Files: pro supportedLanguage muss eine JSON-Datei existieren.
* Plus: Easy-Variante muss alle Keys der Standard-Variante haben.
*/
function check_i18n(string $dir, array $m, Report $r): void {
if (empty($m['supportedLanguages']) || !is_array($m['supportedLanguages'])) {
$r->warn("Keine supportedLanguages deklariert");
return;
}
$i18nDir = "$dir/public/i18n";
if (!is_dir($i18nDir)) {
$r->fail("Verzeichnis 'public/i18n/' fehlt — pro Sprache eine JSON-Datei erwartet");
return;
}
$langData = [];
foreach ($m['supportedLanguages'] as $lang) {
$file = "$i18nDir/$lang.json";
if (!file_exists($file)) {
$r->fail("i18n-File fehlt: public/i18n/$lang.json");
continue;
}
$data = json_decode(file_get_contents($file), true);
if (!is_array($data)) {
$r->fail("i18n-File '$lang.json' ist kein valides JSON");
continue;
}
$langData[$lang] = $data;
$r->ok("i18n '$lang.json': " . count($data) . " Keys");
}
// Easy-Pflicht: für jede Sprache mit -standard muss -easy existieren
$standards = array_filter(array_keys($langData), fn($k) => str_ends_with($k, '-standard'));
foreach ($standards as $stdLang) {
$easyLang = str_replace('-standard', '-easy', $stdLang);
if (!isset($langData[$easyLang])) {
$r->fail("Easy-Sprache fehlt: '$easyLang' (Pflicht für jedes -standard)");
continue;
}
// Keys vergleichen
$stdKeys = array_keys($langData[$stdLang]);
$easyKeys = array_keys($langData[$easyLang]);
$missing = array_diff($stdKeys, $easyKeys);
if ($missing) {
$r->fail("'$easyLang' hat fehlende Keys gegenüber '$stdLang'", array_values($missing));
} else {
$r->ok("'$easyLang' deckt alle Keys von '$stdLang' ab");
}
$extra = array_diff($easyKeys, $stdKeys);
if ($extra) {
$r->warn("'$easyLang' hat zusätzliche Keys, die in '$stdLang' fehlen", array_values($extra));
}
}
}