-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
33 lines (32 loc) · 915 Bytes
/
test.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
<?php
$DIR = 'upload';
$LANG = 'ru-ru';
function test_file($path, $labels) {
$undefined = [];
include_once $path;
foreach ($labels as $label) {
if (!isset($_[$label])) {
$undefined[] = $label;
}
}
return $undefined;
}
$passed = 0;
$failed = 0;
foreach (['admin', 'catalog'] as $path) {
$json = json_decode(file_get_contents($path.'.json'), true);
$json[$LANG.'.php'] = $json['root'];
unset($json['root']);
foreach ($json as $file => $labels) {
$file = implode(DIRECTORY_SEPARATOR, [$DIR, $path, 'language', $LANG, $file]);
$undefined = test_file($file, $labels);
if (!empty($undefined)) {
$failed++;
echo 'Failed ' . $file . PHP_EOL;
echo "\tUndefined: " . implode(', ', $undefined).PHP_EOL;
} else {
$passed++;
}
}
}
echo "Passed: $passed. Failed: $failed";