RE: Translation - fast and dynamic plugin function and modifier

From: Date: Mon, 25 Mar 2002 18:50:06 +0000
Subject: RE: Translation - fast and dynamic plugin function and modifier
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3337@lists.php.net to get a copy of this message
M> Great, thanks for the examples. Anyone done a mixture of the two M> approaches? File based for static translation, and DB for dynamic? At the moment, i'm working on a smarty powered site which features 4 languages. Most data comes from a mysql databases, all the multilingual fields being prepended with _lang. My queries look like SELECT field_$lang as field, field_$default_lang as field_default FROM table WHERE condition In my template, i use these field that way: field: {$FIELD|default:$FIELD_DEFAULT} For the static text translation, i've written a little smarty function, named trans. It takes as an optionnal argument the current language (lang), and as many string parameters as the possible language values. By instance, in my situation, the languages are fr, angl, all and lu (French, English, German and Luxemburgish). So i'll come up with something like {trans lang=$LANG fr='fr text' angl='english text' all='german text' lu='lu text} the displayed parameter being the one with the same name that $lang. btw, if $lang is ommited, the session variable LANG is used. That way, i easily get my static and dynamic text translated. Using an external file for translations is in my opinion quite useless and a loss of time. Hope it helps, Bertrand

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