How to add Internationalization in WordPress using Javascript/React?

I see that you do not use register_block_type in PHP, which is now recommended way to register block. I am assuming you register block in the front-end ( I am not familiar with create-block ), and instead that I inspect create-block, would you share your front end code where you also have translation functions? It could be for a various reasons that this does not function, one of more frequent being using incorrect text domain. Also, for better workflow I recommend using wp-cli and wp i18n make-json.


Use wp i18n make-json to create Jed-formatted JSON files. This is the reason why your code did not work. You only created .pot and .po files, but you have to supply .json files, since javascript loads them. See examples at bottom of this page.