Extract pattern metadata (title & description)#312
Extract pattern metadata (title & description)#312swissspidy merged 10 commits intowp-cli:mainfrom oandregal:add/translate-php-patterns-metadata
Conversation
For this to be actually useful, Gutenberg should also actually translate the title. I don't see any |
Yeah, I need to follow-up with that as well :) |
|
I've prepared the Gutenberg PR that uses this data at WordPress/gutenberg#40047 but I'm having some trouble to get the translated strings. |
/patterns|
Pending some tests this looks good to go! 👍 |
Tests would need to wait until tomorrow morning :) |
|
@swissspidy pushed the test. |
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
| $options = [ | ||
| // Extract 'Title' and 'Description' headers from pattern files. | ||
| 'wpExtractPatterns' => isset( $this->main_file_data['Theme Name'] ), | ||
| 'include' => array_merge( $this->include, array( 'patterns' ) ), |
There was a problem hiding this comment.
@swissspidy Do you know why this hardcodes patterns here? Since these are PHP files they should be included by default. Now you explicitly have to exclude the patterns when you for example are using --include=wp-admin/*. to only include wp-admin strings.
There was a problem hiding this comment.
I suppose the idea was to make this more efficient and only scan these files when needed.
But you're right that this is already covered by the call above. I'll create a PHP to combine these.
… command. Ensures that strings from Twenty Twenty-Two are not included in POT files for wp-admin. See wp-cli/i18n-command#312 (review). git-svn-id: https://meta.svn.wordpress.org/sites/trunk@11809 74240141-8908-4e6f-9713-ba540dce6ec7
…irmly by ignoring the `wp-content` directory entirely for these admin contexts. It appears that the command does not fully respect the `exclude` parameter if it believes there are strings that should be included. By excluding a higher-level directory, it never see's the potential included `patterns` folder. Ensures that strings from Twenty Twenty-Two are not included in POT files for wp-admin. Previously: [11809]. See wp-cli/i18n-command#312 (review) git-svn-id: https://meta.svn.wordpress.org/sites/trunk@11810 74240141-8908-4e6f-9713-ba540dce6ec7
In WordPress/gutenberg#36751 Gutenberg added the ability to automatically register patterns that live in the
/patternsdirectory. These patterns provide metadata via headers in the PHP file as in:From the existing metadata, we need the
Titleto be translatable. This PR adds support for looking up those patterns and extracting the Title string into the pot file.How to test
foo-themedirectory at the top-level, which contains the following files:style.csswith at least these contents:patterns/my-pattern.phpwith at least these contents:foo-theme/foo-theme.potfile has been generated and that contains the pattern title and the theme name. You should get something along these lines: