Re: [SMARTY] smarty and GNU gettext

From: Date: Tue, 30 May 2006 12:30:17 +0000
Subject: Re: [SMARTY] smarty and GNU gettext
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13441@lists.php.net to get a copy of this message
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

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