Main | November 2006 »

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.

Download tsmarty2c.php

Enjoy!

Creative Commons License
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 | Comments (1) | TrackBack

September 13, 2006

3rd Try

I've been trying to get a blog started for some time now but never really had any idea of what kind of stuff to post... well, I've deceided to just start a totally generic one and just post whatever I want in it all jumbled up...

Lets see how long I keep up with it.

Posted by Nathan on September 13, 2006 at 04:09 PM in Generic | Permalink | Comments (0) | TrackBack