19declare(strict_types=1);
40 $lower = mb_strtolower(
$text);
41 $ascii = function_exists(
'iconv') ? @iconv(
'UTF-8',
'ASCII//TRANSLIT', $lower) :
false;
43 return is_string($ascii) && $ascii !==
'' ? strtolower($ascii) : $lower;
52 foreach (file($file, FILE_IGNORE_NEW_LINES) ?: [] as $number => $line) {
54 $started = trim($line) ===
'<!-- language file start -->';
57 $parts = explode(
'#:#', trim($line));
58 if (count($parts) < 3) {
61 $folded =
$fold($parts[0]) .
'#:#' .
$fold($parts[1]);
62 $occurrences[$folded][$parts[1]][basename($file)] ??= $number + 1;
67 $files_per_spelling = array_map(
'array_keys', $spellings);
68 $colliding_files = count($spellings) > 1 ? array_values(array_intersect(...array_values($files_per_spelling))) : [];
69 if ($colliding_files !== []) {
70 $duplicates[$folded] = [$spellings, $colliding_files];
77 foreach ([
"txt('" . $identifier .
"'",
'txt("' . $identifier .
'"'] as
$pattern) {
80 'git -C %s grep -n -F %s -- %s 2>/dev/null',
83 escapeshellarg(
'components')
85 foreach ($output as $hit) {
86 $callers[] = implode(
':', array_slice(explode(
':', $hit), 0, 2));
90 return array_values(array_unique($callers));
93echo sprintf(
"%d Identifier mit Varianten, die sich in derselben Sprachdatei nur in Groß-/Kleinschreibung unterscheiden\n\n", count(
$duplicates));
94echo
"| Modul | Varianten | Betroffene Dateien | Fundstellen (Datei:Zeile) | Aufrufer (`txt('…')`) |\n|---|---|---|---|---|\n";
95foreach (
$duplicates as $folded => [$spellings, $colliding_files]) {
96 $module = explode(
'#:#', $folded)[0];
100 $example = $colliding_files[0];
101 foreach ($spellings as $spelling => $lines) {
102 $variants[] =
'`' . $spelling .
'`';
103 $places[] =
'`' . $spelling .
'`: lang/' . $example .
':' . $lines[$example];
105 $callers[] =
'`' . $spelling .
'`: ' . ($found === [] ?
'keine' : implode(
', ', array_slice($found, 0, 5)) . (count($found) > 5 ? sprintf(
' … (+%d)', count($found) - 5) :
''));
107 $affected = count($colliding_files) >= 25
108 ?
'fast alle (' . count($colliding_files) .
')'
109 : implode(
', ', array_map(
static fn(
string $f):
string => substr(
$f, 6, -5), $colliding_files));
110 echo sprintf(
"| `%s` | %s | %s | %s | %s |\n",
$module, implode(
', ', $variants), $affected, implode(
'<br>', $places), implode(
'<br>', $callers));
if(!isset($arguments[0])) if(count( $arguments) > 3) if(! $remove_from_lang &&isset($arguments[2]) &&!is_dir($arguments[2])) $module
foreach($files as $file) $duplicates
$ilias_root
Lists every identifier of the shipped lang/ilias_*.lang files that occurs in one module in spellings ...