Skip to content

Commit

Permalink
Dev Allow Clocale to be handled by a custom class - this patch will b…
Browse files Browse the repository at this point in the history
…e part of the upcoming Yii verion 1.1.17
  • Loading branch information
c-schmitz committed Jun 18, 2015
1 parent f9b0d65 commit 185719d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions framework/base/CApplication.php
Expand Up @@ -42,7 +42,7 @@
* CApplication will undergo the following lifecycles when processing a user request:
* <ol>
* <li>load application configuration;</li>
* <li>set up class autoloader and error handling;</li>
* <li>set up error handling;</li>
* <li>load static application components;</li>
* <li>{@link onBeginRequest}: preprocess the user request;</li>
* <li>{@link processRequest}: process the user request;</li>
Expand Down Expand Up @@ -97,6 +97,10 @@ abstract class CApplication extends CModule
* the language that the messages and view files are in. Defaults to 'en_us' (US English).
*/
public $sourceLanguage='en_us';
/**
* @var string the class used to get locale data. Defaults to 'CLocale'.
*/
public $localeClass='CLocale';

private $_id;
private $_basePath;
Expand Down Expand Up @@ -395,11 +399,12 @@ public function findLocalizedFile($srcFile,$srcLanguage=null,$language=null)
/**
* Returns the locale instance.
* @param string $localeID the locale ID (e.g. en_US). If null, the {@link getLanguage application language ID} will be used.
* @return CLocale the locale instance
* @return an instance of CLocale
*/
public function getLocale($localeID=null)
{
return CLocale::getInstance($localeID===null?$this->getLanguage():$localeID);
$class=$this->localeClass;
return $class::getInstance($localeID===null?$this->getLanguage():$localeID);
}

/**
Expand All @@ -409,7 +414,8 @@ public function getLocale($localeID=null)
*/
public function getLocaleDataPath()
{
return CLocale::$dataPath===null ? Yii::getPathOfAlias('system.i18n.data') : CLocale::$dataPath;
$class=$this->localeClass;
return $class::$dataPath===null ? Yii::getPathOfAlias('system.i18n.data') : $class::$dataPath;
}

/**
Expand All @@ -419,7 +425,8 @@ public function getLocaleDataPath()
*/
public function setLocaleDataPath($value)
{
CLocale::$dataPath=$value;
$class=$this->localeClass;
$class::$dataPath=$value;
}

/**
Expand Down Expand Up @@ -937,7 +944,7 @@ public function displayException($exception)
}

/**
* Initializes the class autoloader and error handlers.
* Initializes the error handlers.
*/
protected function initSystemHandlers()
{
Expand Down

0 comments on commit 185719d

Please sign in to comment.