Savant and gettext support
Currently using Savant3 for a few projects I am working on, one required international support.
My first thoughts resulted in the following Savant_gettext which allows you to use gettext within your Savant template.
This works but after thinking about it on a busy website all this translation would use a lot of CPU on "static" content, but the website is 90% dynamic so caching was difficult.
Solution Savant3_Filter_translate This takes "Phrase" tags and translates them into "Translated Phrase" while not breaking other Savant3 templating code.
Using the same templates and a simple shell script, I can pre-translate all the files and have templates with all the savant code but already translated.
/templates/default
turns into
/templates/default
/templates/en
/templates/fr
And so on. Default has the base template while the others are the pre-translated templates required to build the site in the lang requested.
No overhead from gettext, no holding 500k worth of variables in memory at all times, Just a quick easy to maintain website. For testing you run off the default template, enabling you to instantly see the changes and translations. A live site uses the proper lang directory, resulting in a faster exp for the end user.


