Location: PHPKode > scripts > Language Detect > language-detect/LanguageDetect.sample.php
<?php
/**
 * 
 * Language Detect Sample
 * Author: Daniel Costa - http://danielcosta.info
 * 
 * Feel free to rate my class at phpclasses.org
 * 
 */

require 'LanguageDetect.php';

$language = ''; // presented here just for explanation
var_dump($language); // $language is blank;

/**
 * Put your site languages accepted here
 */
$acceptedLanguages = array('en', 'pt');

$languages = new LanguageDetect();
$checkLanguages = $languages->getLanguagesList($acceptedLanguages,$foundLanguages = array());
if ($checkLanguages) {
	$language = key($foundLanguages);
} else {
	$language = $acceptedLanguages[0];
}

var_dump($language); // preferred language was set;

?>
Return current item: Language Detect