Re: Passing Objects between scripts and guarateeing that a language has been choosen.

From: Date: Thu, 04 Sep 2003 17:09:05 +0000
Subject: Re: Passing Objects between scripts and guarateeing that a language has been choosen.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161676@lists.php.net to get a copy of this message
* Thus wrote Webmaster (webmaster@dentona.de): > Hi, > > I am just starting to understand how the session handling routines work in > php. > I can pass objects to other scripts. So I can put the language into the > object that the visitor chose at the very first page. > But what if a visitor bookmarked my homepage and comes back after a few > weeks. > How can I guarantee that a language is always choosen? I mean how is this > done professionally? > What do I have to write at the beginning of every page? > > I hope it is clear what I am asking. You should check the 'Accept-Language' header [1] that the client usually sends: $languages = $_SERVER['HTTP_ACCEPT_LANGUAGE']; you'll have a string like: en;q=1.0, de;q=0.9, da;q=0.1 meaning that the user prefers english but if you don't have an english translation, give me german, and last but not least, I can read danish a bit. If the client doesn't have the header then direct them to a page that has them select their language choice. Then handle their choice with session data [2]. I would have the session data override the Accept-language header so that the user can manually override his browser settings. You can see how google [3] does things by modifying your language settings in your browser and your personal google settings. IMO they have a very nice language detection system. [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 [2] http://php.net/session [3] http://www.google.com/ Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#161676) next »