amiranagram/localizator

quotation marks are not escaped if a comma is directly after it in the string

filip-nifti opened this issue · 2 comments

When translating the following test-strings:
{{__('This is a "Test", followed by some text')}}
{{__("This is another \"Test\", followed by more text")}}

They both result in wrong keys. They keys are as follows:
"This is a \"Test": "",
"This is another \"Test": "",

I was about to do a pull request but i cant seem to figure out the regexp rules in the parser... Its not my strong suit....

Anyway here is a link to the regepx rules and tester, would really appreciate some help :)

Thank you for reporting. I've had a similar issues with quotes that I fixed a few months ago. I'll see what can I do. I'm certain I need to improve the regex.

Hi @amiranagram
I found another package that handles translation and looked in their code, they have an alternate regex string to find.
I tried using theirs for a bit to solve it. They solve it out of the box but it cant handle escaped strings as well as yours.
Maybe it can help you to find a way to improve the regex?
ANyway, here is the link to their implementation of the find-regex: https://github.com/barryvdh/laravel-translation-manager/blob/17f5f116fb7941d1e860a749d03718ce008829bd/src/Manager.php#L161.
Its very well documented.

Their regex tester is here: https://regex101.com/r/WEJqdL/6

It solves the issue i posted but it does not manage to escape double quotation marks if the string is created using double quotation marks. See this tester: https://regex101.com/r/94oA7o/1