diff --git a/common/functions.php b/common/functions.php index a1bd7234a..154d60455 100644 --- a/common/functions.php +++ b/common/functions.php @@ -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. *