Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
filip-nifti opened this issue Nov 1, 2022 · 2 comments

Comments

@filip-nifti
Copy link
Contributor

filip-nifti commented Nov 1, 2022

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 :)

@amiranagram
Copy link
Owner

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.

@filip-nifti
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants