Re[3]: [SMARTY] using gettext with smarty

From: Date: Sun, 16 Mar 2003 21:18:03 +0000
Subject: Re[3]: [SMARTY] using gettext with smarty
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8681@lists.php.net to get a copy of this message
Seems the list removes attachements. Anyone who's interested can mail me in person. /l On Sun, 16 Mar 2003 18:23:03 +0100 (CET) Linus McCabe <linus@mccabe.nu> wrote: > > I use gettext and to extract the strings i parse the templates before > passing them on to xgettext() etc. It's not a very good solution, but it > works. It shouldn't be too hard to write a xgettext clone though... > perhaps > ill do it one of these days if i have the energy and happens to be bored > ;) > (not likely) > If you feel like writing a clone yourself you could easily do it in php, > see smartys functions for good examples of regexp to extract strings etc. > > Attached are two scripts that does the work, they go through a number of > paths, search and replace templates and phpfiles, write them to a > temporary file and > pass it on to xgettext. > > It shouldnt be too hard to modify them to suit your needs, but beware, > they > are not pieces of art ;) > > /linus> > > On Sun, 16 Mar 2003 12:15:17 -0500 (EST) "James E. Flemer" > <jflemer@acm.jhu.edu> wrote: > > > 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 > > > > > > > >

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