lang() 함수 추가

This commit is contained in:
conory 2016-03-05 23:05:41 +09:00
parent 7b75a103b2
commit bd6f7d6542

View file

@ -25,6 +25,31 @@ function config($key, $value = null)
}
}
/**
* Get or set lang variable.
*
* @param string $code Lang variable name
* @param string $value `$code`s value
* @return mixed
*/
function lang($code, $value = null)
{
if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang)
{
$GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(Context::getLangType() ?: config('locale.default_lang') ?: 'ko');
$GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
}
if ($value === null)
{
return $GLOBALS['lang']->get($code);
}
else
{
$GLOBALS['lang']->set($code, $value);
}
}
/**
* Get the first value of an array.
*