Skip to content

Commit

Permalink
Internationalize the server registration #5
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Aug 14, 2021
1 parent e4dd8f4 commit a76aa57
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sb-post-edit-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,32 @@
* @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/writing-your-first-block-type/
*/
function oik_sb_sb_post_edit_block_block_init() {
oik_sb_sb_post_edit_block_load_plugin_textdomain();
$args = [ 'render_callback' => 'oik_sb_sb_post_edit_block_dynamic_block'];
$registered = register_block_type_from_metadata( __DIR__, $args );
//bw_trace2( $registered, "registered" );
/*
* Localise the script by loading the required strings for the build/index.js file
* from the locale specific .json file in the languages folder
*/
$ok = wp_set_script_translations( 'oik-sb-sb-post-edit-block-editor-script', 'sb-post-edit-block' , __DIR__ .'/languages' );
//echo "?$ok?";

//add_filter( 'load_script_textdomain_relative_path', 'oik_load_script_textdomain_relative_path', 10, 2);

}

function oik_sb_sb_post_edit_block_loaded() {
add_action( 'init', 'oik_sb_sb_post_edit_block_block_init' );
}

function oik_sb_sb_post_edit_block_load_plugin_textdomain( $domain="sb-post-edit-block" ) {
$languages_dir = "$domain/languages";
bw_trace2( $languages_dir, "languages dir" );
$loaded = load_plugin_textdomain( $domain, false, $languages_dir );
return $loaded;
}

/**
* Implements the Post Edit block.
*
Expand Down

0 comments on commit a76aa57

Please sign in to comment.