Loading a language file in the plugin initialization
The final step to plugin translation is to put the code in place to load a translation file. This is done by registering an action hook callback and calling a single function when it gets executed.
This recipe shows how to load the translation file created in the previous recipe.
Getting ready
You should have already followed the Making admin page code ready for translation and Translating text strings using Poedit recipes to have the proper files required for this recipe. Alternatively, you can get the resulting code (Chapter 11/ch11-hello-world/ch11-hello-world-v3.php
and Chapter 11/ch11-hello-world/languages
folder) for these recipes from the code bundle. You should rename the file ch11-hello-world-v3.php
to ch11-hello-world.php
and copy the languages
folder next to the renamed file before starting the recipe.
How to do it...
- Navigate to the
ch11-hello-world
folder of the WordPress plugin directory of your development installation. - Open the...