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

\n in JS files: backslash \ is stripped #200

Closed
jakubjo opened this issue Mar 21, 2019 · 2 comments
Closed

\n in JS files: backslash \ is stripped #200

jakubjo opened this issue Mar 21, 2019 · 2 comments

Comments

@jakubjo
Copy link

jakubjo commented Mar 21, 2019

Thank you for this awesome package!

I've encountered following issue:

When scanning JavaScript files the backslash of new line sequences is stripped.

gettext("First Line\nSecond Line\nThird Line");

Results in following msgid:

msgid "First LinenSecond LinenThird Line"

When I remove the case in JsFunctionsScanner:39 extracting is working as intended.
https://github.com/oscarotero/Gettext/blob/93176b272d61fb58a9767be71c50d19149cb1e48/src/Utils/JsFunctionsScanner.php#L39

I'd submit a PR, but I'm unsure how to fix this properly and do not really understand all whats happening in JsFunctionsScanner.

@jakubjo jakubjo changed the title \n in JS files: \ is stripped \n in JS files: backslash \ is stripped Mar 21, 2019
@oscarotero
Copy link
Member

I guess we need to check if the current status is simple-quote or double-quote and make a break if so.
Something like this: https://github.com/oscarotero/Gettext/blob/93176b272d61fb58a9767be71c50d19149cb1e48/src/Utils/JsFunctionsScanner.php#L55

Thanks!

@jakubjo
Copy link
Author

jakubjo commented Mar 21, 2019

We use \n also in single quotes in JS. I believe JS does not require double quotes around new line sequences.

I've submitted a PR. In our case the issue is fixed and everything is working as intended. I'm curious what you'll say.

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