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
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.
The text was updated successfully, but these errors were encountered:
swissspidy
changed the title
Use extractor instead of regex to get main file header data
Add file references to extracted file header data
Jan 16, 2024
swissspidy
changed the title
Add file references to extracted file header data
Add line number references to extracted file header data
Jan 16, 2024
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.
The text was updated successfully, but these errors were encountered: