From 6dee5deafcb7cb1d3d66bc8d21ddbb9698054ab1 Mon Sep 17 00:00:00 2001 From: Ladislav Brychta <74542573+lbfeenix@users.noreply.github.com> Date: Tue, 17 Nov 2020 11:41:45 +0100 Subject: [PATCH 1/2] Multiline disabled translations --- src/Loader/PoLoader.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Loader/PoLoader.php b/src/Loader/PoLoader.php index 7e6d2f43..cfa37703 100644 --- a/src/Loader/PoLoader.php +++ b/src/Loader/PoLoader.php @@ -26,9 +26,14 @@ public function loadString(string $string, Translations $translations = null): T //Multiline while (substr($line, -1, 1) === '"' && $nextLine !== false - && substr(trim($nextLine), 0, 1) === '"' + && (substr(trim($nextLine), 0, 1) === '"' || substr(trim($nextLine), 0, 4) === '#~ "') ) { - $line = substr($line, 0, -1).substr(trim($nextLine), 1); + if (substr(trim($nextLine), 0, 1) === '"') { // Normal multiline + $line = substr($line, 0, -1).substr(trim($nextLine), 1); + } + if (substr(trim($nextLine), 0, 4) === '#~ "') { // Disabled multiline + $line = substr($line, 0, -1).substr(trim($nextLine), 4); + } $nextLine = next($lines); } From fcb8f3b3abaef463ffa5c5615b09ec6ca4686747 Mon Sep 17 00:00:00 2001 From: Ladislav Brychta <74542573+lbfeenix@users.noreply.github.com> Date: Tue, 17 Nov 2020 23:33:58 +0100 Subject: [PATCH 2/2] Minor code (elseif) fix --- src/Loader/PoLoader.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Loader/PoLoader.php b/src/Loader/PoLoader.php index cfa37703..1d98c56e 100644 --- a/src/Loader/PoLoader.php +++ b/src/Loader/PoLoader.php @@ -30,8 +30,7 @@ public function loadString(string $string, Translations $translations = null): T ) { if (substr(trim($nextLine), 0, 1) === '"') { // Normal multiline $line = substr($line, 0, -1).substr(trim($nextLine), 1); - } - if (substr(trim($nextLine), 0, 4) === '#~ "') { // Disabled multiline + } elseif (substr(trim($nextLine), 0, 4) === '#~ "') { // Disabled multiline $line = substr($line, 0, -1).substr(trim($nextLine), 4); } $nextLine = next($lines);