Implementing theme support

This commit is contained in:
Dennis Eichhorn 2016-07-05 19:00:48 +02:00
parent e7a016cb07
commit 1ea12353c4
2 changed files with 9 additions and 5 deletions

View File

@ -17,6 +17,7 @@ namespace phpOMS\Localization;
use phpOMS\Log\FileLogger;
use phpOMS\Log\LoggerInterface;
use phpOMS\Module\ModuleAbstract;
/**
* Localization class.
@ -134,6 +135,7 @@ class L11nManager
*
* @param string $code Country code
* @param string $module Module name
* @param string $theme Theme
* @param string $translation Text
*
* @return array
@ -141,15 +143,16 @@ class L11nManager
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getText(string $code, string $module, string $translation)
public function getText(string $code, string $module, string $theme, string $translation)
{
if (!isset($this->language[$code][$module][$translation])) {
/** @var ModuleAbstract $class */
$class = '\Modules\\' . $module . '\\Controller';
$this->loadLanguage($code, $module, $class::getLocalization($code, $module));
$this->loadLanguage($code, $module, $class::getLocalization($code, $theme));
if (!isset($this->language[$code][$module][$translation])) {
$this->logger->warning(FileLogger::MSG_FULL, [
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.'
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.',
]);
return 'ERROR';

View File

@ -296,6 +296,7 @@ class Localization
* Get translation.
*
* @param string $module Module name
* @param string $theme Theme name
* @param string $translation Text
*
* @return array
@ -303,8 +304,8 @@ class Localization
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getText(string $module, string $translation)
public function getText(string $module, string $theme, string $translation)
{
return $this->l11nManager->getText($this->language, $module, $translation);
return $this->l11nManager->getText($this->language, $module, $theme, $translation);
}
}