Skip to content

registering blocks from PHP attempt to load translations from plugin root #70357

@Lovor01

Description

@Lovor01

Description

When registering blocks from PHP, either by using register_block_type or wp_register_block_types_from_metadata_collection, they use under the hood register_block_type_from_metadata. This function in turn attempts to load translations from plugin root. It is much more common, and would be a good practice to offer a choice from where it should be loaded, and that is typically /languages folder.

Step-by-step reproduction instructions

Use register_block_type or wp_register_block_types_from_metadata_collection to register a block(s).
Create some translations for block.json metadata like block title etc. Use query monitor plugin to debug and see from where is loading of translations attempted.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Internationalization (i18n)Issues or PRs related to internationalization efforts[Type] WP Core TicketRequires an upstream change from WordPress. Core Trac ticket should be linked.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions