Re: [SMARTY-GENERAL] On multilanguage documents

From: Date: Mon, 08 Apr 2002 07:14:21 +0000
Subject: Re: [SMARTY-GENERAL] On multilanguage documents
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3553@lists.php.net to get a copy of this message
It sounds correct, but the main drawback of this method is in my opinion that you constantly have to work on several files as soon as you attempt to type a multiple text, even if the text you are typing is not gonna appear again in any other template. This method is ok for standard text, that appears again and again in many templates, but a pain in the ass for standard text. I rather use a translate smarty function, that takes as an argument the current language and the strings in the different languages. I think that it is correct to mix that method (for the texts which are 'reserved' to the current template), and yours, for the text that may repeat over the templates. Bertrand MP> How do you handle generating documents in various languages? MP> I do it like this (please correct me if there is a better/cleaner way): MP> 1. First, I produce config files with messages in each language - MP> e.g. for English & Polish: MP> file "en.conf": MP> > [alerts] MP> > no_js = Please enable JavaScript in your browser. MP> > no_cookies = Please enable cookies in your browser. MP> file "pl.conf": MP> > [alerts] MP> > no_js = Prosze wlaczyc obsluge JavaScript. MP> > no_cookies = Prosze wlaczyc obsluge cookies. MP> 2. In the PHP script, I pass special variable "language" to the template: MP> > $doc->assign("language", "en"); MP> 3. In the template, I include the proper config file and then - MP> use its values: MP> > {config_load file="$language.conf"} MP> > MP> > <html><body> MP> > <h1>{#no_js#}</h1> MP> > </body></html> MP> Please correct me if there is a better/cleaner way... MP> Thanks.

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