From d333d5fe6c5b4e7faaf103780def9531532b55e3 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Tue, 27 Jun 2023 11:15:02 +0900 Subject: [PATCH 1/2] fix/translate --- inc/blocks.php | 5 +++++ src/copy-button-wrap/block.json | 1 + src/copy-button-wrap/index.js | 2 ++ src/copy-button/block.json | 1 + src/copy-button/index.js | 3 +++ src/copy-target/block.json | 1 + src/copy-target/index.js | 3 +++ src/simple-copy/block.json | 1 + src/simple-copy/index.js | 3 +++ 9 files changed, 20 insertions(+) diff --git a/inc/blocks.php b/inc/blocks.php index c3cfe08..6e38110 100644 --- a/inc/blocks.php +++ b/inc/blocks.php @@ -12,6 +12,7 @@ add_action( 'init', function () { + load_plugin_textdomain( 'vk-simple-copy-block' ); $blocks = array( 'simple-copy', 'copy-target', @@ -22,6 +23,10 @@ function () { register_block_type( VK_SIMPLE_COPY_BLOCK_DIR_PATH . 'build/' . $block . '/' ); + wp_set_script_translations( + 'vk-simple-copy-block-'. $block . '-editor-script-js', + 'vk-simple-copy-block' + ); } } ); diff --git a/src/copy-button-wrap/block.json b/src/copy-button-wrap/block.json index e16fa23..8c9d6c8 100644 --- a/src/copy-button-wrap/block.json +++ b/src/copy-button-wrap/block.json @@ -3,6 +3,7 @@ "name": "vk-simple-copy-block/copy-button-wrap", "category": "vk-blocks-cat", "title": "Copy Button", + "textdomain": "vk-simple-copy-block", "parent": ["vk-simple-copy-block/simple-copy"], "attributes": { "buttonAlign": { diff --git a/src/copy-button-wrap/index.js b/src/copy-button-wrap/index.js index e18db91..66ed78c 100644 --- a/src/copy-button-wrap/index.js +++ b/src/copy-button-wrap/index.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -20,6 +21,7 @@ if ( pathString.indexOf('widgets.php') === -1 ) { registerBlockType(name, { + title: __( 'Copy Button', 'vk-simple-copy-block' ), icon: , ...settings, save, diff --git a/src/copy-button/block.json b/src/copy-button/block.json index fe75718..3f8c5b2 100644 --- a/src/copy-button/block.json +++ b/src/copy-button/block.json @@ -4,6 +4,7 @@ "category": "vk-blocks-cat", "title": "Copy Button", "description": "Button to copy the code of the copy target block.", + "textdomain": "vk-simple-copy-block", "parent": ["vk-simple-copy-block/copy-button-wrap"], "attributes": { "text": { diff --git a/src/copy-button/index.js b/src/copy-button/index.js index e18db91..56d86f9 100644 --- a/src/copy-button/index.js +++ b/src/copy-button/index.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -20,6 +21,8 @@ if ( pathString.indexOf('widgets.php') === -1 ) { registerBlockType(name, { + title: __( 'Copy Button', 'vk-simple-copy-block' ), + description: __( 'Button to copy the code of the copy target block.', 'vk-simple-copy-block' ), icon: , ...settings, save, diff --git a/src/copy-target/block.json b/src/copy-target/block.json index 25b8f7b..0f4ed03 100644 --- a/src/copy-target/block.json +++ b/src/copy-target/block.json @@ -4,6 +4,7 @@ "category": "vk-blocks-cat", "title": "Copy Target", "description": "The inner blocks of this block will be copied.", + "textdomain": "vk-simple-copy-block", "parent": [ "vk-simple-copy-block/simple-copy" ], diff --git a/src/copy-target/index.js b/src/copy-target/index.js index e18db91..33e701e 100644 --- a/src/copy-target/index.js +++ b/src/copy-target/index.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -20,6 +21,8 @@ if ( pathString.indexOf('widgets.php') === -1 ) { registerBlockType(name, { + title: __( 'Copy Target', 'vk-simple-copy-block' ), + description: __( 'The inner blocks of this block will be copied.', 'vk-simple-copy-block' ), icon: , ...settings, save, diff --git a/src/simple-copy/block.json b/src/simple-copy/block.json index fa8337e..645119b 100644 --- a/src/simple-copy/block.json +++ b/src/simple-copy/block.json @@ -4,6 +4,7 @@ "category": "vk-blocks-cat", "title": "Simple Copy", "description": "A block to copy the code of the block inside the copy target.", + "textdomain": "vk-simple-copy-block", "attributes": { "blockId": { "type": "string" diff --git a/src/simple-copy/index.js b/src/simple-copy/index.js index 19c1615..4210611 100644 --- a/src/simple-copy/index.js +++ b/src/simple-copy/index.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -21,6 +22,8 @@ if ( pathString.indexOf('widgets.php') === -1 ) { registerBlockType(name, { + title: __( 'Simple Copy', 'vk-simple-copy-block' ), + description: __( 'A block to copy the code of the block inside the copy target.', 'vk-simple-copy-block' ), icon: , ...settings, save, From 7df2be169a518082b3690ebb05940701bed21811 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Tue, 27 Jun 2023 11:16:16 +0900 Subject: [PATCH 2/2] readme --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index 9a7bb38..476cca4 100644 --- a/readme.txt +++ b/readme.txt @@ -32,6 +32,8 @@ e.g. == Changelog == +[ Fix ] Translation + = 0.1.1 = [ Specification change ] Sentences and lower case tuning [ Specification change ] Add plugins banner