Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TMultiView and TView class file.
4
 *
5
 * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Revision: 1.66 $  $Date: ${DATE} ${TIME} $
10
 * @package System.I18N
11
 */
12
 
13
/**
14
 * Import the HTTPNeogtiator
15
 */
16
Prado::using('System.I18N.core.HTTPNegotiator');
17
 
18
/**
19
 * TGlobalizationAutoDetect class will automatically try to resolve the default
20
 * culture using the user browser language settings.
21
 *
22
 * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
23
 * @version $Revision: 1.66 $  $Date: ${DATE} ${TIME} $
24
 * @package System.I18N
25
 */
26
class TGlobalizationAutoDetect extends TGlobalization
27
{
28
	private $_detectedLanguage;
29
 
30
	public function init($xml)
31
	{
32
		parent::init($xml);
33
 
34
		//set the culture according to browser language settings
35
		$http = new HTTPNegotiator();
36
		$languages = $http->getLanguages();
37
		if(count($languages) > 0)
38
		{
39
			$this->_detectedLanguage=$languages[0];
40
			$this->setCulture($languages[0]);
41
		}
42
	}
43
 
44
	public function getDetectedLanguage()
45
	{
46
		return $this->_detectedLanguage;
47
	}
48
}
49