Skip to content

Commit 7cd0555

Browse files
committed
Translation infrastructure updates
* Declare textdomain in block.json * Update how translations are loaded
1 parent 9cc731b commit 7cd0555

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

includes/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ protected function init(): void {
2424
*/
2525
public function init_translations(): void {
2626
// Load translations
27-
load_plugin_textdomain( 'multisite-shared-blocks', false, MULTISITE_SHARED_BLOCKS_PLUGIN_DIRNAME . '/languages' );
27+
load_plugin_textdomain( 'multisite-shared-blocks', false, sprintf( '%s/languages', dirname( MULTISITE_SHARED_BLOCKS_PLUGIN_BASENAME ) ) );
2828
}
2929
}

multisite-shared-blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// Plugin URL and PATH
3232
define( 'MULTISITE_SHARED_BLOCKS_URL', plugin_dir_url( __FILE__ ) );
3333
define( 'MULTISITE_SHARED_BLOCKS_DIR', plugin_dir_path( __FILE__ ) );
34-
define( 'MULTISITE_SHARED_BLOCKS_PLUGIN_DIRNAME', basename( rtrim( dirname( __FILE__ ), '/' ) ) );
34+
define( 'MULTISITE_SHARED_BLOCKS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
3535

3636
register_activation_hook( __FILE__, [ \Beapi\MultisiteSharedBlocks\Plugin::class, 'activate' ] );
3737

src/blocks/shared-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
}
3030
},
3131
"editorScript": "file:./index.js",
32-
"editorStyle": "file:./index.css"
32+
"editorStyle": "file:./index.css",
33+
"textdomain": "multisite-shared-blocks"
3334
}

0 commit comments

Comments
 (0)