Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#52301 closed enhancement (fixed)

Blocks: Add i18n support to register_block_type_from_metadata

Reported by: gziolo's profile gziolo Owned by: gziolo's profile gziolo
Milestone: 5.7 Priority: normal
Severity: normal Version: 5.7
Component: Editor Keywords: has-patch has-unit-tests
Focuses: Cc:

Description (last modified by gziolo)

Related issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/23636.

Related PR in WP-CLI from @swissspidy: https://github.com/wp-cli/i18n-command/pull/210.

Description

There are some issues related to internationalization (i18n) support in the introduced block.json metadata files that still need to be resolved.

There is a proposal in block registration document that we still need to implement:
https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

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 in i18n command. It was based on the aforementioned document.

Code

https://github.com/WordPress/wordpress-develop/pull/868

Change History (11)

This ticket was mentioned in PR #868 on WordPress/wordpress-develop by gziolo.


4 years ago
#1

Trac ticket: https://core.trac.wordpress.org/ticket/52301

Related issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/23636.

Related PR in WP-CLI from @swissspidy: https://github.com/wp-cli/i18n-command/pull/210.

## Description

There are some issues related to internationalization (i18n) support in the introduced block.json metadata files that still need to be resolved.

There is a proposal in block registration document that we still need to implement:
https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

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 in i18n command. It was based on the aforementioned document.

#2 @gziolo
4 years ago

  • Description modified (diff)

lukecarbis commented on PR #868:


4 years ago
#3

This PR will need eyes from the documentation team.

#4 @gziolo
4 years ago

  • Owner set to gziolo
  • Resolution set to fixed
  • Status changed from new to closed

In 49981:

Blocks: Add i18n support to register_block_type_from_metadata

Related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/23636.
Related WP-CLI PR: https://github.com/wp-cli/i18n-command/pull/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.

#5 @gziolo
4 years ago

  • Keywords dev-feedback removed

#6 @gziolo
4 years ago

In 49982:

Blocks: Add automatic RTL handlind for block styles registered from metadata

Related Gutenberg issue: https://github.com/WordPress/gutenberg/pull/28274

With this change it is going to be possible to use the same pattern that wp_style_add_data uses for RTL handling. If the block style file with "-rtl.css" is included in addition to the regular style referenced in "block.json" file then it is going to be automatically registered.

Props swisspidy, aristath.
See #52301.

ZebulanStanphill commented on PR #868:


4 years ago
#8

Shouldn't textdomain be textDomain to match the camelCase already being used for editorScript and editorStyle?

gziolo commented on PR #868:


4 years ago
#9

@ZebulanStanphill, I know it's confusing. In the written language it's two words so you would expect text_domain in PHP and textDomain in JavaScript, but in practice, it' was mostly textdomain in PHP codebase so followed it. Related docs:

#10 @gziolo
3 years ago

Related documentation changes in Gutenberg: https://github.com/WordPress/gutenberg/pull/29023.

This ticket was mentioned in Slack in #core by monikarao. View the logs.


3 years ago

Note: See TracTickets for help on using tickets.