Recently I´ve been translating a theme and while the translation process wasn´t complicated at all, it took me quite some time to figure out how to get started. Somehow none of the ´how-to´s available seemed to work for me. I´ll try to make this guide a practical one by covering only the need-to-know and leaving aside the technical details.
Localizing Wordpress - a brief overview
If you ever had to translate a Wordpress theme or plugin directly in the source code, you´ll know that it´s a time-consuming process. A time-waisting process as well, since which each update you´d have to translate the files all over again.
Fortunately, a growing number of Wordpress developers have made their work available for internationalization, by adding a PHP-function to all the text messages that will be displayed:
__($message)_e($message)
For translators it´s not necessary to know exactly how these functions work.
This method allows you to make a list of all the text strings available for translation. This list is called a POT-file and consists of two columns: the left column contains all the words and phrases of the theme or plugin that are available for translation. The right column is still blank: this is where you can add your translations.
When the translation is completed, you´ll save the file as a PO-file. Now you have an external translation file that you can edit or update whenever you want! Converting this PO-file to a MO-file is the last step in the localization: this MO-file is basically a optimized PO-file for your server in order to retreive the translations faster.
Recapitulating:
| Internationalization/localization | Making Wordpress available in languages other than English |
| POT (Portable Object Template) | List of messages available for translation |
| PO (Portable Object) | List of messages available for translation with translation next to it |
| MO (Machine Object) | Optimized machine-readable binary file in order to speed up the process on the server-side |
Using Poedit to translate your theme or plugin
Poedit is a free open-source translation tool that allows even the most code illiterate blogger to translate his favourite theme or plugin in his own language. While simple to use, the interface is not the most intuitive. This step by step guide will lead you through the process.
- Download and install Poedit
project - download - Run Poedit.
When asked for a prefered language just choose the language you want to use in Poedit. Fill in your name and email address. These will be included in your translations. - Start a new translation
Choose File > New Catalog
(if provided, you can edit an existing POT-file by choosing File > New catalog from POT file) - Fill in the settings
- Poject name and version - Add the name and version of the theme or plugin
- Team - Add your name
- Team´s email address - Add your email address
- Language - Choose the language you´re going to translate to from a list. The order is not 100% alphabetical, so fill in the first letters and use your keyboard arrows to find the language.
- Country - Add your target country. To find it, use the same trick as mentioned above.
- Charset/Source code charset - Add them if you know what they are. Wordpress uses UTF-8 by default.
- Plural Forms - Add a function to describe how to process plural forms. For most languages you can just copy-paste the formula from this list.
- Base path - Add the path to the folder of the theme or plugin you want to translate. You can copy this path from your windows explorer browser window or by viewing the properties of the folder (right mouse click).
- Path - Add the path within the folder to your theme or plugin
- Fill in the two functions the developers have used to make massages available for translation:
__( underscore underscore) and_e(underscore e) - Save your POT-file.
When you´re done, just hit enter and Poedit will compile a POT-file of words and phrases ready to be translated. Save this list. - Start translating.
Now that you´ve got a complete list of all the words and phrases, you can start adding your translations. Poedit also offers the possibility to add comments. To use this function, go to View > Show comment window. Remember to save the file while you´re working, so you won´t loose your data when you´re computer crashes. - Save your PO- and MO-file
When done, go to File > Preferences > Editor and make sure the box ´Automatically compile .mo file on save´ is ticked. Save your file as a PO-file, using a combination of language and country codes. E.g. a Brazilian translation would be saved as pt_BR.po and Spanish would be es_ES.po. - Upload your translations
On saving Poedit automatically prepared a MO-file for you. Just upload the PO and MO files to the appropriate folder of your theme or plugin and you should be able to view your translation in the theme/plugin interface. If you have defined the appropriate WPLANG in your wp-config.php file, that is.
-
- Tab: Project Info -

- Tab: Paths -
* Click the little dotted square to add a new item *
Example:
This is what I´d fill in if I´d want to translate a theme called “TranslationTheme” located in this location:
C:\Documents and Settings\User\My Documents\Folder\TranslationTheme

- Tab: Keywords -
* Click the little dotted square to add a new item *








Sin Comentarios ↓
Deja un comentario
Deja tu comentario >>