Skip to content

Commit

Permalink
Dev Fixed a issue in CLocale (taken from official patch for upcoming …
Browse files Browse the repository at this point in the history
…Yii version)

Dev This is for general preparation to use the Yii i18n system
  • Loading branch information
c-schmitz committed Nov 2, 2012
1 parent 5a60395 commit 8248f40
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions framework/i18n/CLocale.php
Expand Up @@ -31,7 +31,6 @@
* @property array $pluralRules Plural forms expressions.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.i18n
* @since 1.0
*/
Expand Down Expand Up @@ -386,7 +385,11 @@ public function getTerritoryID($id)
{
$subTag = explode('_', $id);
// territory sub tags can be distigused from script sub tags by length
if (strlen($subTag[1])<4)
if (isset($subTag[2]) && strlen($subTag[2])<4)
{
$id = $subTag[2];
}
elseif (strlen($subTag[1])<4)
{
$id = $subTag[1];
}
Expand All @@ -413,19 +416,19 @@ public function getTerritoryID($id)
public function getLocaleDisplayName($id=null, $category='languages')
{
$id = $this->getCanonicalID($id);
if (isset($this->_data[$category][$id]))
if (($category == 'languages') && ($id=$this->getLanguageID($id)) && (isset($this->_data[$category][$id])))
{
return $this->_data[$category][$id];
}
else if (($category == 'languages') && ($id=$this->getLanguageID($id)) && (isset($this->_data[$category][$id])))
elseif (($category == 'scripts') && ($id=$this->getScriptID($id)) && (isset($this->_data[$category][$id])))
{
return $this->_data[$category][$id];
}
else if (($category == 'scripts') && ($id=$this->getScriptID($id)) && (isset($this->_data[$category][$id])))
elseif (($category == 'territories') && ($id=$this->getTerritoryID($id)) && (isset($this->_data[$category][$id])))
{
return $this->_data[$category][$id];
}
else if (($category == 'territories') && ($id=$this->getTerritoryID($id)) && (isset($this->_data[$category][$id])))
elseif (isset($this->_data[$category][$id]))
{
return $this->_data[$category][$id];
}
Expand Down

0 comments on commit 8248f40

Please sign in to comment.