You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
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:
yii2-translate-manager/services/scanners/ScannerFile.php
Line 173 in 218f41b
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.
The text was updated successfully, but these errors were encountered: