Localizing WordPress Themes and Plugins
It would be easy to assume that everyone on the internet speaks English. The majority of software is produced in English simply for the reason that doing so gives it a larger potential audience (or, maybe more appropriately, gives it access into the American market). However, you shouldn't assume this means everyone reads and writes English at the same level, or that non-native speakers wouldn't want software in their own language. There is a world of speakers outside of English and now is the time to tap into them.
This guide is another in the Inside WordPress series and will show how to prepare WordPress themes and plugins for localization. Not only will this open up your theme or plugin to more people, but it will contribute to the international reach of WordPress, and you'll receive the very satisfying feeling of seeing your own work in another language. A little extra effort at the start will soon pay off.
Some important points:
- You do not need to speak multiple languages yourself - localizing a theme or plugin just requires modifications to your code, not actual translation of words
- The localization process is relatively simple - there is no reason not to localize everything you create!
The guide will be written from a beginners perspective, but will take you through some fairly advanced concepts. As a theme or plugin creator it is assumed that you will be familiar with both HTML and PHP, although detailed explanations will be given at each stage.
If you are a translator you can read the sister article, Translating WordPress, which explains how to take an already prepared theme or plugin and translate it into another language.






Comments (page 3 of 3)
Oct 15, 2008 7:18 am
Where are the typos? In general spaces before brackets are not an error in PHP.
Oct 15, 2008 7:00 am
Great article, was very helpful for localizing a wordpress theme! Unfortunately, there are some typos in the code examples (spaces before brackets), that took some extra time to find and correct to get the code working. You might want to correct those. Peace.
Jun 23, 2008 10:11 am
Bah! I sorted it out finally. For some strange reason PoEdit couldn't handle my language settings properly and when I __ngettex the %, it returned errors and added some strange referral to #, php-format file, even though there's no such file in the theme I'm translating (and returned an error when saving).
However, I finally decided to do it the hard way, opened the .po file in Notepad ++, then added the following "by hand"
#: home.php:42
#: single.php:44
msgid "% comment"
msgid_plural "%d comments"
msgstr[0] "0 komentarz"
msgstr[1] "% komentarze"
msgstr[2] "% komentarzy"
Then I reloaded the file in PoEdit (but without reloading the files from the folder) and saved - without any problems this time. Just don't trust PoEdit and you'll be fine
Jun 22, 2008 3:52 pm
Message sent (using contact form).
Cheers
Jun 22, 2008 1:17 pm
Can you send the code you are trying to enter to me? I'll look into why it's not working here.
Jun 18, 2008 4:37 pm
BTW, the xhtml code function doesn't seem to work on your site, contrary to what a tooltip above the comment area says.
Jun 18, 2008 4:36 pm
A great tutorial indeed, thank you so much!. I'm using it for internationalization of the excellent TMA theme (The Morning After). Sadly, the tutorial doesn't seem to explain the ngettext thingie right. In TMA a similar function (comments_popup_link) is often called, but when I change the relevant passage the way you suggest, it gets messed up. Precisely, I change
into
When there is one comment or two - all gets translated just fine. But poedit doesn't see the other possibilities (3 comments, 4 comments, and so on) and where there are three comments or more - no text is visible at all. Any ideas?
Pings & Trackbacks
ak.artofliving.ru, farthinker.cn, lichao.net, pressedwords.com, simple67.cn, weblogtoolscollection.com, blogherald.com
Leave a comment