[wp-hackers] wordpress.org *.pot file feature forpluginsgetsbroken by PoEdit
heiko.rabe at code-styling.de
heiko.rabe at code-styling.de
Wed Jul 22 10:48:07 UTC 2009
Let me explain (beside the effect of not assisted by PoEdit to translated the fields) what benefit for loading and runtime this would give.
Let's say, we have a function like:
function i18n_load_plugininfo($textdomain, $path) { ... }
What does the function do (best case description for example) ?
1.) It searches as currenct the related *.mo file.
2.) It loads the 28 bytes header and the searches the translation first entry (begin of trans table).
3.) it reads the first pair (size, offset) for the header translation.
4.) it seeks to the position of file and reads only size bytes from offset.
5.) it explodes string into a qualified header array.
6.) it returns the array with the header fields.
Because of specification of *.mo file format, the msgid table is sorted ASC and related to that fact are the trans string accordingly. That's why msgid "" is always trans table entry pair 0.
Doing so you would avoid loading the complete *.mo file into memory for purpose only to find strings to tranlate the plugin overview page. You only extract the header fields which are a few bytes instead of kBytes *.mo content.
This will massively increase speed of processing and reduced signific the amount of memory needed to make this kind of translation.
The only remaining thing is, how to translate it with editors like PoEdit. But the aspects for speed and memory load should not be thrown away.
Heiko Rabe
(www.code-styling.de)
> "X-WordPress-Plugin-Name: Custom Field Images\n"
> "X-WordPress-Plugin-Description: Easily associate any image to a post and
> display it in post excerpts, feeds etc.\n"
> ...
>
> and as new golden goal it would also work for gettextable themes, where you
> have currently no solution for:
>
> "X-WordPress-Theme-Name: My Super Theme\n"
> "X-WordPress-Theme-Description: This is the worlds best theme ever seen on
> earth.\n"
> ...
>
> I have written the proposed X-WordPress fields only english because of
> illustration but normally at a german file (de_DE.po) you would have german
> text there :-)
>
> This would be my proposal for keeping it inside the file and also can be
> keeped even if the files gets re-written by a new scan process.
> And because the header of a *.mo file get's processed dedicated (at least to
> get the pluralization formula and number) this fields could be extracted as
> easy as the plurals.
We can easily add the strings as headers, too.
The problem is that gettext editors don't give a interface to edit the
headers.
Let's say the strings are lost from the POT file for some reason. In
order to recover them, you will have to open the POT file using a text
editor, copy the strings from the headers and put them into a
msgid/msgstr blocks. Just re-running the makepot script is easier and
less error-prone than that.
More information about the wp-hackers
mailing list