wp-cli / i18n-command

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

Update and combine `theme.json` and `block.json` extractors #319

Closed swissspidy closed 2 years ago

swissspidy commented 2 years ago

Uses the block-i18n.json schema file to determine which fields are translatable.

Enhancement: Adds support for translating block variation fields. Apparently these were not extracted before...

Fixes #287

swissspidy commented 2 years ago

cc @gziolo

swissspidy commented 2 years ago

Looks like the existing theme i18n schema parser does not support cases like

  "keywords": [ "block keyword" ],

as seen in block.json

So that needs some fiddling to enable support and make the tests pass

swissspidy commented 2 years ago

@schlessera I'm running into some fatal errors here on PHP < 7.4. Perhaps you have some ideas here? Not sure which one of my changes could have caused that...

schlessera commented 2 years ago

@swissspidy The problem was the use of private access in the IterableCodeExtractor trait. That worked fine until you extended a class that was using that trait.

swissspidy commented 2 years ago

Ah 💡 🤦 Thanks!

gziolo commented 2 years ago

I think it's a good idea to use the file from wordpress-develop for now. I'm still not sure whether using the canonical URL similar to https://schemas.wp.org/trunk/block.json as discussed in the parent issue would work so nicely as it can be ahead of WordPress core.

Anyway, it looks like this PR has everything covered. Nice work, thank you for bringing i18n schemas up to date ❤️