Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Block: Enable loading translations for created blocks #24125

Merged
merged 7 commits into from
Jul 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add basic note to the create-block tutorial
  • Loading branch information
ryelle committed Jul 22, 2020
commit f0177ef777f7efcbc1138c81862398da7808e37f
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function create_block_gutenpride_block_init() {
$script_asset['dependencies'],
$script_asset['version']
);
wp_set_script_translations( 'create-block-gutenpride-block-editor', 'create_block' );

$editor_css = 'editor.css';
wp_register_style(
Expand Down Expand Up @@ -138,6 +139,8 @@ The build process creates a secondary asset file that contains the list of depen

The `wp_register_script` function registers a name, called the handle, and relates that name to the script file. The dependencies are used to specify if the script requires including other libraries. The version is specified so the browser will reload if the file changed.

The `wp_set_script_translations` function tells WordPress to load translations for this script, if they exist. See more about [translations & internationalization.](/docs/designers-developers/developers/internationalization.md)

The `register_block_type` function registers the block we are going to create and specifies the editor_script file handle registered. So now when the editor loads it will load this script.

With the above in place, create a new post to load the editor and check the you can add the block in the inserter. You can use `/` to search, or click the box with the [+] and search for "Gutenpride" to find the block.
Expand Down