Skip to content

Commit eb8b20c

Browse files
committed
Recognize inconsistent indentations in phrases
1 parent e2011a0 commit eb8b20c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

extra/_generateDeletedPhrases.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
$indentation = $noIndentation ? "" : "\t";
5656

5757
\sort($missingIdentifiers, \SORT_NATURAL);
58-
$missingIdentifiers = \array_map(
59-
static fn($identifier) => "{$indentation}\t<item name=\"{$identifier}\"/>",
60-
$missingIdentifiers
61-
);
6258

6359
if ($hasDeleteBlock) {
6460
// Find the position of {$indentation}<delete> and {$indentation}</delete>
@@ -67,11 +63,27 @@
6763
$endTag = "\n{$indentation}</delete>\n";
6864
$end = \mb_strpos($data, $endTag);
6965

66+
if ($start === false && $end === false) {
67+
if ($indentation === "") {
68+
$indentation = "\t";
69+
}
70+
71+
$startTag = "\n{$indentation}<delete>\n";
72+
$start = \mb_strpos($data, $startTag);
73+
$endTag = "\n{$indentation}</delete>\n";
74+
$end = \mb_strpos($data, $endTag);
75+
}
76+
7077
if ($start === false || $end === false) {
71-
echo "Could not find the start and end positions.\n";
78+
echo "Could not find the start (" . \get_debug_type($start) . ") and end (" . \get_debug_type($end) . ") positions.\n";
7279
exit(1);
7380
}
7481

82+
$missingIdentifiers = \array_map(
83+
static fn($identifier) => "{$indentation}\t<item name=\"{$identifier}\"/>",
84+
$missingIdentifiers
85+
);
86+
7587
$before = \mb_substr($data, 0, $start + \mb_strlen($startTag));
7688
$after = \mb_substr($data, $end);
7789

@@ -86,6 +98,11 @@
8698
exit(1);
8799
}
88100

101+
$missingIdentifiers = \array_map(
102+
static fn($identifier) => "{$indentation}\t<item name=\"{$identifier}\"/>",
103+
$missingIdentifiers
104+
);
105+
89106
$before = \mb_substr($data, 0, $end + \mb_strlen($endTag));
90107
$after = \mb_substr($data, $end + \mb_strlen($endTag));
91108

0 commit comments

Comments
 (0)