Blog

How-to translate WordPress Theme and how to compile .po files

In the last couple of month i found several threads in the AppThemes forums about “How-to translate WordPress Theme” into another language. There is a tutorial available, but it seems that it’s not clear enough for some beginners. In this tutorial I will try to explain how a translation is done and how to edit only some words in an existing translation. For this tutorial i’m using the ClassiPress theme. Here we go in two parts:

languages

  • Part 1 : Translating the ClassiPress Theme using language packs
  • Part 2 : Editing words in a .po file and create a new .mo file

Part 1 – Translating the ClassiPress theme using language packs

I assume you have already installed your ClassiPress Theme on your webspace and everything looks fine, except that this is not the language that you want. So the first thing you do is visit the AppThemes language section which you can find here:

AppThemes Language Packs

You will see the list of all the Theme Language Packs from AppThemes. As we are doing it for ClassiPress, please click on that “ClassiPress” link. Now look for your language. In this tutorial i will select the German Language Pack and so i download the classipress_3.3_de_DE.zip on my pc. Next step is to unzip that file. You will find two (2) files inside, which are:

  • classipress-de_DE.po
  • classipress-de_DE.mo

First, let’s explain simply what the difference is:

  • PO – Portable Object. This is the file that you receive back from the translators. It’s a text file that includes the original texts and the translations.
  • MO – Machine Object. The MO file includes the exact same contents as PO file. The two files differ in their format. While a PO file is a text file and is easy for humans to read, MO files are compiled and are easy for computers to read. Your web server will use the MO file to display the translations.

That’s enough to know at the moment, let’s continue:

Now open your FTP client and go to your WordPress website. Find the wp-config.php file in the root directory of WordPress. Open that file with your text editor and look for this part:

As we want the translation in German, we change the above code to this:

Don’t write de_de or DE_DE, do it exactly like i did: de_DE 
Find the correct ending for your language here: http://codex.wordpress.org/Installing_WordPress_in_Your_Language 

Save the file. Now navigate with your FTP client to the /wp-content/languages/themes/ folder and upload the two files that you unziped before (classipress-de_DE.mo and classipress-de_DE.po) in that folder. Normally you only need to upload the .mo file, but in the next part you will find out why we also upload the .po file

You are done! Refresh the front site (CTRL & F5) and enjoy your native language. In the next part i will explain you how to edit the language files:

_______________________________________________

Part 2 : Editing words in a .po file and create a new .mo file

Maybe you have just translated your theme and now found a word you don’t like the way it is translated. Time to change that. But before we start let me explain as easy as possible why we have two language files.

  • The .po file can be opened with a normal editor.
  • The .mo file is a optimized machine-readable binary file (MO file)  and can not be edited by a normal editor.
If you just open the .po file, do your changes and upload it back to your webspace, the translation will not show up!

So we need another tool. To get it, please go to http://sourceforge.net/projects/poedit/files/ and download poedit-setup.exe. Install that software on your pc.

And now please read carefully: Start  Poedit and open the classipress-de_DE.po into that programm. That programm is very easy to use, just look for the words and translate them as you like. Save the file. Now the big magic happens! Poedit did not only change the classipress-de_DE.po file. It also changed the classipress-de_DE.mo file into a binary file without you knowing it. If there isn’t a classipress-de_DE.mo file Poedit will create a new one. Why? Because we only need that classipress-de_DE.mo file on our webspace. The classipress-de_DE.po file we only use in Poedit to create that classipress-de_DE.mo file. OK? 😉

But i suggest to upload both files to your webspace, just in case you find more words to edit and don’t know where you stored your classipress-de_DE.po file on your pc. Next time you just need to download the classipress-de_DE.po file from your webspace, do more edits, save it and upload again both files to your webspace.

Check the front site if the translation was successful. If you did everything as described, it should now be translated.

Please rate this tutorial if it was helpful for you. Thanks for reading and good luck with you site.

How-to translate WordPress Theme and how to compile .po files 4.97/5 (99.41%) 34 votes

Tags: , , , , ,

8 Responses to “How-to translate WordPress Theme and how to compile .po files”

  1. miko July 31, 2013 at 00:56 #

    How do u translate there is no part 1
    ( there is no langue pack i need)

  2. Rolf Hassel August 1, 2013 at 13:28 #

    Then you will need to build your own language pack. See more infos here: http://www.appthemes.com/blog/how-to-translate-a-wordpress-theme/

    Cheers

  3. Branko Jagodic August 18, 2013 at 18:19 #

    Thanks!

  4. Steve Gallegos August 20, 2013 at 23:23 #

    Thank you Rolf for the excellent instruction. I followed them to the letter in order to switch the language to Spanish. But…after following all the steps, my website native language is still in English. Note: if you visit the site you will see that some of the text is in Spanish, however that is because I entered that language manually. The basic theme text remains in English. Any ideas?

    Thank you
    Steve

  5. Manish August 25, 2013 at 06:31 #

    Hi Samcy, can you kindly explain how do I make English English translation for certain words like Ads=>Vehicles, Ad=> Vehicle

  6. amazing September 8, 2013 at 08:10 #

    This is an amazing article , thank you for sharing

  7. angcbam September 15, 2013 at 15:09 #

    Thanks Samcy, this worked perfectly for me

Leave a Reply


+ 9 = 15

Go Up ▲Go Up ▲