-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcheckLocalization.php
37 lines (32 loc) · 1.1 KB
/
checkLocalization.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
$localizationPath = __DIR__ . '/assets/localizations';
$refLocalizationPath = $localizationPath . '/en.json';
$refLocalization = json_decode(file_get_contents($refLocalizationPath));
$mandatoryKeyList = array_keys((array)$refLocalization);
$fileList = scandir($localizationPath);
foreach ($fileList as $fileLoop) {
$fileBasenameLoop = basename($fileLoop);
if (substr($fileBasenameLoop, 0, 1) == '.') {
continue;
}
$refLocalizationLoop = json_decode(file_get_contents($localizationPath . '/' . $fileBasenameLoop));
$missingKeyList = [];
foreach ($mandatoryKeyList as $mandatoryKeyLoop) {
if (!property_exists($refLocalizationLoop, $mandatoryKeyLoop)) {
$missingKeyList[] = $mandatoryKeyLoop;
}
}
if (!empty($missingKeyList)) {
logText('Error on ' . $fileBasenameLoop);
logText(' Missing keys:');
foreach ($missingKeyList as $missingKeyLoop) {
logText(' - ' . $missingKeyLoop);
}
} else {
logText($fileBasenameLoop . ' OK');
}
}
function logText(string $text)
{
print($text . "\n");
}