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 translation not being found by scan #133

Open
krissce opened this issue May 8, 2020 · 0 comments
Open

Javascript translation not being found by scan #133

krissce opened this issue May 8, 2020 · 0 comments
Labels

Comments

@krissce
Copy link

krissce commented May 8, 2020

Hi there,
I've spent hours tracing odd issue where Scan function was not finding lajax.t() translations in my js code. After long time I narrowed it to this js code:

function x(str, attribute)
{
str = str.replace(/style="/gi, 'style="' + attribute + ': ' + ';');
str = str.replace(new RegExp(attribute + '="[^<>"]*"', "gi"), '');
//translation below will not be found by scanner!
lajax.t('testing');
}

What this method does does not matter now, because it was just extracted from whole function code, but this just code is valid. Anyway, after debugging I found out that token_get_all was failing to match tokens properly. This is the line from code:

$tokens = token_get_all($subject);

If you try code I've pasted above Scan will not add new string translation called 'testing'.
If you remove first line from this function, that is: str = str.replace(/style="/gi, 'style="' + attribute + ': ' + ';'); - then Scan will find 'testing' string for translation.

Anyway, this is just in case someone was not sure why translation is not being found.

@moltam moltam added the bug label May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants