Make Your WordPress Theme Translatable

Today I made my Pets & Vets WordPress Theme Translatable. At first it seemed a little daunting, here is a quick guide.

Step 1: Add some functions.

Add this to your functions.php file, change “YOURTEXTDOMAIN” to something unique, like your theme name.

// language files
add_action('after_setup_theme', 'theme_setup');
function theme_setup(){
    load_theme_textdomain('YOURTEXTDOMAIN', get_template_directory() . '/languages');

Step 2: Edit your text

Go through every file in your theme, for simple text, that isn’t already wrapped in php, use the “_e(“option below. For text that is already wrapped in php, use the “__(” option below. Also, don’t forget to replace YOURTEXTDOMAIN with the one set in the first step.

<?php _e("This is the translatable text", "YOURTEXTDOMAIN");?>
<?php the_content(__('Read more...', "YOURTEXTDOMAIN"));?>

Step 3: How to create a PO file

Goto the link below and upload your theme files. After a few moments, it will give you the source for your PO file, or you can download the PO file GZipped… Unzip it and add it to your “/languages” subfolder.

Theme Authors! You’re Done….

Now for the translators:

Step 4: How to create a MO file

Download Poedit from here: and install.

Screen Shot 2014-04-03 at 3.25.34 PM

Click on “Create new translation” and open our new PO file.

Select the language you’re translating it to. Make your changes to the translation. Save.  Add your new PO and MO files to the language folder.

Step 5: Implementation

Open wp-config.php and add the code below with your corresponding language code. Here are the country and language codes.

define ('WPLANG', 'fr_FR');
Tags: , , , , ,
Previous Post Next Post
Digital Designer / WordPress Theme Developer

Leave a Reply

Your email address will not be published. Required fields are marked *