You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Localize Text doesn't localize string attributes of non-core blocks #869
"Localize Text" only localizes attributes of core blocks. get_localizable_block_attributes() is a fixed list (Search, pagination links, Navigation Link, Read More, …):
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.
I confirmed the cause in escape_block_attribute_strings(). The block name from the block comment is passed as 'core/' . $block_name. Core blocks are serialized without a namespace (wp:search), so that works for them. A namespaced block like wp:woocommerce/mini-cart-shopping-button-block becomes core/woocommerce/…, which never matches, so it's skipped.
My plan:
Resolve the full block name properly (add core/ only when there's no namespace).
For non-core blocks, look the block up in WP_Block_Type_Registry and localize string attributes declared with "role": "content".
Keep the existing list for core blocks, so core behaviour doesn't change.
Skip url, href, src, id, and slug even if they're marked role: content. For example, core/navigation-link marks url as content, and localizing it would be wrong.
Let me know if the approach looks good or any change requried.
Activity
prasadkarmalkar commentedon Oct 28, 2026
Hi! I'd like to take this one.
I confirmed the cause in
escape_block_attribute_strings(). The block name from the block comment is passed as'core/' . $block_name. Core blocks are serialized without a namespace (wp:search), so that works for them. A namespaced block like wp:woocommerce/mini-cart-shopping-button-block becomes core/woocommerce/…, which never matches, so it's skipped.My plan:
Let me know if the approach looks good or any change requried.