Removing l11nManager from l11n

This commit is contained in:
Dennis Eichhorn 2016-07-27 13:30:08 +02:00
parent dd80569a88
commit 1a017e6719
2 changed files with 29 additions and 27 deletions

View File

@ -31,13 +31,6 @@ use phpOMS\Datatypes\Exception\InvalidEnumValue;
class Localization
{
/**
* Localization manager.
*
* @var L11nManager
* @since 1.0.0
*/
public $l11nManager = null;
/**
* Country ID.
*
@ -136,9 +129,8 @@ class Localization
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(L11nManager $l11nManager = null)
public function __construct()
{
$this->l11nManager = $l11nManager;
}
/**
@ -323,22 +315,5 @@ class Localization
public function setThousands(string $thousands)
{
$this->thousands = $thousands;
}
/**
* Get translation.
*
* @param string $module Module name
* @param string $theme Theme name
* @param string $translation Text
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getText(string $module, string $theme, string $translation)
{
return $this->l11nManager->getText($this->language, $module, $theme, $translation);
}
}
}

View File

@ -338,6 +338,33 @@ class View implements \Serializable
$this->data[$id] = $data;
}
/**
* Get translation.
*
* @param string $module Module name
* @param string $theme Theme name
* @param string $translation Text
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getText(string $translation, string $module = null, string $theme = null)
{
if(!isset($module)) {
$match = '/Theme/';
$module = ($start = strripos($this->template, $match)) !== false ? substr($this->template, ($offset = $start+strlen($match)), strpos($this->template, '/', $offset)) : throw new \Exception('Unknown Theme');
}
if(!isset($theme)) {
$match = '/Modules/';
$module = ($start = strripos($this->template, $match)) !== false ? substr($this->template, ($offset = $start+strlen($match)), strpos($this->template, '/', $offset)) : throw new \Exception('Unknown Module');
}
return $this->app->l11nManager->getText($this->l11n->getLanguage(), $module, $theme, $translation);
}
/**
* Arrayify view and it's subviews.
*