Re: [SMARTY] using gettext with smarty
| From: | James E. Flemer | Date: | Sun, 16 Mar 2003 17:15:17 +0000 |
| Subject: | Re: [SMARTY] using gettext with smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8677@lists.php.net to get a copy of this message | ||
On Sun, 16 Mar 2003, Peter Bowyer wrote:
> At 20:22 13/03/2003 -0500, James E. Flemer wrote:
> >The problem is that functions have to look like:
> > {gettext msg="Smarty is fine with this."} or even
> > {_ _="Smarty is fine with this."} or
> > {"This is ok, too."|gettext} etc.
> >
> >If I use something that Smarty likes, then the gettext tools
> >don't work (to extract the message catalog). Does anyone have
> >suggestions, or better yet something already implemented? I'd
> >rather do this with a plugin, tho modifying Smarty is an option.
>
> One way would be to use a prefilter to convert those latter two types to
> the necessary PHP code. Although I think this would mean having Smarty set
> to allow PHP code in your templates which may/may not be a security risk in
> your case. I think this would be necessary as the compiler would see PHP
> code. I can't actually remember though - it's been such a long time since
> I used Smarty for anything like this.
You missed the point. The problem is that unless you have code
that looks like:
_("....") or
gettext(".....")
none of the gettext tools work. Without being able to extract
the strings for translation out of the source code automatically
makes gettext completely useless. Sure I could modify
all the gettext tools, or write perl scripts to do their job
with the new smarty syntax, but I'd rather not.
Smarty would really benifit from being able to use gettext with
it out of the box. Or I guess the world can go ahead using
associative arrays for translation like:
$spanish = array( "hello" => "hola", "good" =>
"bueno" );
rather than use existing tools.
-James