From 8ca0ca4a4759e96ae9928f861f5e3efb3d63c5a0 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Fri, 5 May 2017 11:47:22 +0900 Subject: [PATCH] Fix Context::loadLang() compatibility when lang.xml is specified --- classes/context/Context.class.php | 3 ++- tests/unit/framework/LangTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 116e100f9..b0f7b3e9e 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -854,8 +854,9 @@ class Context */ public static function loadLang($path) { - if (preg_match('@/(modules|addons|plugins)/([a-z0-9_]+)/lang/?$@', str_replace('\\', '/', $path), $matches)) + if (preg_match('@/(modules|addons|plugins|widgets)/([a-zA-Z0-9_-]+)/lang/?(?:lang\.xml)?$@', str_replace('\\', '/', $path), $matches)) { + $path = \RX_BASEDIR . $matches[1] . '/' . $matches[2] . '/lang'; $plugin_name = $matches[2]; } else diff --git a/tests/unit/framework/LangTest.php b/tests/unit/framework/LangTest.php index 4533b063c..0fc64b12f 100644 --- a/tests/unit/framework/LangTest.php +++ b/tests/unit/framework/LangTest.php @@ -66,4 +66,12 @@ class LangTest extends \Codeception\TestCase\Test $en->foobartestlang = 'Hello, %s!'; $this->assertEquals('Hello, Travis!', $en->get('foobartestlang', 'Travis')); } + + public function testLangCompat() + { + Context::loadLang('./modules/member/lang'); + $this->assertEquals('서명', Context::getLang('signature')); + Context::loadLang('./modules/document/lang/lang.xml'); + $this->assertEquals('문서 목록', Context::getLang('document_list')); + } }