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

javascript extraction method gives unexpected results with escaped newlines #1056

Open
oomsveta opened this issue Jan 2, 2024 · 0 comments

Comments

@oomsveta
Copy link

oomsveta commented Jan 2, 2024

Hello, the other day I noticed an inconsistent behavior between the python and javascript extraction methods:

>>> list(extract("javascript", BytesIO(b"_('hey\\\nlol')")))
[(1, 'hey\nlol', [], None)]
>>> list(extract("python",     BytesIO(b"_('hey\\\nlol')")))
[(1, 'heylol', [], None)]

(Notice the extra newline between "hey" and "lol" with the javascript extraction method).

I think it's most likely a bug, and the JavaScript should behave the same as the Python.
This is especially bad since the current behavior also differs from how the JavaScript parser interprets it:

const hey = _("hey \
lol"
);

The content of the variable is heylol, but the extracted source term is hey\nlol. The mismatch between the two will prevent the string from being translated by gettext at all.

Could you take a look? Thanks in advance!

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

1 participant