Extract strings contained within eval() #222
Conversation
The unit tests keep timing out on trunk only - I'm not sure why as I've not been able to run then locally. |
Interesting edge case & nice solution for the line number! Would you be able to add some Behat tests for this? Could probably just copy some lines from the MathML plugin and then verify that strings are extracted as expected with the correct line number. |
I'll get some tests added @swissspidy - Hopefully I can figure out how to run the tests locally |
Unfortunately I wasn't able to get tests running locally, and there are no existing tests for the JS set of extraction methods, so I can't really fly into it blind either. |
There are no unit tests for it, but Behat tests, starting here: i18n-command/features/makepot.feature Lines 1559 to 1580 in b02ecdc If it's not working, feel free to add me to your fork so I could amend, otherwise I can open a new PR with your commit in it and the tests. |
@schlessera Any idea about the test timeouts? I can't re-start Travis in case it's just a flake. |
…an the location within the eval contents.
…hat's a literal. Tests ran into a BinaryExpression here, which doesn't appear to be expected.
dd32 commentedJul 24, 2020
Some build systems can result in the built files gettext functions being inside eval() calls.
One such example of this, is a webpack'd built file in this plugin: https://plugins.trac.wordpress.org/browser/mathml-block/trunk/dist/mathml-block.js?rev=2276811#L245
Currently, the relevant output is this:
which doesn't work for WordPress Translation files, as those src files are never enqueued, only the built files.
After the change, here's the output: