Internationalise your WordPress theme


Make a languages folder in your theme directory to place your translation files.

To include translation files in your wordpress theme add the load_theme_textdomain function to your functions.php file preferably in ‘after_setup_theme’.

add_action( 'after_setup_theme', 'ML_theme_setup' );

if ( !function_exists( 'ML_theme_setup' ) ) {
function ML_theme_setup() {
load_theme_textdomain('ML', get_template_directory() . '/languages');

The First parameter of the load_theme_textdomain function, in this case ‘ML’, is the theme domain name which should also be included in each translation function as the second parameter like this…

__('translatable string','ML')  


_e('translatable string','ML')

Your stylesheet should also have this name included at the top of the file, i.e Theme Name: ML

__() and _e() return or echo the respective translatable string.

Once you have made all your translatable strings in your theme you need to make a .po file .mo file to put in your langauges folder.

I used the upgraded version of poedit to do this. poedit will scan your wordpress theme and pull in all the translatable strings automatically.


Choose ‘Translate WordPress theme or plugin’ and then select your theme folder.

Once you have translated all the strings poedit automatically saves the .po and .mo files which you should add to your languages folder via ftp.



No Comments

Leave a response