RE: [PHP] Multiple languages

From: Date: Sun, 15 Jul 2001 06:54:07 +0000
Subject: RE: [PHP] Multiple languages
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57920@lists.php.net to get a copy of this message
The best way to do it definitely is: make several files with an array like: file: lang.eng.inc: $dict = Array(); $dict['name'] = 'Name'; $dict['button']['red'] = 'Red Button'; file: lang.ita.inc: $dict = Array(); $dict['name'] = 'il nome'; $dict['button']['red'] = 'il bottone rosso'; file: lang.spa.inc: $dict = Array(); $dict['name'] = 'nombre'; $dict['button']['red'] = 'er botone roso'; file: lang.rus.inc: $dict = Array(); $dict['name'] = 'Imya'; $dict['button']['red'] = 'Krassnaya knopka'; file: lang.jap.inc: $dict = Array(); $dict['name'] = 'Onamae'; $dict['button']['red'] = 'Aka no battonu'; and so on... and so on... then, in your scripts before any output (no, not a rule, just otherwise makes few sense)... 1. ... include a config file where the language is set. oh well, you can use any way you wish, cookies, sessions, get variables, whatever, as long as you can set a language of preference to the script. 2. include "lang.$lang.inc"; 3. In case you need something within a function or class just define variable $dict as global. Hare we go. This is the less resource consuming way, all you need is to set the language prefence correctly and work on keeping track of it. any code? Hmm, you could try to look into applications like phpmyadmin or Jinnie... but the difference here is, most of these doing a little mistake - they create a bunch of new variables for every phrase. Better do it with an array. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Inércia Sensorial [mailto:inerte@hotmail.com] Sent: Sunday, July 15, 2001 12:04 PM To: php-general@lists.php.net Subject: [PHP] Multiple languages Hi All, I want to enable multiple languages on one of my scripts, so administrators or visitors can choose in what language they want to browse the site. I have seen a few ways to do it, like with switch, define or querying databases. But, considering performance, what is the best way to make a script with multiple languages? Thanks for any ideas. -- Julio Nobrega. You're asking me will my love grow, I don't know. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#57920) next »