Skip to content

Commit

Permalink
Windows newlines (#12)
Browse files Browse the repository at this point in the history
* Add support for newlines

* Windows new lines are special
  • Loading branch information
Constantin Druc authored Jun 14, 2022
1 parent f61d624 commit 3d4329f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/RequiredTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
1 change: 1 addition & 0 deletions tests/RequiredTranslationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/test-files/__.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ __('This will go in the JSON array')
__(
'Well this is ackward'
)

__(

'Well this is even more ackward'

)

0 comments on commit 3d4329f

Please sign in to comment.