From 1050087f1e2c28a55ed488f092524de14126abf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 7 Dec 2018 14:15:45 +0800 Subject: =?UTF-8?q?=E5=85=88=E5=90=88=E5=B9=B6=E8=8B=B1=E6=96=87=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=EF=BC=8C=E5=86=8D=E5=90=88=E5=B9=B6=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E7=9A=84=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/find_lib.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'server/src/matcher') diff --git a/server/src/matcher/find_lib.lua b/server/src/matcher/find_lib.lua index 213d6111..e2c124ab 100644 --- a/server/src/matcher/find_lib.lua +++ b/server/src/matcher/find_lib.lua @@ -58,6 +58,17 @@ local function mergeLibs(target, libs) end end +local function loadLocale(language, relative) + local localePath = ROOT / 'locale' / language / relative + local localeBuf = io.load(localePath) + if localeBuf then + local locale = table.container() + xpcall(lni.classics, log.error, localeBuf, localePath:string(), {locale}) + return locale + end + return nil +end + local Libs local function getLibs() if Libs then @@ -78,21 +89,19 @@ local function getLibs() }) for path in io.scan(ROOT / 'libs') do local libs - local locale local buf = io.load(path) if buf then libs = table.container() xpcall(lni.classics, log.error, buf, path:string(), {libs}) end local relative = fs.relative(path, ROOT) - local localePath = ROOT / 'locale' / language / relative - local localeBuf = io.load(localePath) - if localeBuf then - locale = table.container() - xpcall(lni.classics, log.error, localeBuf, localePath:string(), {locale}) - end + local locale = loadLocale('enUS', relative) mergeLocale(libs, locale) + if language ~= 'enUS' then + locale = loadLocale(language, relative) + mergeLocale(libs, locale) + end mergeLibs(Libs, libs) end -- cgit v1.2.3