logo       

RE: [SMARTY] newbie question: msg#00388

php.smarty.general

Subject: RE: [SMARTY] newbie question

Monte just covered this yesterday. As a newcomer to Smarty it
won't make a ton of sense right away, but here's what he said:

MO> I think some are using a compile_id for each language.
MO> That way you get a separate set of compiled files for
MO> the same set of templates.

As soon as a visitor picks a language preference,
put their pref in the session or cookie, then on each
page of your app, you can test that variable
to see which section of the code to output or
which table in the db to access. For example

if($_SESSION["lang"]=="en"){
//do english stuff
}elseif($_SESSION["lang"]=="fr"){
// do french stuff
}elseif{$_SESSION["lang"]=="du"){
// do dutch stuff
}

or better yet:
$sql="
SELECT * FROM table_".$_SESSION["lang"];
/* assumes you have 3 tables with the same setup:
table_en, table_fr, table_du
strongly recommended for populating pulldowns, etc.
you could also use 3 different INI files and put your
lang-specific strings in each one, then do substitution
with smarty based on reading in the strings from config
files.
*/

HTH-
Geoff

> -----Original Message-----
> From: Gert Van den Eynde [mailto:gvdeynde@xxxxxxxxx]
> Sent: Tuesday, January 28, 2003 8:23 AM
> To: smarty-general@xxxxxxxxxxxxx
> Subject: [SMARTY] newbie question
>
>
> Hello everybody,
>
>
> I'm just learning to use Smarty for our project website. And
> of course, I have some design questions ;-)
>
> The website is to be three-lingual (English, French, Dutch).
> A page would have a header, a footer, a navigation part on
> the left (a simple menu) and the main content area (classical
> layout). All these parts have a version in each language,
> i.e. there is a French, Dutch and English menu.
>
> What I intended to do was to create for each 'real' page a
> .php file that would instantiate a Smarty object using a main
> template. The language would be a variable in the Smarty
> object. There would be three subdirs (en,fr,nl) which contain
> the content for each page. I would then have the template
> file read in the content (based on the current file name) in
> the correct language, the menu in the correct language, etc.
> For example if a visitor wants home.php in English, the
> content would be read from en/home.html (or en/home.php).
>
> Is this a good way to proceed? Or is there a cleaner way?
> What about caching?
>
>
> Thank you for your help,
>
>
> Gert
>
>
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise