Home Forums Gutenberg block.json with translated title and description (i18n & L10n) Reply To: block.json with translated title and description (i18n & L10n)

  • No not yet. I have also tried using wp cli i18n to create .pot and json files (see below) and trying to register via:

    add_action( 'wp_enqueue_scripts', 'my_blocks_script_translations' );
    function my_blocks_script_translations() {
    	if ( function_exists( 'wp_set_script_translations' ) ) {
    		wp_set_script_translations( 'my-blocks', 'my-textdomain', get_template_directory() . '/includes/blocks/languages/' );

    But no success yet.

    Problem 1: I can’t generate a json file when the string reference block.json is present in the .po file #: my-blocks/testblock/block.json. Like this:

    #: my-blocks/testblock/block.json
    #: my-blocks/google-maps/block.json
    msgctxt "block keyword"
    msgid "container"
    msgstr "behÄllare"

    Trying the same procedure but with the strings added in a .js file works, like #: my-blocks/testblock/script.js

    Problem 2: Even when using an online tool (such as to convert my .po file to json I can’t get wp_set_script_translations() to work.

    Anyway, this is what I’ve tried (without success), maybe someone can figure things out which I can’t.

    functions.php: same snippet as above


    	"name": "my-blocks",
    	"version": "1.0.0",
    	"description": "Builds pot and json files for translation of ACF blocks",
    	"author": "Me",
    	"scripts": {
    		"start": "wp-scripts start",
    		"build": "wp-scripts build",
    		"packages-update": "wp-scripts packages-update",
    		"make-pot": "wp i18n make-pot . languages/my-blocks.pot --exclude=node_modules,src --ignore-domain --headers='{\"Last-Translator\":\"lepardman <[email protected]>\",\"Language-Team\":\"The team <[email protected]>\"}'",
    		"make-json": "wp i18n make-json languages/ --no-purge --pretty-print"
    	"dependencies": {
    		"@wordpress/i18n": "^4.27.0"
    	"devDependencies": {
    		"@wordpress/scripts": "^25.4.0"

    I first run wp i18n make-pot to get a pot file (this works, all strings are added). Then I use PoEdit to create a po file with translations (or copy+paste pot and change file name to .po and translate). And lastly I run wp i18n make-json but it creates no files (output: “Success: Created 0 files”). See problem #1.