- internationalization
- WordPress Flow
- Translations wrapper functions
- gettext hook
Internationalization is the process of making our plugins/themes ready to be translated into other languages.
POT, PO and MO files
POT (Portable Object Template ) file
- POT file is used as starting point for translations
- It contains all the original strings that need to be translated in other languages
PO (Portable Object) file
- The PO file contains the actual translations from the template files
MO (Machine Object) file
- MO file is generated by compiling the PO File.
- It is optimised to be used in actual translations
WordPress Flow
I got through the wordpress core files to learn how exactly the files are run one by one, like how the wordpress flow works to better understand the actions and filters.
- Index.php file is entry point when an user visits the WordPress blog
- After index.php wp-blog-header.php is loaded. This file loads the wp-load.php file to load the wordpress
- Then it moves to loading template-loader.php
- the template loader redirects to the template and emits
template-redirectaction

__() , _e() functions in i18n
In order to make a string translatable in your application you have to just wrap the original string in a __() function:
__( 'Hello, dear user!', 'movie-library' );
If your code should echo the string to the browser, use the _e() function instead:
_e( 'Watch from here', 'movie-library' );
gettext hook
The gettext filter is used to translate the strings in our plugin
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Salman' :
$translated_text = __( 'Bhai!', 'movie-library' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
Leave a Reply