From b437a953baf71c2eb07651dd0c38efdec6777b16 Mon Sep 17 00:00:00 2001 From: Jonas Rittershofer Date: Tue, 2 Mar 2021 14:15:54 +0100 Subject: [PATCH] fixup! Allow vue-translator comments --- .../translationtool/src/translationtool.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/translations/translationtool/src/translationtool.php b/translations/translationtool/src/translationtool.php index 9a26be26..64952183 100644 --- a/translations/translationtool/src/translationtool.php +++ b/translations/translationtool/src/translationtool.php @@ -336,12 +336,11 @@ private function createFakeFileForVueFiles() { $regexMatches = preg_grep($regex, $vueSource); foreach ($regexMatches as $lineNum => $match) { - // Check for comment in previous line. Either HTML or JS comment. HTML-Comments terminate with '-->', JS do not - if(preg_match("/\W(TRANSLATORS)\s(.+)(-->)/", $vueSource[$lineNum-1], $commentSplit) - || preg_match("/\W(TRANSLATORS)\s(.+)/", $vueSource[$lineNum-1], $commentSplit)) { - - // Insert comment - $fakeFileContent .= "// TRANSLATORS " . preg_replace('/\s+/', ' ', $commentSplit[2]) . PHP_EOL; + // Check for comment in previous line. Either HTML or JS comment. + if(preg_match("/\W(\/\/|\/\*||\*\/)\s*/', '', $commentSplit[3]); + $fakeFileContent .= "// TRANSLATORS " . preg_replace('/\s+/', ' ', $commentText) . PHP_EOL; } // Insert translation-function @@ -360,12 +359,11 @@ private function createFakeFileForVueFiles() { $regexMatches = preg_grep($regex, $vueSource); foreach ($regexMatches as $lineNum => $match) { - // Check for comment in previous line. Either HTML or JS comment. HTML-Comments terminate with '-->', JS do not - if(preg_match("/\W(TRANSLATORS)\s(.+)(-->)/", $vueSource[$lineNum-1], $commentSplit) - || preg_match("/\W(TRANSLATORS)\s(.+)/", $vueSource[$lineNum-1], $commentSplit)) { - - // Insert comment - $fakeFileContent .= "// TRANSLATORS " . preg_replace('/\s+/', ' ', $commentSplit[2]) . PHP_EOL; + // Check for comment in previous line. Either HTML or JS comment. + if(preg_match("/\W(\/\/|\/\*||\*\/)\s*/', '', $commentSplit[3]); + $fakeFileContent .= "// TRANSLATORS " . preg_replace('/\s+/', ' ', $commentText) . PHP_EOL; } // Insert translation-function