[wp-trac] [WordPress Trac] #54797: Allow languages path in register_block_type

WordPress Trac noreply at wordpress.org
Thu Jan 13 08:57:24 UTC 2022

#54797: Allow languages path in register_block_type
 Reporter:  Rahe             |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  I18N             |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:

Comment (by gziolo):

 We discussed this issue also on WordPress Slack (link requires
 registration at https://make.wordpress.org/chat):


 There is also an issue opened in the Gutenberg project:


 There are two issues identified:

 1. When providing file paths to scripts (`editorScript`, `script` or
 `viewScript`), when there is a trailing `./` included then there is wrong
 md5 generated for the file and it doesn't match with the file generated in
 the translations folder.
 2. When a plugin provides a custom path to the translations folder,
 example: `languages`, it doesn't get passed to
 `wp_set_script_translations` called inside the
 `register_block_script_handle` helper function.

 The first issue can be solved by always removing the trailing `./` from
 the file path passed in `block.json`.

 The second issue can be tackled in many ways. One possibility is what
 @Rahe proposed in this ticket. An alernative to consider is to detect
 whether a script is registered inside a plugin (vs core block) and pass
 the custom path based on the setting read from the domain path set in the
 plugin metadata. More about that in

Ticket URL: <https://core.trac.wordpress.org/ticket/54797#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list