From 3c4d3dc2d04c31990ee7f2cb9d63414a5f9ae309 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 30 Jan 2021 22:57:39 -0500 Subject: [PATCH] Skip empty message strings in Console\PoToPhp - Fix issue with empty plurals not displaying the defaut translation string --- src/Console/PoToPhp.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Console/PoToPhp.php b/src/Console/PoToPhp.php index ef2e2f7385..d5f746a6db 100644 --- a/src/Console/PoToPhp.php +++ b/src/Console/PoToPhp.php @@ -115,19 +115,15 @@ HELP; } if ($k != '' && substr($l, 0, 7) == 'msgstr ') { - if ($ink) { - $ink = false; - $out .= '$a->strings["' . $k . '"] = '; - } - - if ($inv) { - $out .= '"' . $v . '"'; - } - $v = substr($l, 8, $len - 10); $v = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $v); - $inv = true; + if ($v != '') { + $out .= '$a->strings["' . $k . '"] = "' . $v . '"'; + } else { + $k = ''; + $ink = false; + } } if ($k != "" && substr($l, 0, 7) == 'msgstr[') { @@ -147,11 +143,13 @@ HELP; $match = []; preg_match("|\[([0-9]*)\] (.*)|", $l, $match); - $out .= "\t" - . preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[1]) - . ' => ' - . preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[2]) - . ",\n"; + if ($match[2] !== '""') { + $out .= "\t" + . preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[1]) + . ' => ' + . preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[2]) + . ",\n"; + } } if (substr($l, 0, 6) == 'msgid_') {