Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block.json string extraction #210

Merged
merged 17 commits into from
Jun 4, 2020
Merged

block.json string extraction #210

merged 17 commits into from
Jun 4, 2020

Conversation

swissspidy
Copy link
Member

@swissspidy swissspidy commented Apr 17, 2020

Fixes #163.

Todo:

  • make tests pass

src/BlockExtractor.php Outdated Show resolved Hide resolved
src/BlockExtractor.php Outdated Show resolved Hide resolved
Copy link
Contributor

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on it, it looks close to ready. I left some comments so we could decide whether we need to refine the original plan :)

features/makepot.feature Show resolved Hide resolved
features/makepot.feature Show resolved Hide resolved
src/MakePotCommand.php Show resolved Hide resolved
Co-Authored-By: Grzegorz (Greg) Ziółkowski <grzegorz@gziolo.pl>
@gziolo
Copy link
Contributor

gziolo commented Apr 17, 2020

Thanks for working on it @swissspidy. How can I help to make the tests pass? :)

src/MakePotCommand.php Outdated Show resolved Hide resolved
@swissspidy
Copy link
Member Author

@gziolo I first need to get the tests setup properly running again on my machine, then I can debug them.

@swissspidy
Copy link
Member Author

@gziolo Tests are passing now, so this should be ready soon 🙂 But I also just learned about WordPress/gutenberg#21490...

@gziolo
Copy link
Contributor

gziolo commented May 11, 2020

@gziolo Tests are passing now, so this should be ready soon 🙂 But I also just learned about WordPress/gutenberg#21490...

Oh, interesting. It looks like more use cases pop up 😄 I don't think theme.json is stable enough to wait for it.

For this PR ✅ 🚢

@swissspidy swissspidy requested a review from a team May 11, 2020 13:10
src/BlockExtractor.php Outdated Show resolved Hide resolved
src/BlockExtractor.php Outdated Show resolved Hide resolved
src/IterableCodeExtractor.php Outdated Show resolved Hide resolved
@gziolo
Copy link
Contributor

gziolo commented May 26, 2020

There is now REST API endpoint for block types merged in the Gutenberg repository. It should become a part of WordPress core as part of WordPress 5.5 release. Related PR:
WordPress/gutenberg#21065

I'm not an expert, but it looks like OPTIONS returns JSON schema for the shape that this endpoint returns. Would it be possible to extend it to include information on which fields are translatable?

Edit: The schema that REST API uses follows snake_case for field names, while the block.json file uses camelCase, so this might require an intermediate step to make it all work.

@swissspidy
Copy link
Member Author

This kind of schema would need to live somewhere outside of WordPress context, where WP-CLI and other tools can easily assess which fields in block.json are translatable and which aren't.


In any case, I feel like this discussion should be better held in some Gutenberg GH issue or something, and shouldn't necessarily block this PR.

features/makepot.feature Outdated Show resolved Hide resolved
features/makepot.feature Outdated Show resolved Hide resolved
@gziolo
Copy link
Contributor

gziolo commented Jun 1, 2020

I landed changes in WordPress core WordPress/wordpress-develop@822ca9e that makes the changes I mentioned lately:

  • styles
  • textdomain

There is a corresponding PR that aligns Gutenberg code and updates RFC for block registration: WordPress/gutenberg#22695.

@swissspidy
Copy link
Member Author

@gziolo Awesome! Updated the code here accordingly.

Copy link
Contributor

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for applying changes so quickly, everything is aligned now 🎉

src/BlockExtractor.php Outdated Show resolved Hide resolved
@schlessera schlessera added this to the 2.2.3 milestone Jun 4, 2020
@schlessera schlessera merged commit e6e61c7 into master Jun 4, 2020
@schlessera schlessera deleted the add/blockjson branch June 4, 2020 06:55
@gziolo
Copy link
Contributor

gziolo commented Jun 17, 2020

This kind of schema would need to live somewhere outside of WordPress context, where WP-CLI and other tools can easily assess which fields in block.json are translatable and which aren't.

It looks like JSON schema is in works for the purpose of validation in Block Directory:
https://github.com/tellyworth/plugin-directory/pull/2/files#diff-73a27cb25a34ab6bcbb40bbbc9c436afR35

Where would be the best place to keep the common schema? I guess that Block Directory sooner or later would need to add its own flavors :)

@swissspidy
Copy link
Member Author

Probably on WordPress.org somewhere

@gziolo
Copy link
Contributor

gziolo commented Jul 8, 2020

This kind of schema would need to live somewhere outside of WordPress context, where WP-CLI and other tools can easily assess which fields in block.json are translatable and which aren't.

I opened a ticket in WordPress track to continue the discussion: https://core.trac.wordpress.org/ticket/50615.

nylen pushed a commit to nylen/wordpress-develop-svn that referenced this pull request Jan 19, 2021
Related Gutenberg issue: WordPress/gutenberg#23636.
Related WP-CLI PR: wp-cli/i18n-command#210.
Related documentation proposal: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

Adds programatic i18n support to `register_block_type_from_metadata` function for block settings registered from `block.json` file that provides `textdomain` field.


Props swissspidy, ocean90.
Fixes #52301.



git-svn-id: https://develop.svn.wordpress.org/trunk@49981 602fd350-edb4-49c9-b593-d223f7449a82
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Jan 19, 2021
Related Gutenberg issue: WordPress/gutenberg#23636.
Related WP-CLI PR: wp-cli/i18n-command#210.
Related documentation proposal: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

Adds programatic i18n support to `register_block_type_from_metadata` function for block settings registered from `block.json` file that provides `textdomain` field.


Props swissspidy, ocean90.
Fixes #52301.



git-svn-id: https://develop.svn.wordpress.org/trunk@49981 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jan 19, 2021
Related Gutenberg issue: WordPress/gutenberg#23636.
Related WP-CLI PR: wp-cli/i18n-command#210.
Related documentation proposal: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

Adds programatic i18n support to `register_block_type_from_metadata` function for block settings registered from `block.json` file that provides `textdomain` field.


Props swissspidy, ocean90.
Fixes #52301.


Built from https://develop.svn.wordpress.org/trunk@49981


git-svn-id: http://core.svn.wordpress.org/trunk@49682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Jan 19, 2021
Related Gutenberg issue: WordPress/gutenberg#23636.
Related WP-CLI PR: wp-cli/i18n-command#210.
Related documentation proposal: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

Adds programatic i18n support to `register_block_type_from_metadata` function for block settings registered from `block.json` file that provides `textdomain` field.


Props swissspidy, ocean90.
Fixes #52301.


Built from https://develop.svn.wordpress.org/trunk@49981


git-svn-id: https://core.svn.wordpress.org/trunk@49682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
schlessera added a commit that referenced this pull request Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract translatable strings from block.json files
4 participants