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

Peter Westwood peter.westwood at ftwr.co.uk
Sun Jun 21 21:23:15 GMT 2009


On 21 Jun 2009, at 20:07, Heiko Rabe wrote:

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

That doesn't sound right to me.

Looking at the code in pomo which parses the file in [1], and the code  
for the C gettext library, I believe the following is true

In the binary mo file the context is stored at the start of the  
translation followed by ascii character EOT (character code 4) this is  
then followed by the translated string.

In the plain text pot or po file it is stored in the context field,  
for example from [2]

#: wp-admin/menu.php:62
msgctxt "page"
msgid "Add New"
msgstr "Нова"

[1] - http://svn.automattic.com/wordpress/trunk/wp-includes/pomo/mo.php
[2] - http://svn.automattic.com/wordpress-i18n/bg_BG/tags/2.8/messages/bg_BG.po

westi
-- 
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5



More information about the wp-hackers mailing list