[wp-polyglots] no-code-duplication i18n for WordPress
Lionel Elie Mamane
lionel at mamane.lu
Fri Mar 7 06:59:29 GMT 2008
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);
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.
Best regards,
--
Lionel
More information about the wp-polyglots
mailing list