on Tips

WordPress translation with PoEdit

3 comments
WordPress
Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon

I was there, too, struggling to make a proper settings in my PoEdit program and prepare all the strings for WordPress translation.

But there is always some quirks there that made me go Oooh. Tried everything, premium plugins and stuff, those plugins are good, but when you’re on a deadline, you always mix languages in translation strings.

Anyway, first thing to know is that you always develop in English first. That is the way to go, and that way you will not have problems with mixed languages later.

Don’t be tempted to add those Chinese that your client gave you in your translate string. You will regret it later.

I will not talk much and will give you a link where everything is explained. This guy deserves it. Thanks to Luka Peharda for the link to this awesome resource.

So, go to WordPress translation secrets and enjoy. This guy has it all, and what is the most important, that I could not find anywhere, is the configuration for the PoEdit to suck in all those WordPress translation functions easily.

Poedit needs to know what functions it must look for and get information from. In reality, gettext knows by itself what to look for in a .php file, but since WordPress uses its own wrapper functions to make our lives easier, this knowledge is no longer applicable.

In a few words, you should add this stuff to your PoEdit preferences to make it dance with WordPress translation:

_e
__ngettext:1,2
_n:1,2
__ngettext_noop:1,2
_n_noop:1,2
_c
_nc:4c,1,2
_x:1,2c
_nx:4c,1,2
_nx_noop:4c,1,2
_ex:1,2c
esc_attr__
esc_attr_e
esc_attr_x:1,2c
esc_html__
esc_html_e
esc_html_x:1,2c

After you have this, no string will ever escape from PoEdit (if properly put in translate function, of course).

Again, many thanks to Anastis Sourgoutsidis who made my life easier.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon



  • Torbjörn Sjögren

    Hi
    Somewhat related to this post.
    Do you know about the Codestyling Localization plugin? I use it all the time. Check it out:
    http://wordpress.org/plugins/codestyling-localization/

  • http://www.cssigniter.com Anastis Sourgoutsidis

    Hi Svonko,
    I’m glad you liked my article :)

    Actually, I’ve just discovered a few more functions that need to be covered, so I will update the post in a few days.

    The source of the “new” functions I’m mentioning is the wordpress-i18n tools, as mentioned in http://codex.wordpress.org/I18n_for_WordPress_Developers#Generating_a_POT_file specifically the section right after the screenshots.

    Hope this helps :)

  • http://www.cssigniter.com Anastis Sourgoutsidis

    Btw, the plugin Torbjorn mentioned, Codestyling Localization, is an excellent plugin that I often use, particularly while checking our themes before release for accidental multiple domains and strings ending in whitespace.

    However, it too misses quite a few functions (5 in total, 1 from my list, if I’m not mistaken).