Internationalization is the process of developing your theme, so it can easily be translated into other languages. Internationalization is often abbreviated as i18n
(because there are 18 letters between the letters i and n).
Localization describes the subsequent process of translating an internationalized theme. Localization is abbreviated as l10n
(because there are 10 letters between the l and the n.)
References
Polygot Teams
Localization
Internationalization
load_theme_textdomain
Create a languages folder in your theme.
Create languages
folder in the root of your theme.
- Add the blank
pot
file in the languages folder and a readme.txt - Rename Blank-WordPress.pot with the slug of your plugin or extension.
Add load_theme_textdomain()
add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
load_theme_textdomain('theme-folder-name', get_template_directory() . '/languages');
}
Add translation functions
Make sure you have used translation functions in your theme to translate strings
_e(‘Hello’,’text-domain’);
esc_html_e( 'Hi', 'text-domain');
$my_var = __( 'Hello', 'text-domain' )
Download Poedit tool
- Download Poedit tool for translation.
- Open the your pot file from your theme’s languages folder with Poedit by clicking on
Create new translation
- Select language for translation and hit ok.
- In Catalog -> Properties -> Translation properties: change the properties to match your WordPress file name -> ok.
Click on Properties again
Add your source path to your themes folder and make sure to exclude any libraries directory.
- Click on the
update from pot
button to fetch and update the translated strings.
- Save (if a notice ask you to pick a language just pick “none of this”). Use your textdomain name if it’s a plugin or only en_US for the name of your file.
- Then click on
Extract from Sources
and do the translation. Then File > save
- Exit and that’s it.
This is how it looks like
Good post