Is there a way, or a script, which can check which language the browser is set to... so that it autamically sets my $language varaible to the language which the browser is set to..

    Yes, you can.

    Browsers may have no language set, or several in order of preference.

    Here is some code I wrote for our application, which sets the language to the first language listed in the browser which is considered "valid" (i.e. I have translations in)

    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    		$langs = split(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
    		// Scan until we find an acceptable language
    		foreach ($langs as $lang) {
    			// Chop of anything after the first two chars (example: en-GB;q=0.5)
    			$lang = substr($lang,0,2);
    			$lang = strtolower($lang); // lowercase it.
    			if (IsValidLanguage($lang)) {
    				SetLanguage($lang);
    				return;
    			}
    		}
    	}
    

    Mark

      Thanks mate...

      however i get this error message..

      Fatal error: Call to undefined function: isvalidlanguage() in .../php/connection/lang_sel.inc on line 9

        Is there a IsValidLanguage function in php? or is this another language?

          Both IsValidLanguage() and SetLanguage() probably are user defined.

            Write a Reply...