diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-07 14:15:45 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-07 14:15:45 +0800 |
commit | 1050087f1e2c28a55ed488f092524de14126abf0 (patch) | |
tree | 448c60972ed939169c52399a6a3d0a153de199b7 /server/src/matcher | |
parent | 4e4bc7c8908afb100233045a1b15368ba8764c59 (diff) | |
download | lua-language-server-1050087f1e2c28a55ed488f092524de14126abf0.zip |
先合并英文翻译,再合并当前语言的翻译
Diffstat (limited to 'server/src/matcher')
-rw-r--r-- | server/src/matcher/find_lib.lua | 23 |
1 files changed, 16 insertions, 7 deletions
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 |