« 3rd Try | Main | Postfix To PHP »
September 25, 2006
Smarty & GNU gettext System
I was looking for a good Smarty GNU gettext implementation a few weeks ago and found one here. Problem with that specific one though was that I did not like that it used a Smarty block (the obvious choice normally) to handle the gettext blocks, since that kills Smarty variable usage in them.
So what I did was I wrote my own handler based on the smarty-gettext I found using a Smarty Prefilter instead. This way I can use smarty syntax inside the gettext blocks. Of course using full ifs and such is not wise and will confuse translators, but using variable names will actually be easier than using %1 %2 %3 and so on as needed with smarty-gettext, since its more obvious for the translater what will actually be displayed in its place.
The source of the prefilter with a short explanation of its usage can is attached.
Download smarty-gettext-prefilter.php
And also a short script taken from smarty-gettext to scan templates for gettext blocks and build fake C code from it to use with the standard gettext tools can be downloaded here.
Enjoy!

This work is licensed under a Creative Commons Attribution 2.5 License.
Posted by Nathan on September 25, 2006 at 04:09 PM in Coding | Permalink
TrackBack
TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83445413953ef00d8353476c253ef
Listed below are links to weblogs that reference Smarty & GNU gettext System:
Comments
Hi,
Your post is what i'm searching.
Thank you!
But, may you give me one example of the use of this plugin?
I can't starting without one example, because i not undertod the coments on the source file, and i dont know where put this source file.
Posted by: Marcus Vinicius Bastos Leandro | Dec 13, 2007 1:39:38 PM