From 3d4329f641b448188f058e34b75d18dd32aa5d2b Mon Sep 17 00:00:00 2001 From: Constantin Druc Date: Wed, 15 Jun 2022 00:53:27 +0300 Subject: [PATCH] Windows newlines (#12) * Add support for newlines * Windows new lines are special --- src/RequiredTranslations.php | 4 ++-- tests/RequiredTranslationsTest.php | 1 + tests/fixtures/test-files/__.txt | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/RequiredTranslations.php b/src/RequiredTranslations.php index fe1c004..087470d 100644 --- a/src/RequiredTranslations.php +++ b/src/RequiredTranslations.php @@ -88,13 +88,13 @@ private function pattern(): string "(?)" . // Must not start with -> '(' . implode('|', $this->translationMethods) . ')' .// Must start with one of the functions "\(" .// Match opening parentheses - "[\s\S]?" .// Ignore new lines + "[\r\n|\r|\n]*?" .// Ignore new lines "[\'\"]" .// Match " or ' "(" .// Start a new group to match: ".*" .// Must start with group ")" .// Close group "[\'\"]" .// Closing quote - "[\s\S]?" .// Ignore new lines + "[\r\n|\r|\n]*?" .// Ignore new lines "[\),]" . // Close parentheses or new parameter "/siuU"; } diff --git a/tests/RequiredTranslationsTest.php b/tests/RequiredTranslationsTest.php index ccf5a8a..3e3887c 100644 --- a/tests/RequiredTranslationsTest.php +++ b/tests/RequiredTranslationsTest.php @@ -22,6 +22,7 @@ public function it_finds_all_required_translations(): void $this->assertEquals([ 'Well this is ackward' => '__.txt', + 'Well this is even more ackward' => '__.txt', 'This will go in the JSON array' => '__.txt', 'lang.first_match' => 'alt_lang.txt', 'lang_get.first' => 'lang_get.txt', diff --git a/tests/fixtures/test-files/__.txt b/tests/fixtures/test-files/__.txt index aed4bf5..3dca26e 100644 --- a/tests/fixtures/test-files/__.txt +++ b/tests/fixtures/test-files/__.txt @@ -4,3 +4,9 @@ __('This will go in the JSON array') __( 'Well this is ackward' ) + +__( + +'Well this is even more ackward' + +)