-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 API: Add i18n support to block.json
metadata file
#23636
Comments
What's also missing here is the whole WordPress.org part and what the translation files will look like. We currently use JSON files with MD5 hashes for JS translations, and PO files for PHP translations. Where do block translations live? |
👋 ended up here because of the |
Yes, that would be great. In fact, it requires changes on the WordPress core side because we lack filters in @jorgefilipecosta works on a similar proposal for a @noisysocks, do you plan to take care of it or you only wanted to triage labels? |
Just triaging! This issue will need an owner. |
I opened PR targeting the WordPress core: WordPress/wordpress-develop#868. |
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
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
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
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
On the PHP side of things, everything is sorted out with https://core.trac.wordpress.org/ticket/52301. You can now register a block type using: register_block_type_from_metadata( __DIR__ ); It will load the I plan to update the client-side code to ensure it doesn't override the block metadata registered on the server for core blocks. |
Removing this from the 5.7 board per this comment from @gziolo:
|
I started JS implementation in #30293. |
Part of #16209.
There are some issues related to internationalization (i18n) support in newly introduced
block.json
metadata files that still need to be resolved.There is a proposal in block registration metadata document that we still need to implement:
https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#internationalization
The good news is that WP-CLI has implemented (wp-cli/i18n-command#210) native support for translatable strings extraction from
block.json
file ini18n
command. It was based on the aforementioned RFC. It still needs to be released though.JavaScript
@wordpress/babel-preset-default
) distributed as part of WordPress packages.PHP (Implemented)
The same issue applies to i18n handling on the PHP side of things. There was a new
register_block_type_from_metadata
utility function added in #20794 to make it possible to register a new block type usingblock.json
metadata file. It's still missing i18n support.Temporary support
The temporary approach for 3rd party blocks that want to use
register_block_type_from_metadata
would be to keep everything that doesn't need to be translated inblock.json
and put the rest as additional params passed with 2nd argument, e.g.:The text was updated successfully, but these errors were encountered: