Skip to content

Commit

Permalink
Fix at fixMultiLines
Browse files Browse the repository at this point in the history
Fix at fixMultiLines when several lines start with #~ " to keep them in one single line.
  • Loading branch information
apeleteiro authored Oct 19, 2021
1 parent ef2e312 commit f9832ed
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Extractors/Po.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,19 @@ public static function fromString($string, Translations $translations, array $op
protected static function fixMultiLines($line, array $lines, &$i)
{
for ($j = $i, $t = count($lines); $j < $t; ++$j) {
if (substr($line, -1, 1) == '"'
&& isset($lines[$j + 1])
&& substr(trim($lines[$j + 1]), 0, 1) == '"'
) {
$line = substr($line, 0, -1).substr(trim($lines[$j + 1]), 1);
} else {
$i = $j;
break;
if (substr($line, -1, 1) == '"' && isset($lines[$j + 1])) {
$nextLine = trim($lines[$j + 1]);
if (substr($nextLine, 0, 1) == '"') {
$line = substr($line, 0, -1).substr($nextLine, 1);
continue;
}
if (substr($nextLine, 0, 4) == '#~ "') {
$line = substr($line, 0, -1).substr($nextLine, 4);
continue;
}
}
$i = $j;
break;
}

return $line;
Expand Down

0 comments on commit f9832ed

Please sign in to comment.