Re: Newbie asks about multi-lingual website strategies

From: Date: Wed, 28 Nov 2007 14:41:36 +0000
Subject: Re: Newbie asks about multi-lingual website strategies
Groups: php.general 
Request: Send a blank email to php-general+get-265127@lists.php.net to get a copy of this message
Wow! I love this group, ask and you shall receive. Thanks everyone for the comments and suggestions. The following snippet from Andrés Robinet would actually suit my current project.. define('DEFAULT_LANG_ID', 'en'); function getLanguageId() { // Allow for language id override in $_GET, $_POST and $_COOKIE $req_lang_id = $_REQUEST['lang_id']; // Retrieve the one stored in the session if any $sess_lang_id = $_SESSION['lang_id']; // $lang_id will contain the lang id retrieved from request (overrides session), // or from session or a default one $lang_id = isset($req_lang_id) ? $req_lang_id : (isset($sess_lang_id) ? $sess_lang_id : DEFAULT_LANG_ID); // Save it for next time $_SESSION['lang_id'] = $lang_id; return $lang_id; } but the idea of getting a preferred language from the browser is also a great strategy ( I didn’t know you could do that, I’m such a noob) so I think that I will investgate that further. The problem with IP address is that usually it is not tied to one particular user so I will scrap that idea. Am I correct that if two people are logged on using two different languages that the session var will keep track of the different users (by IP I assume) and the server won’t mess up? Anyway thanks everyone for all the great help, I’m on a nearly vertical learning curve here and it’s great to have this community to draw on. I’m pretty much working in a vacuum otherwise. Jeff

« previous php.general (#265127) next »