mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 15:18:41 +00:00
Merge branch 'dynamic-language-loading' of https://github.com/Orange-Management/phpOMS into develop
This commit is contained in:
commit
0a20653628
|
|
@ -118,7 +118,7 @@ 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 getLanguage(string $language, string $module = null) : array
|
public function getModuleLanguage(string $language, string $module = null) : array
|
||||||
{
|
{
|
||||||
if (!isset($module) && isset($this->language[$language])) {
|
if (!isset($module) && isset($this->language[$language])) {
|
||||||
return $this->language[$language];
|
return $this->language[$language];
|
||||||
|
|
@ -144,11 +144,16 @@ class L11nManager
|
||||||
public function getText(string $code, string $module, string $translation)
|
public function getText(string $code, string $module, string $translation)
|
||||||
{
|
{
|
||||||
if (!isset($this->language[$code][$module][$translation])) {
|
if (!isset($this->language[$code][$module][$translation])) {
|
||||||
$this->logger->warning(FileLogger::MSG_FULL, [
|
$class = '\Modules\\' . $module . '\\Controller';
|
||||||
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.'
|
$this->loadLanguage($code, $module, $class::getLocalization($code, $module));
|
||||||
]);
|
|
||||||
|
|
||||||
return 'ERROR';
|
if (!isset($this->language[$code][$module][$translation])) {
|
||||||
|
$this->logger->warning(FileLogger::MSG_FULL, [
|
||||||
|
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.'
|
||||||
|
]);
|
||||||
|
|
||||||
|
return 'ERROR';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->language[$code][$module][$translation];
|
return $this->language[$code][$module][$translation];
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ abstract class ModuleAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function getLocalization(string $language, string $destination) : array
|
public static function getLocalization(string $language, string $destination) : array
|
||||||
{
|
{
|
||||||
$lang = [];
|
$lang = [];
|
||||||
if (($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) !== false) {
|
if (($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) !== false) {
|
||||||
|
|
|
||||||
|
|
@ -648,8 +648,6 @@ class ModuleManager
|
||||||
{
|
{
|
||||||
$this->running[$module] = ModuleFactory::getInstance($module, $this->app);
|
$this->running[$module] = ModuleFactory::getInstance($module, $this->app);
|
||||||
$this->app->dispatcher->set($this->running[$module], '\Modules\\' . $module . '\\Controller');
|
$this->app->dispatcher->set($this->running[$module], '\Modules\\' . $module . '\\Controller');
|
||||||
// todo: replace 'en' with request language.
|
|
||||||
$this->loadLanguage($module, 'en');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -670,23 +668,4 @@ class ModuleManager
|
||||||
|
|
||||||
return $this->running[$module];
|
return $this->running[$module];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load module language.
|
|
||||||
*
|
|
||||||
* @param string $module Module name
|
|
||||||
* @param string $language Language
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn
|
|
||||||
*/
|
|
||||||
public function loadLanguage(string $module, string $language)
|
|
||||||
{
|
|
||||||
$file = $this->running[$module]->getLocalization($language, $this->app->appName);
|
|
||||||
if (!empty($file)) {
|
|
||||||
$this->app->l11nManager->loadLanguage($language, $module, $file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user