-
Notifications
You must be signed in to change notification settings - Fork 58
Description
This is something I noticed while working on #61 / #64.
When printing warnings for missing / invalid strings I want to print the warning together with the location of where that string is.
For file headers that's currently not possible because they're being extracted using regex. This is mainly because I borrowed that code from https://develop.svn.wordpress.org/trunk/tools/i18n/makepot.php, which has been doing that for years.
However, since we already leverage a powerful gettext extraction library, I wonder if we could add a new extractor just for these file headers.
retrieve_main_file_data()
, get_file_data()
get_file_headers()
, get_file_data_from_string()
, and _cleanup_header_comment()
would be affected/obsoleted by such a change.
I'm not sure how feasible it is, but it would make for a more robust solution that is more similar to the other extractors and easier to test than some old regex from WordPress core.
Also, we could make sure to get the filename / line references that way.
I guess it's the same argument as regex vs. using a DOM parser to parse some HTML in PHP.
I just saw that the Template Name:
extraction already resides in \WP_CLI\I18n\IterableCodeExtractor
.
We should probably consolidate this somehow.