From de3098855b58693288c16698c8811ecfa6e55c3f Mon Sep 17 00:00:00 2001 From: phpnut Date: Sat, 23 Dec 2006 23:35:59 +0000 Subject: [PATCH] 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 --- cake/libs/i18n.php | 9 ++++----- cake/libs/l10n.php | 12 ++++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index e85d48152..6031a1d41 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -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)) { diff --git a/cake/libs/l10n.php b/cake/libs/l10n.php index d97e8255a..1370c684d 100644 --- a/cake/libs/l10n.php +++ b/cake/libs/l10n.php @@ -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; } } ?> \ No newline at end of file