Re: [SMARTY] smarty and GNU gettext

From: Date: Tue, 30 May 2006 13:22:39 +0000
Subject: Re: [SMARTY] smarty and GNU gettext
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13442@lists.php.net to get a copy of this message
You really don't want to use it, since the performance gains are negligible from a custon made library getting the stuff from a DB -I've done and made benchmarks and the results are similar with an edge going to custon made libraries when you're using high ammounts of translated terms- . For legibility reasons I implemented my system as block plugin: {translate}text{/translate} and added some localization functions to deal with numeric format etc.. On 5/30/06, Marcus Bointon <marcus@synchromedia.co.uk> wrote:
On 30 May 2006, at 13:11, D_C wrote: basically gettext is a php function, so if this is used in the middle of a smarty template, it will make templates really ugly. I think! Unless there is a clean way to inline php funcs inside smarty... You really don't want to do that... also, since a php funciton is being called in the middle of a template, i imagine this stops smarty from being able to pre-compie/ cache the template itself? So, any suggested approaches? Yup. Wrap it up in a Smarty plugin. Many smarty plugins are no more than this, so try looking at some. You might need a pair of plugins - an initializer (e.g. to select and load an appropriate language file) and a modifier to display a text item. The popup plugins work this way. Can a modifier function work directly on a string? eg if i created a localize() modifier that called gettext, then: had a template like this: { "message list" | localize } Yes, you can use this syntax. Try for example {"hello world"| escape:"url"} and it will render to 'hello%20world'. There are several Smarty translation mechanisms around (including some that use gettext) - try looking at the wiki: http:// smarty.incutio.com/ Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture marcus@synchromedia.co.uk | http://www.synchromedia.co.uk -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Vicente Werner y Sánchez

« previous php.smarty.general (#13442) next »