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
{{ message }}
Repository navigation
Extract translatable strings from block.json files #163
I can potentially help with implementation as I built large parts of that tool and am familiar with it. Then, I suppose @ocean90 could help update it on dotorg.
The challenge would be only how WP-CLI locates all block.json files
Just like WP-CLI scans all JS and PHP files for translation functions, it would then also scan all block.json files that are deemed valid. Don't see a huge difficulty there.
I explored building Babel plugin which takes care of converting block.json into JavaScript code but we decided that we shouldn't go in that direction. Here are some snippets of code which should help with the implementation:
@gziolo Thanks for the update! How often do you think the list of translatable properties would change? It might be safer to have title, description, keywords, and styles.label* whitelisted in WP-CLI.
@gziolo Thanks for the update! How often do you think the list of translatable properties would change? It might be safer to have title, description, keywords, and styles.label* whitelisted in WP-CLI.
What about styleVariations?
styleVariations is an alias for styles that is the legacy name and a bit ambiguous.
The whitelist approach is perfectly fine. I don't expect to change it frequently. Only if we decide to add new fields but I don't see any reasons for that as of today.
@swissspidy – it seems to be one of the last blockers for making block.json a thing. Can you share some pointers about how this could be implemented? Maybe some prior art (PR or commit)?
Activity
swissspidy commentedon Jul 9, 2019
Here's the final RFC: https://github.com/WordPress/gutenberg/blob/76aa7154913d54985ffbb57b695c9d7e86492124/docs/rfc/block-registration.md
gziolo commentedon Jan 3, 2020
I have just closed WordPress/gutenberg#16088 where we all agreed that
i18n-commandshould extract translatable strings fromblock.jsonfile.Re-sharing comment from @swissspidy:
I explored building Babel plugin which takes care of converting
block.jsoninto JavaScript code but we decided that we shouldn't go in that direction. Here are some snippets of code which should help with the implementation:The gist of it is:
string(titleanddescription) andstring[](keywords) are translatable when whitelistedObject[]onlylabelproperties are translatable for each object listed (this is only forstylesat the moment)swissspidy commentedon Jan 8, 2020
@gziolo Thanks for the update! How often do you think the list of translatable properties would change? It might be safer to have
title,description,keywords, andstyles.label* whitelisted in WP-CLI.* What about
styleVariations?gziolo commentedon Jan 8, 2020
styleVariationsis an alias forstylesthat is the legacy name and a bit ambiguous.The whitelist approach is perfectly fine. I don't expect to change it frequently. Only if we decide to add new fields but I don't see any reasons for that as of today.
swissspidy commentedon Jan 8, 2020
Thanks for the quick response!
Sounds like a relatively easy thing to implement then :-)
gziolo commentedon Apr 8, 2020
@swissspidy – it seems to be one of the last blockers for making
block.jsona thing. Can you share some pointers about how this could be implemented? Maybe some prior art (PR or commit)?swissspidy commentedon Apr 17, 2020
@gziolo Heya, I created #210 as a starting point for this.