I made a plugin with…

I made a plugin with existing localization on WordPress.org for free: https://wordpress.org/plugins/simpletoc/ I migrated to block.json and made all changes by comparing it to the output of `npx wordpress/create-block todo-list`. I read through the Block Editor guide on internationalization https://developer.wordpress.org/block-editor/how-to-guides/internationalization/ , but there seem to be a few differences to the way it works in the todo-list example.

The result is that all my `__` php functions work and translate all stringsString A string is a translatable part of the software. A translation consists of a multitude of localized strings.. But my `__` JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. function does not translate any of the translation on translate.wordpress.orgtranslate.wordpress.org The platform for contributing to the translation of WordPress core, themes and plugins.

What I tried and checked:

1. block.jsonJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. contains `”textdomain”: “simpletoc”`
2. edit.js contains `import { __ } from ‘wordpress/i18nInternationalization Internationalization (sometimes shortened to I18N , meaning “I - eighteen letters -N”) is the process of planning and implementing products and services so that they can easily be adapted to specific local languages and cultures, a process called localization. This is the process of making software translatable. Information about Internationalization for developers can be found in the Developer’s handbooks.’;`
3. plugin.php contains `Text Domain: simpletoc`

I did not change it, but I use the __ function like this:

                    label={__("Remove heading", "simpletoc")}

The sad thing is that it worked before in version 4.8 without block.json but I want to avoid reverting to that. Amazingly, the description in block.json does get translated but not the `__` functions in the code. I tried to use some things before doing that:

In the init hook I tried to use

    function register_simpletoc_block()
      wp_set_script_translations( 'simpletoc-js', 'simpletoc' );
      register_block_type( __DIR__ . '/build' , [
        'render_callback' => __NAMESPACE__ . 'render_callback'
    add_action( 'init', 'register_simpletoc_block' );

I tried this but it does not work either:

    wp_set_script_translations( 'simpletoc', 'simpletoc' );


    wp_set_script_translations( 'simpletoc-toc-editor-script-js', 'simpletoc' ); 

since this is the script in the edit page of GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/

<script src='http://localhost/wp-content/plugins/simpletoc/build/./index.js?ver=d2bfa87b84057817ab1ccfd2e596ca3a' id='simpletoc-toc-editor-script-js'></script>

But since I do not set “simpletoc-js” anymore, I have no idea if this is necessary. It would be really great if someone could explain or at least help me to debug this.

This is always empty:

    <script id='simpletoc-toc-editor-script-js-translations'>
    ( function( domain, translations ) {
    	var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
    	localeData[""].domain = domain;
    	wp.i18n.setLocaleData( localeData, domain );
    } )( "simpletoc", { "locale_data": { "messages": { "": {} } } } );

If I install my old 4.8 pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party this part contains data from translate.wordpress.org as usual.

– This tag works:
– This tag does not (block.json)

What am I missing? Can somebody please help?