While working on my Gutenberg Development Course I was really happy to find out that the core developers ported over much of the internationalization features we are familiar with on the PHP side into a client side library available as
Example of __() in Action
Since wp.i18n is available in the global scope, you can access it directly without needing to officially “import” anything. In this example we are pulling out the
__ function from the
wp.i18n library it exists within.
Notice when we call the function, we do not need to pass in a second parameter with the text domain for our plugin or theme. This will be automatically sorted out for you.
Additional Internationalization Functions
We also have access to some other helpful internationalization functions that you may recognize from the PHP side.
Most of the time you only need
__(), but if you are familiar with these other functions already in PHP or just want to dig deeper, you can explore the core library readme file here.
Learn More About Gutenberg Development
If you would like to learn more about building with the new editor in WordPress, please check out my Gutenberg Development Course 🙂