[wp-hackers] Question about translation extensions during WP 2.8

Nikolay Bachiyski nb at nikolay.bg
Sun Jun 21 21:13:11 GMT 2009

On Sun, Jun 21, 2009 at 22:07, Heiko Rabe<heiko.rabe at code-styling.de> wrote:
> Normally a GNU gettext processor would not allow to have the same phrase twice in file.
> So if the new _x method writes the phrase to *.mo file the same way as __ or _e would do, this may
> lead on some systems to bad behavoir because of double occurance and damaged hash map table inside *.mo file.

The context is part of the key, by which the strings are mapped in the
MO file. That's why it won't lead to ambiguities inside the hash map.
Actually, this is the proper gettext way of managing contexts. We
hadn't been using it before, because it wasn't well supported in the
various gettext tools, most notably poEdit.

> _x('Published', 'page')
> internally into
>  "Published|page"
> at the binary machine object file. If i now try to reverse a *.mo file, i
> can't figure out, if
>  "Car|House|Boat|Context"
> is a contextual separation string or just a menu item collection used at
> __(), because such information about context are not stored inside the
> binary format.
> So how would the mo/po classes figure out this, because | becomes unreliable
> during load of *.mo file ?

In the MO file, the context is stored in a different way, not like

>From the MO file specification:

    Contexts are stored by storing the concatenation of the context, a
<EOT> byte, and the original string, instead of the original string.

The full specification:

Happy hacking,

More information about the wp-hackers mailing list