RE: RE: [SMARTY] using different languages in my Templates

From: Date: Fri, 20 Dec 2002 13:56:46 +0000
Subject: RE: RE: [SMARTY] using different languages in my Templates
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6911@lists.php.net to get a copy of this message
Hmmm, well, the sites I build rarely have more than 500 hits a day, so this doesn't really impose a great threat to our servers. But of course if your hits rise above that level, it might become an issue. Well, I might have an idea, but perhapse it's a crazy one... Here it comes: Suppose you could create a prefilter for smarty that does the following: - regular expression on something like {translate key="([^"]*)"} - with preg_match_all you would get all the matches in an array - with impode you should be able to create a comma-separated list of all the keys used in your template - with a QUERY something like this : SELECT * FROM wordlist WHERE key in (commaSeparatedKeys) you should be able to fetch all the used words in your template in one query (commaSeparatedKeys should be the string you created in the previous step with all the comma separated keys) - now you can do a replace in the template so that the correct translated words appear in the template This way you'd have only one query and you can still use the {translate key="key_to_translate} syntax. How about that? Yuri -----Original Message----- From: Andreas Korthaus [mailto:akorthaus@web.de] Sent: Friday, December 20, 2002 2:38 PM To: smarty-general@lists.php.net; Yuri Weseman Cc: Andreas Korthaus Subject: Re: RE: [SMARTY] using different languages in my Templates Hi Yuri! > I had a similar problem not so long ago and decided to go for a custom > plugin like this: > {translate key="key_to_translate"} > > The translate plugin used the specified key to lookup a translation in the > database according to the currently set language (which can be stored in the > GET, a cookie, or in the session or whatever). But if I do this, I can get a lot of database-querys! If I have 80 translate-keys, I will have 80 extra and seperate database querys. That must make it very slow, doesn't it? I would like to include_once() a spezial file with a multi-dimansional array with all keys of this template and the according language-strings. But the question is, what should I do to have keep my language-files up to date? I can save the data of all these files in my database, and if something changes in this database, the file(s) have to be created again. Has someone an idea how to build something like this into a smarty-template solution? Kind regards, Andreas ____________________________________________________________________________ __ Werden Sie kreativ! Bei WEB.DE FreeMail hei?t es jetzt nicht nur schreiben, sondern auch gestalten. http://freemail.web.de/features/?mc=021142

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