As part of my integration into Zend Framework, I wrote a replacement translator 
service for phptal. you basically just write a class that implements 
PHPTAL_TranslationService and then when you create the phptal instance you call 
its 'setTranslator' method and pass in an instance of your class.

I assume that the translator service is not actually called at compile time - 
only at runtime. Obviously if you use something like Zend you can make use of 
memcache to hold the translation keys in a cache (which works very well) but 
translating static text at compile time (if it doesn't already happen) would 
require deeper modification of phptal.

As an aside, I also make use of Zend's plural support and use a custom tales 
modifier to pass in the translation keys for singular and plural and then the 
variable with the value used to decide on the actual key to use. It works very 
well for me :)


On 2 Apr 2010, at 13:20, Florent wrote:

> Hi,
> I know that phptal i18n gettext implementation is fetching translations
> at run time.
> Performance-wise, it would be interesting to fetch translations at parse
> time and cache one compiled template per locale.
> Some workaround would be needed for plural translation, probably some 
> generated
> code based on the plural form defined in PO files.
> My question :
>> From where would you start in phptal code to change this behavior?
> How can I hook into i18n namespace and implement my own modifier?
> _______________________________________________
> PHPTAL mailing list

PHPTAL mailing list

Reply via email to