Mailinglisten-Archive |
On Fri, 21 Jan 2000 14:50:55 +0100, Stefan Schwardt <Schwardt_(at)_Euro-Auto-Boerse.net> wrote: >Hat > jemand Erfahrungen mit soetwas oder Tipps für die Umsetzung? > Verschiedene Sprachversionen in verschiedenen Tabellen? Macht aber > das Skript unlesbar. Includes Vielleicht hilft dir das folgende. Ich hoffe, es stört dich nicht, dass es in germish ;)) geschrieben ist. To create a multilingual website use this method: ------------------------------------------------- Every language get it's own file "[language].inc.php3" which resides in the /inc directory. The images which are needed for the different languages resides in their own directory. The name of this directory depends on the first to letters of $HTTP_ACCEPT_LANGUAGE, for example: /img/de german /img/en english At the beginning of each page is the following code: // Check language if (strlen($strLang) == 0) { $strLang = GetEnv("HTTP_ACCEPT_LANGUAGE"); $strLang = strtolower(substr($strLang,0,2)); // first two letters } To get the different language files use this code: // Switch languages switch ($strLang) { // language selection case "de": include ("inc/german.inc.php3"); break; case "en": include ("inc/english.inc.php3"); break; default: include ("inc/english.inc.php3"); $strLang = "en"; } To get the different images use this: <img src="img/<? echo $strLang ?>/graphics.gif"> Inside the language files is also a switch construct which is used to get the strings for the entired file. switch ($strFileName) { case "index.php3"; $langTitle= "Die Einsatz-Möglichkeiten"; $strUserEdit= "Anmelden"; break; case "user_edit.php3": $langTitle = "Deine eigene Liste"; // Welcome text $langWelcome = "Hallo und herzlich willkommen!"; ... } This method allows the same variable name (see $langTitle) in more then one file. To get the filename use this code on top of each page (before including the language files): $saScript = explode("/",$SCRIPT_NAME); // get array $intSize = count($saScript); // Size $strFileName = $saScript[$intSize-1]; // gives the filename -- end of description ciao amalesh -- Anwendungsentwicklung mit C++ JAVA VB PHP ASP SQL POET SGML XML http://www.living-source.com ~ ak_(at)_living-source.com ~ icq963380 Hamburg : Tel. 040-39834630 Fax. 040-39834639 Mob. 0170-4809618 Freiburg: Tel. 0761-152580 Fax. 0761-1525850
php::bar PHP Wiki - Listenarchive