0

Here is my code.

I based it on CapitaineWP formation and template. I have the .pot, .po, .mo and .json files.

$script_asset_path = PERSO_FOLDER."/build/index.asset.php";

if ( ! file_exists( $script_asset_path ) ) { throw new \Error( 'You need to run npm start or npm run build for the "create-block/perso-chacha-bases" block first. ('.$script_asset_path.')' ); }

$index_js     = '/build/index.js';
$script_asset = require( $script_asset_path );
wp_register_script(
    'perso-chacha-bases-block-editor',
    PERSO_URL.$index_js,
    $script_asset['dependencies'],
    $script_asset['version']
);
wp_set_script_translations(
    'perso-chacha-bases-block-editor',
    'perso-chacha',
    PERSO_FOLDER . '/languages'
);

$editor_css = '/build/index.css';
wp_register_style(
    'perso-chacha-bases-block-editor',
    PERSO_URL.$editor_css,
    array(),
    filemtime( PERSO_FOLDER.$editor_css )
);

$style_css = '/build/style-index.css';
wp_register_style(
    'perso-chacha-bases-block',
    PERSO_URL.$style_css,
    array(),
    filemtime( PERSO_FOLDER.$style_css )
);

register_block_type( 'create-block/perso-chacha-bases', array(
    'editor_script' => 'perso-chacha-bases-block-editor',
    'editor_style'  => 'perso-chacha-bases-block-editor',
    'style'         => 'perso-chacha-bases-block',
) );

1 Answer 1

0

I found the problem. I needed to add -perso-chacha-bases-block-editor after fr_FR in the json filename. I found out this solution here: Gutenberg translation is not working

Big thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.