Re: 1 shot translation / solution 4 U :-)
| From: | Norbert Röcher | Date: | Sun, 14 Apr 2002 01:37:01 +0000 |
| Subject: | Re: 1 shot translation / solution 4 U :-) | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3686@lists.php.net to get a copy of this message | ||
"Olivier Hericord" <ohericord@free.fr> schrieb im Newsbeitrag
news:B8CCF5D3.1369%ohericord@free.fr...
[.. bla bla...] :-)
>
> MY PROBLEME IS:
>
> When a have a section which outputs 90 rows with 3 translation by
rows like
> {translation VERBOSE="change"} , {translation VERBOSE="delete"}
{translation
> VERBOSE="details"}, it proceeds to 270 translations => 270 HITS ON
THE
> DATABASE TO TRANSLATE 90 TIMES THE SAME THING!!!!!!!!!!!!!
>
> What's the solution?? PreFilters??? PostFilters???
The solution is to do some intelligent coding within your
translation-function!
While i don't know, how your coding exactly looks like i just post a
suggestion:
function translate ($string){
static $translated = array();
if (isset ($translated[$string])){
return $translated[$string];
}
$result = INSERT HERE YOUR QUERY FOR THE TRANSALTION
OF YOUR STRING;
return $translated[$string] = $result;
}
From now on each translation will only be queried once for each
sitehit.
> Are postfilters executed at every request of an already compiled
template???
> If YES, could it be possible to build a postfilter to parse the
compiled
> template to find particular tags and to replace them with a single
needed
> access to the DB?????
A prefilter could be another solution, if you use selfdefined tags like
BBcode (something like [trans]my word[/trans]). But i think the above
posted solution should solve your problem for this time.
Greetings,
Norbert