Changing Session check in I18n class to use the same name as Configure::write().

Changed I10n class to attempt setting language based on DEFAULT_LANGUAGE if it is set and the auto detection of the HTTP_ACCEPT_LANGUAGE fails to find a match

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4171 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-12-23 23:35:59 +00:00
parent 673bd82ee8
commit de3098855b
2 changed files with 12 additions and 9 deletions

View file

@ -95,12 +95,11 @@ class I18n extends Object {
$_this =& I18n::getInstance();
$language = Configure::read('Config.language');
if($language === null && !empty($_SESSION['Config']['locale'])) {
$_this->locale = $_SESSION['Config']['locale'];
} else{
$_this->__l10n->get($language);
$_this->locale = $_this->__l10n->locale;
if($language === null && !empty($_SESSION['Config']['language'])) {
$language = $_SESSION['Config']['language'];
}
$_this->__l10n->get($language);
$_this->locale = $_this->__l10n->locale;
if(is_null($domain)) {
if (preg_match('/views{0,1}\\'.DS.'([^\/]*)/', $directory, $regs)) {

View file

@ -55,7 +55,7 @@ class L10n extends Object {
* @var string
* @access public
*/
var $lang = 'en-us';
var $lang = 'eng';
/**
* Enter description here...
*
@ -324,8 +324,9 @@ class L10n extends Object {
function get($language = null) {
if (!is_null($language)) {
return $this->__setLanguage($language);
} elseif ($this->__autoLanguage() === false){
return $this->__setLanguage($language);
}
return $this->__autoLanguage();
}
/**
* Enter description here...
@ -352,6 +353,7 @@ class L10n extends Object {
if($this->default) {
$this->languagePath = array(2 => $this->__l10nCatalog[$this->default]['localeFallback']);
}
Configure::write('Config.language', $this->lang);
Configure::write('charset', $this->charset);
}
/**
@ -374,10 +376,12 @@ class L10n extends Object {
if($this->default) {
$this->languagePath = array(2 => $this->__l10nCatalog[$this->default]['localeFallback']);
}
break;
Configure::write('Config.language', $this->lang);
Configure::write('charset', $this->charset);
return true;
}
}
Configure::write('charset', $this->charset);
return false;
}
}
?>