11local fs = require ' bee.filesystem'
22
3- local json = require ' json-beautify'
3+ local currentPath = debug.getinfo (1 , ' S' ).source :sub (2 )
4+ local rootPath = currentPath :gsub (' [^/\\ ]-$' , ' ' )
5+ package.path = package.path
6+ .. ' ;' .. rootPath .. ' ?.lua'
7+ .. ' ;' .. rootPath .. ' server/script/?.lua'
8+
9+ local json = require ' json-beautify'
410local configuration = require ' package.configuration'
5- local fsu = require ' fs-utility'
11+ local fsu = require ' fs-utility'
12+ local lloader = require ' locale-loader'
613
714local function addSplited (t , key , value )
815 t [key ] = value
@@ -43,11 +50,17 @@ local encodeOption = {
4350 newline = ' \r\n ' ,
4451 indent = ' ' ,
4552}
46- for _ , lang in ipairs {' ' , ' -zh-cn' } do
47- local nls = require (' package.nls' .. lang )
53+
54+ for dirPath in fs .pairs (fs .path ' server/locale' ) do
55+ local lang = dirPath :filename ():string ()
56+ local nlsPath = dirPath / ' setting.lua'
57+ local text = fsu .loadFile (nlsPath )
58+ if not text then
59+ goto CONTINUE
60+ end
61+ local nls = lloader (text , nlsPath :string ())
4862
4963 local setting = {
50- [' $schema' ] = ' ' ,
5164 title = ' setting' ,
5265 description = ' Setting of sumneko.lua' ,
5366 type = ' object' ,
@@ -56,5 +69,12 @@ for _, lang in ipairs {'', '-zh-cn'} do
5669 end ),
5770 }
5871
72+ if lang == ' en-us' then
73+ lang = ' '
74+ else
75+ lang = ' -' .. lang
76+ end
77+
5978 fsu .saveFile (fs .path ' setting/schema' .. lang .. ' .json' , json .beautify (setting , encodeOption ))
79+ :: CONTINUE::
6080end
0 commit comments