Title: How to add Internationalization in WordPress using Javascript/React?
Last modified: June 16, 2022

---

# How to add Internationalization in WordPress using Javascript/React?

 *  [Sharukh Khan](https://wordpress.org/support/users/sharukhajm/)
 * (@sharukhajm)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/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/](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/](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?
    -  This topic was modified 3 years, 11 months ago by [Sharukh Khan](https://wordpress.org/support/users/sharukhajm/).

Viewing 1 replies (of 1 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/how-to-add-internationalization-in-wordpress-using-javascript-react/#post-15747652)
 * Take a look at the path in your wp_register_script() function to temp.js. There
   is a “/” in front of it.
 * If you create the language files with wp i18n make-json, json files are created
   in your languages directory which contain the path of the JS files as md5 hash
   in the file name. If there is even one character different, then the JS files
   are not loaded at all and thus no translation takes place.
 * Therefore, compare the paths you use with the defaults from the manual. I stumbled
   exactly over it at the beginning also constantly.

Viewing 1 replies (of 1 total)

The topic ‘How to add Internationalization in WordPress using Javascript/React?’
is closed to new replies.

## Tags

 * [gutenberg](https://wordpress.org/support/topic-tag/gutenberg/)
 * [i18n](https://wordpress.org/support/topic-tag/i18n/)
 * [internationalization](https://wordpress.org/support/topic-tag/internationalization/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [threadi](https://wordpress.org/support/users/threadi/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/how-to-add-internationalization-in-wordpress-using-javascript-react/#post-15747652)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
