mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
Fix unit tests, and auto-load default lang if not loaded
This commit is contained in:
parent
c67dbbc659
commit
1a3c500c76
2 changed files with 19 additions and 24 deletions
|
|
@ -859,7 +859,7 @@ class Context
|
|||
* Load language file according to language type
|
||||
*
|
||||
* @param string $path Path of the language file
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
public static function loadLang($path)
|
||||
{
|
||||
|
|
@ -872,15 +872,13 @@ class Context
|
|||
$plugin_name = null;
|
||||
}
|
||||
|
||||
if ($GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
{
|
||||
return $GLOBALS['lang']->loadDirectory($path, $plugin_name);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
$GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(self::$_instance->lang_type ?: config('locale.default_lang') ?: 'ko');
|
||||
$GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
|
||||
}
|
||||
|
||||
return $GLOBALS['lang']->loadDirectory($path, $plugin_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -923,14 +921,13 @@ class Context
|
|||
*/
|
||||
public static function getLang($code)
|
||||
{
|
||||
if ($GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
{
|
||||
return $GLOBALS['lang']->get($code);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $code;
|
||||
$GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(self::$_instance->lang_type ?: config('locale.default_lang') ?: 'ko');
|
||||
$GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
|
||||
}
|
||||
|
||||
return $GLOBALS['lang']->get($code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -938,19 +935,17 @@ class Context
|
|||
*
|
||||
* @param string $code Language variable name
|
||||
* @param string $val `$code`s value
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
public static function setLang($code, $val)
|
||||
{
|
||||
if ($GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||
{
|
||||
$GLOBALS['lang']->set($code, $val);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
$GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(self::$_instance->lang_type ?: config('locale.default_lang') ?: 'ko');
|
||||
$GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
|
||||
}
|
||||
|
||||
$GLOBALS['lang']->set($code, $val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue