• if (!getBlockType('plugin/retail-section-shortcode')) {
        registerBlockType('plugin/retail-section-shortcode', {
            title: __('Start of member article', 'plugin'),
            icon: "editor-ltr",
            category: 'widgets',
            edit: Edit,
            save: function () {
                return '[retail-section-shortcode]';
            },
        });
    }
    
    if (!getBlockType('plugin/close-retail-section-shortcode')) {
        registerBlockType('plugin/close-retail-section-shortcode', {
            title: __('End of member article', 'plugin'),
            icon: "editor-rtl",
            category: 'widgets',
            edit: CloseEdit,
            save: function () {
                return '[/retail-section-shortcode]';
            },
        });
    }

    I have used Internationalize in BlockType registration on WordPress’ Gutenberg editor, But when I sync the new word with the Loco Translate plugin, it cannot be found.

    Is there any way?

    Please help me.

    Thank you

    • This topic was modified 2 years, 1 month ago by QuyenBE.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tim W

    (@timwhitlock)

    Please provide some clarity in what you’ve done, and what you’re expecting to happen?

    What file are you syncing, and what is it getting its source strings from?

    Where does this code live? Has it been extracted into a file? Are you expecting it to have done, or are you doing this?

    Is there really a text domain called “plugin”?

    Thread Starter QuyenBE

    (@quyen264)

    This is the source for WordPress.

    https://developer.ww.wp.xz.cn/block-editor/reference-guides/packages/packages-blocks/#registerblocktype

    https://developer.ww.wp.xz.cn/block-editor/getting-started/tutorial/


    I am testing this on my local machine.


    For example, when I use the phrase “(‘Start of member article’, ‘plugin’)” in the php file, Loco Translate will find it so I can translate it into different languages.

    But when I use “(‘Start of member article’, ‘plugin’)” in the JS file, Loco Translate cannot be found.

    Plugin Author Tim W

    (@timwhitlock)

    Using a string in a JavaScript file is not as simple as with PHP files, which can simply read the same MO file. Under WordPress every script has its own JSON file, which must have its required strings registered in advance.

    When you save your PO file in Loco Translate, it compiles a MO file and all the required JSON files. BUT the PO file must reference the script for each required string, or Loco Translate cannot know the JSON is required. See my page on this: https://localise.biz/wordpress/plugin/manual/json

    So, when you added “Start of member article” to your JS file, what else did you do? Just adding the code is not enough.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Cannot be translated in editor gutenberg’ is closed to new replies.