wp-cli / i18n-command

Provides internationalization tools for WordPress projects.
MIT License
96 stars 52 forks source link

Ignore minified JavaScript files #45

Closed swissspidy closed 6 years ago

swissspidy commented 6 years ago

Right now, we exclude some files by default. One file pattern that we don't yet exclude is minified JavaScript files. They usually look like i-am-minified.min.js.

It's not currently possible to exclude files using glob patterns like *.min.js but I think that would be a great addition.

When someone excludes *.min.js, we can turn this into a regex à la .*\.min.js or something, and then exclude the file if it matches that regex. WP_oEmbed::get_provider() has some code that does this. Perhaps we can reuse this.

In the PHP extractor, the relevant code is here: https://github.com/wp-cli/i18n-command/blob/bd16b5fd631980dea4684e9b290b3e80674b4401/src/PhpCodeExtractor.php#L129-L146

We can probably extend this with a new regex.

schlessera commented 6 years ago

I assume it is more important to have that included in the JsCodeExtractor.php file. The code seems to be exactly the same, though: https://github.com/wp-cli/i18n-command/blob/bd16b5fd631980dea4684e9b290b3e80674b4401/src/JsCodeExtractor.php#L111-L121

This makes me wonder again about where to DRY up the code...

swissspidy commented 6 years ago

This makes me wonder again about where to DRY up the code...

54 could solve this.

swissspidy commented 6 years ago

For reference, this is how the current makepot.php script does it:

https://github.com/WordPress/wordpress-develop/blob/4ce3db3e8d25099bb9f1f017b7006d3fc2dfaa3c/tools/i18n/extract.php#L48-L67