Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How to add Internationalization in WordPress using Javascript/React?

I am trying to follow this article https://developer.wordpress.org/block-editor/how-to-guides/internationalization/ in order to translate my block.

I created my block using https://developer.wordpress.org/block-editor/getting-started/create-block/ script.

Then in my gutenpride.php, I added this code.

function myguten_set_script_translations()
{
    wp_register_script('myguten-script', plugins_url('/temp.js', __FILE__), ['wp-blocks', 'wp-i18n', 'wp-element'], filemtime(__DIR__ . '/temp.js'));

    wp_set_script_translations('myguten-script', 'myguten', plugin_dir_path(__FILE__) . 'languages');

    wp_localize_script('myguten-script', 'myguten', [
        'plugin_url' => plugins_url('/', __FILE__),
    ]);

    wp_enqueue_script('myguten-script');
}
add_action('init', 'myguten_set_script_translations');

As you can see, I am registering a temp.js file and giving it all the required dependencies.

The temp.js file works and is running.

As instructed by the translation article I added two files in my language folder

1. myguten-co.po
2. myguten.pot

Then I created the JSON file for myguten-co.po and changed the site language to Esperanto.

But when I see the block or add the new block yet I do not get the translated label.

Is there anything I am missing?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!