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

Heiko Rabe heiko.rabe at code-styling.de
Sun Jun 21 19:07:47 GMT 2009


Hi Peter,

thanks for the answer. If understand it right, than the result of *.mo 
file creation process will transform

_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 ?

regards

Heiko Rabe
(www.code-styling.de)

>
> On 21 Jun 2009, at 18:45, Heiko Rabe wrote:
>> i would be happy if somebody can explain the advantage of the new one 
>> similar translation capabilities:
>>
>>   _x('Published', 'page')
>>
>> in opposite to
>>
>>   _c('Published|page')
>>
>> 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.
>
> It allows for the context to be properly specified in the po file, 
> makes the string easier to translate (and also makes it safer to use 
> "|" in a string again)
>
> Previously in the pof file:
> #: wp-admin/edit-pages.php:78
> msgid "Published|page"
> msgstr ""
>
> Now in the pot file:
> #: wp-admin/edit-pages.php:78
> msgctxt "page"
> msgid "Published"
> msgstr ""
>
> So it is explicitly marked as context 
> (http://www.gnu.org/software/gettext/manual/gettext.html#Contexts)
>
> westi



More information about the wp-hackers mailing list