[wp-hackers] Re: [wp-polyglots] no-code-duplication i18n for WordPress

Nikolay Bachiyski nbachiyski at developer.bg
Fri Mar 7 08:18:35 GMT 2008


2008/3/7, Lionel Elie Mamane <lionel at mamane.lu>:
> On Thu, Mar 06, 2008 at 06:44:28PM +0200, Nikolay Bachiyski wrote:
>
>  > Apart from not spending time on this issue, here is some
>  > proof-of-concept tokenizer code, which will make the extracting and
>  > replacing work very easy and clean:
>
>  > http://nb.niichavo.org/files/code/token_comments.phps
>
>
> From reading this code, it seems to me it will miss any strings
>  containing variable references, while mine catches them (albeit in the
>  suboptimal way of cutting the string at the variable reference, which
>  is why I suggest to replace them by format strings in sprintf calls);

Recognising only literal strings was my goal. Letting translators
translate arbitrary PHP code can and will be disastrous.

>  compared to mine, it also does not allow to tag a whole function call
>  (or code block) with several strings to be translated in it, it really
>  needs a separate tag for each. OTOH, it doesn't use an end tag, this
>  might balance it. Being less strict in the special-tag match is
>  probably better, like allowing arbitrary amount of whitespace between
>  "/*" and "WP_I18N"; should do that.As the tokenizer-method allows us
>  to gettext-lookup the string itself (albeit in PHP-escaped form), I
>  don't think recognising _all_ tags of the form WP_I18N_.* is
>  desirable; just _one_ start tag and _one_ end tag. This allows to
>  reserve the other ones for eventual future different use.

Modifying the code, so that it doesn't impose so rigorous rules is
very easy -- this was just a proof-of-concept program. The main point
of the code was to show that the tokenizer is a good friend of ours.

Happy hacking,
Nikolay.


More information about the wp-hackers mailing list