Re: Localizable template

From: Date: Mon, 07 Jun 2004 06:33:02 +0000
Subject: Re: Localizable template
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12963@lists.php.net to get a copy of this message
Hi! Enver ALTIN wrote:
I have been recently upgrading an older project to use HTML_Template_IT and gettext all around, and I'm stuck! :-) How do I enable a template to be localized? It seems that the intltool-update script can collect things like:
        <h2>_("Some text to localize")</h2>
these, what's the good way to gettext() them? Could we wrap another localizable class around the template engine, parse these and call gettext() as needed, replacing these parts? If you think this is the good way, can you point me to the right direction to do it?
You should use the HTML_Template_ITX class (note the 'X', is is part of HTML_Template_IT package as well) and its 'callback' feature. You add something like <h2>func_gettext("Some text to localize")</h2> to the template (the script collecting the strings can be tuned to extract such a string quite easily) and do $tpl->setCallbackFunction('gettext', 'gettext'); in your script. Of course, there are some not-quite-obvious problems with callbacks in HTML_Template_ITX and callbacks there are not documented, so you may consider using HTML_Template_Sigma instead, where callbacks work better, *are* documented and there is an example included showing how to use them for i18n.

« previous php.pear.general (#12963) next »