Blogs for Bands Development

Translating Plugins

To follow along with this tutorial, you’ll need to download and unzip the latest version of the plugin you want to translate (perhaps the development version) and then download and install Poedit.  Poedit is a free piece of software that has installers for Windows and Mac and can be installed through most Linux package managers.  If you have another method of translating the POT file, feel free to do so.  For this tutorial, I’ll be using Poedit on Windows Vista, so forgive me if the screen shots don’t look exactly like what you’re seeing.

Once you have Poedit installed, open it up to the initial blank screen. In the File menu, select New Catalog from POT File.

In the file open dialog, browse to the folder where you have unzipped the plugin.  Select gigs-calendar.pot.  This contains all of the text that needs translating.

Now you need to set up your new catalog.  In the dialog that opens, enter the name of the plugin and the version number.  In this case, we are opening the POT file for Gigs Calendar version 0.4.  Then enter your name and email address (both are optional).  Next enter the language and the locale for your translation. Click “OK” to continue.

Next, enter the filename that you want to save your translation as. You’ll need to use a specific format. First use the filename of the POT file you used without the extension. In this case, “gigs-calendar”, then add a dash, then the locale code. This has two parts, your language code and your locale code. For Mexican Spanish, you would use “es_MX”. The proper codes can be found in Appendixes A and B of this document.  All of these together give us “gigs-calendar-es_MX.po”.

Now you’re ready for the actual work of translating. You should immediately see a list of strings that need translated. When you click on a string, it will populate into the box near the bottom of the screen.  You will type your translation into the box below that one. Translate them as best you can, being sure to retain any HTML entities you come across. If you don’t want to do all of the translations at once (there can be a lot of strings), you can save the file and come back later.

Once you’re done, click on the save button to save your translation. Two files will be generated for you, a .po file and a .mo file.  Both are important.  The .mo file is what WordPress actually uses to translate the plugin.  The .po file will allow you to update your translation when a new version of the plugin comes out.  If you would like me to add your translation to the plugin, send me both files.  That way, if you cannot continue translating, I can send the .po file to another interested party who can build on your work.

Now that you have your .mo file, you can upload it into the plugin’s i18n folder in your WordPress install.  You may have to set WordPress’s locale.  In your wp-config.php file, see if there’s a line that looks like this:

define ('WPLANG', '');

If that’s blank, just put in your locale code. If it’s missing, simply create a new line. In my example, I would want to set that to Mexican Spanish

define ('WPLANG', 'es_MX');

Now you’re all done! Coming soon… how to update your translation for a new version of my plugin.

Comments

  • Toni L 6:11 am on January 2, 2009 | #

    Hey I tried to apply this, for this plugin in WP 2.7.

    I’ve set the locale to
    define (‘WPLANG’, ‘fi’);
    which refers to Finnish. Then I made a file .mo named gigs-calendar-fi.mo . I saved the file in plugins folder root.

    Plugin wont get translated is there something I’ve done wrong?

  • Dan 12:49 pm on January 2, 2009 | #

    Toni,

    I forgot to mention in the article, but you should put your mo file in the i18n folder. Be sure you back it up, because it’ll get overwritten if you do an automatic plugin update. Also, if you’d like to email that file to me, I’d be happy to include it.

Leave a Comment

  • Recent Tags

    All Updates RSS

  • Blog at WordPress.com
    Prologue theme by Automattic

  • Order kamagra 100mg buy priligy online usa