Skip to content

Localize Text doesn't localize string attributes of non-core blocks #869

Open

Description

@iamtakashi

What happens

"Localize Text" only localizes attributes of core blocks. get_localizable_block_attributes() is a fixed list (Search, pagination links, Navigation Link, Read More, …):

https://github.com/WordPress/create-block-theme/blob/5524f195e8/includes/create-theme/theme-locale.php#L272-L294

String attributes of other blocks are exported as-is. For example, WooCommerce's Mini-Cart shopping button:

<!-- wp:woocommerce/mini-cart-shopping-button-block {"startShoppingButtonLabel":"Shop"} -->

Expected

User-facing string attributes of any block are wrapped in esc_attr__().

Suggested fix

Instead of a hardcoded list, localize string attributes whose block.json definition has "role": "content" (the same signal the editor uses for content-only editing), and keep the list as a fallback for core blocks that don't declare it.

Drafted with AI assistance, verified by me against a theme exported with Create Block Theme and the source.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions