mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Be more permissive about null values passed to lang() and Context::getLang()
This commit is contained in:
parent
14449dff9d
commit
6e2bab02cc
2 changed files with 4 additions and 4 deletions
|
|
@ -856,7 +856,7 @@ class Context
|
||||||
$GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
|
$GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $GLOBALS['lang']->get($code);
|
return $code ? $GLOBALS['lang']->get((string)$code) : (string)$code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ function config(string $key, $value = null)
|
||||||
* @param string $value `$code`s value
|
* @param string $value `$code`s value
|
||||||
* @return string|null|\ArrayObject
|
* @return string|null|\ArrayObject
|
||||||
*/
|
*/
|
||||||
function lang(string $code, $value = null)
|
function lang(?string $code, $value = null)
|
||||||
{
|
{
|
||||||
if (!isset($GLOBALS['lang']) || !$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
if (!isset($GLOBALS['lang']) || !$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
|
||||||
{
|
{
|
||||||
|
|
@ -42,9 +42,9 @@ function lang(string $code, $value = null)
|
||||||
|
|
||||||
if ($value === null)
|
if ($value === null)
|
||||||
{
|
{
|
||||||
return $GLOBALS['lang']->get($code);
|
return $GLOBALS['lang']->get($code ?? '');
|
||||||
}
|
}
|
||||||
else
|
elseif ($code !== null)
|
||||||
{
|
{
|
||||||
$GLOBALS['lang']->set($code, $value);
|
$GLOBALS['lang']->set($code, $value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue