Closed gziolo closed 3 years ago
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 [Priority] High
label. What's the status of this one? Should we prioritise it for 5.7?
Yes, that would be great. In fact, it requires changes on the WordPress core side because we lack filters in register_block_type_from_metadata
. Relate proposal for filters in https://github.com/WordPress/wordpress-develop/pull/821.
@jorgefilipecosta works on a similar proposal for a theme.json
file in https://github.com/WordPress/gutenberg/pull/27380. It should help to drive this integration. I don't think it's a blocker though 😃
@noisysocks, do you plan to take care of it or you only wanted to triage labels?
@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: https://github.com/WordPress/wordpress-develop/pull/868.
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 block.json
file from the current directory and translate fields that are listed as translatable when the textdomain
is provided.
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:
https://github.com/WordPress/gutenberg/issues/23636 won’t have more items in WP 5.7, it requires some more fiddling on the Gutenberg side to make it work and it depends on the changes that are included in WP core for 5.7.
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 (https://github.com/wp-cli/i18n-command/pull/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 https://github.com/WordPress/gutenberg/pull/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.: