Skip to content

WordPress translation with PoEdit

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:

[code lang=”php”]
_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
[/code]

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.

3 thoughts on “WordPress translation with PoEdit”

  1. 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).

Comments are closed.