mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 06:48:41 +00:00
Merge pull request #47 from Orange-Management/dynamic-language-loading
Dynamic language loading
This commit is contained in:
commit
a3be580f2a
|
|
@ -17,6 +17,7 @@ namespace phpOMS\Localization;
|
||||||
|
|
||||||
use phpOMS\Log\FileLogger;
|
use phpOMS\Log\FileLogger;
|
||||||
use phpOMS\Log\LoggerInterface;
|
use phpOMS\Log\LoggerInterface;
|
||||||
|
use phpOMS\Module\ModuleAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Localization class.
|
* Localization class.
|
||||||
|
|
@ -134,6 +135,7 @@ class L11nManager
|
||||||
*
|
*
|
||||||
* @param string $code Country code
|
* @param string $code Country code
|
||||||
* @param string $module Module name
|
* @param string $module Module name
|
||||||
|
* @param string $theme Theme
|
||||||
* @param string $translation Text
|
* @param string $translation Text
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
|
@ -141,15 +143,16 @@ class L11nManager
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @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])) {
|
if (!isset($this->language[$code][$module][$translation])) {
|
||||||
|
/** @var ModuleAbstract $class */
|
||||||
$class = '\Modules\\' . $module . '\\Controller';
|
$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])) {
|
if (!isset($this->language[$code][$module][$translation])) {
|
||||||
$this->logger->warning(FileLogger::MSG_FULL, [
|
$this->logger->warning(FileLogger::MSG_FULL, [
|
||||||
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.'
|
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return 'ERROR';
|
return 'ERROR';
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,7 @@ class Localization
|
||||||
* Get translation.
|
* Get translation.
|
||||||
*
|
*
|
||||||
* @param string $module Module name
|
* @param string $module Module name
|
||||||
|
* @param string $theme Theme name
|
||||||
* @param string $translation Text
|
* @param string $translation Text
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
|
@ -303,8 +304,8 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user