From fc09ea0d47466e8d6280ca1c2abc8f7373643248 Mon Sep 17 00:00:00 2001 From: conory Date: Sun, 6 Mar 2016 16:35:01 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EC=97=86?= =?UTF-8?q?=EC=9D=B4=20lang()=ED=95=A8=EC=88=98=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=8B=9C=20=ED=98=84=EC=9E=AC=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EA=B3=A0=20=EC=9E=88=EB=8A=94=20=EC=96=B8=EC=96=B4=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B0=98=ED=99=98=20lang=20=EC=97=90=20set=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=A8=20(=EC=8B=A4=EC=A0=9C=EB=A1=9C=20set=EC=9D=B4=20?= =?UTF-8?q?=EB=90=98=EC=A7=80=EC=95=8A=EB=8A=94=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=EC=88=98=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/framework/lang.php | 22 ++++++++++++++++++++++ common/functions.php | 10 +++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/common/framework/lang.php b/common/framework/lang.php index fbddd57a9..d8c678cf0 100644 --- a/common/framework/lang.php +++ b/common/framework/lang.php @@ -50,6 +50,16 @@ class Lang $this->_loaded_plugins['_custom_'] = new \stdClass(); } + /** + * Return language type. + * + * @return string + */ + public function langType() + { + return $this->_language; + } + /** * Load translations from a plugin (module, addon). * @@ -187,6 +197,18 @@ class Lang return $this->__call($key, $args); } + /** + * Generic setter. + * + * @param string $key + * @param string $value + * @return void + */ + public function set($key, $value) + { + $this->__set($key, $value); + } + /** * Magic method for translations without arguments. * diff --git a/common/functions.php b/common/functions.php index 154d60455..388e8d78e 100644 --- a/common/functions.php +++ b/common/functions.php @@ -32,7 +32,7 @@ function config($key, $value = null) * @param string $value `$code`s value * @return mixed */ -function lang($code, $value = null) +function lang($code = null, $value = null) { if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang) { @@ -40,14 +40,18 @@ function lang($code, $value = null) $GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common'); } - if ($value === null) + if ($code !== null && $value === null) { return $GLOBALS['lang']->get($code); } - else + else if ($code !== null && $value !== null) { $GLOBALS['lang']->set($code, $value); } + else + { + return $GLOBALS['lang']->langType(); + } } /**