Video Tutorial Internationalization
We will now discuss the internationalization (i18n) of our theme. The objective is to ensure that our theme adapts to the language chosen by the site administrator. To translate a theme or WordPress plugin use the gettext library.
We will start by specifying the domain associated with our theme / plugin:
/ *
Theme Name: My theme
Text Domain: montheme
* /
Then, we will use the localization functions in our theme:
Parameter page
// will become
It will then be necessary to use the POEdit software in order to extract the strings to translate into a .pot (if we are using a template) or .po file that we will place in a specific folder for our theme.
Finally, we will tell WordPress how to load translations for our domain
add_action ('after_setup_theme', function () {
load_theme_textdomain ('montheme', get_template_directory (). '/ languages');
});