Skip to content

Commit 50cdb75

Browse files
Merge pull request #399 from N1ebieski/Fix-Translation-detection-breaks-when-there-are-blank-lines-in-a-JSON-file-#42
Fix Translation detection breaks when there are blank lines in a JSON file
2 parents 59678dc + 56eca94 commit 50cdb75

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

php-templates/translations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function linesFromJsonFile($file)
133133
array_keys($json),
134134
);
135135
$result = [];
136-
$searchRange = 2;
136+
$searchRange = 5;
137137

138138
foreach ($encoded as $index => $keys) {
139139
// Pretty likely to be on the line that is the index, go happy path first
@@ -142,7 +142,7 @@ protected function linesFromJsonFile($file)
142142
continue;
143143
}
144144

145-
// Search around the index, like to be within 2 lines
145+
// Search around the index, likely to be within $searchRange lines
146146
$start = max(0, $index - $searchRange);
147147
$end = min($index + $searchRange, count($lines) - 1);
148148
$current = $start;

src/templates/translations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ $translator = new class
133133
array_keys($json),
134134
);
135135
$result = [];
136-
$searchRange = 2;
136+
$searchRange = 5;
137137
138138
foreach ($encoded as $index => $keys) {
139139
// Pretty likely to be on the line that is the index, go happy path first
@@ -142,7 +142,7 @@ $translator = new class
142142
continue;
143143
}
144144
145-
// Search around the index, like to be within 2 lines
145+
// Search around the index, likely to be within $searchRange lines
146146
$start = max(0, $index - $searchRange);
147147
$end = min($index + $searchRange, count($lines) - 1);
148148
$current = $start;

0 commit comments

Comments
 (0)