RE: [PHP] multilingual website

From: Date: Thu, 05 Feb 2004 21:21:59 +0000
Subject: RE: [PHP] multilingual website
Groups: php.general 
Request: Send a blank email to php-general+get-176935@lists.php.net to get a copy of this message
the PHPNuke (Portal software used all over the world, http://phpnuke.org/) code uses selectable including of php files containing define statements; in a directory call language (usually) there are files named lang-xxxx.php where xxxx is the name of the language; the current language selection is stored in each users session such that; $lang = $_SESSION["lang"]; // ie; $lang = "english" include_once("language/lang-".$lang.".php"); // ie; "language/lang-english.php" The included files contain define statements (defines are global constants and can't be accidentally updated by your code, I believe) define("_INPUTUSERID","Input User ID"); define("_PASSWORD","Password"); the french included file (language/lang-french.php) might look like; define("_INPUTUSERID","Eenpoot OOsair ahDee"); define("_PASSWORD","Paas voord"); // ok, so I flunked french You get the idea; then you need to go thru each html form and change every instance of text that appears on the form to a reference to one of these global values; echo "<table><tr><td><font class=content>"._INPUTUSERID."<br>" ."<input type=text name=fuser></font></td></tr>\n" ."<tr><td><font class=content>"._PASSWORD."<br>" ."<input type=password name=fpswd></font></td></tr></table>; Using the features of the language instead of a db access, means that the only time it takes to setup for each language is the time it takes to load and process the source include. I suspect this may be faster, has anyone timed other approaches? Note that this does not translate the data stored in your database, nor does it translate things coming from other sources such as directories, filenames, etc. When you provide both french and english input forms, you are likely to have some data stored in your database in french and some in english, potentially resulting in english forms with french data (and visa versa) on your website. hope this helps, Warren Vail -----Original Message----- From: julien dufourcq [mailto:juduf24@hotmail.com] Sent: Thursday, February 05, 2004 12:24 PM To: php-general@lists.php.net Subject: [PHP] multilingual website hi, i'm looking here for some help with the design of a multilingual website. Everything in that website needs to change from a language to an other. I've made search on the web to find some examples but i couldn't find very interesting things about how to manage that, using php. What's best ? - Use a database and make a querry for each text i have to put on my pages? - Use an xml file for each language and parse it to get my text? - Use a .php file with a variable for each item i have on my website? Or is there an other possibility? Thanks for your help. Julien juduf24@hotmail.com _________________________________________________________________ MSN Search, le moteur de recherche qui pense comme vous ! http://search.msn.fr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#176935) next »