diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 13:03:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 13:03:30 +0800 |
commit | 2304c9722132da29ff98c01de18db7daef5e8aac (patch) | |
tree | 0a5f65712cc5bbd52ee4be4a63a8f8c37c3ee7e9 | |
parent | 3e2b0549a646dd98815fef896946ab6d5159d825 (diff) | |
download | lua-language-server-2304c9722132da29ff98c01de18db7daef5e8aac.zip |
翻译
-rw-r--r-- | server/locale/en-US/script.lni | 9 | ||||
-rw-r--r-- | server/locale/zh-CN/script.lni | 9 | ||||
-rw-r--r-- | server/src/language.lua | 4 | ||||
-rw-r--r-- | server/src/matcher/diagnostics.lua | 16 |
4 files changed, 28 insertions, 10 deletions
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni index e69de29b..da01d7d5 100644 --- a/server/locale/en-US/script.lni +++ b/server/locale/en-US/script.lni @@ -0,0 +1,9 @@ +<root> +DIAG_LINE_ONLY_SPACE = 'Line with spaces only.' +DIAG_LINE_POST_SPACE = 'Line with postspace.' +DIAG_UNUSED_LOCAL = 'Unused local `{}`.' +DIAG_UNDEFINED_GLOBAL = 'Undefined global `{}`.' +DIAG_UNUSED_LABEL = 'Unused label `{}`.' +DIAG_REDEFINED_LOCAL = 'Redefined local `{}`.' +DIAG_PREVIOUS_CALL = 'Parsed as function call for the previous line. It may be necessary to add a `;` before.' +DIAG_OVER_MAX_ARGS = 'The function takes only {:d} parameters, but you passed {:d}.' diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni new file mode 100644 index 00000000..6b322fb4 --- /dev/null +++ b/server/locale/zh-CN/script.lni @@ -0,0 +1,9 @@ +<root> +DIAG_LINE_ONLY_SPACE = '只有空格的空行。' +DIAG_LINE_POST_SPACE = '后置空格。' +DIAG_UNUSED_LOCAL = '未使用的局部变量 `{}`。' +DIAG_UNDEFINED_GLOBAL = '未定义的全局变量 `{}`。' +DIAG_UNUSED_LABEL = '未使用的标签 `{}`。' +DIAG_REDEFINED_LOCAL = '重定义局部变量 `{}`。' +DIAG_PREVIOUS_CALL = '解析为了上一行的函数调用。你可能需要在前面加一个 `;`。' +DIAG_OVER_MAX_ARGS = '函数只接收 {:d} 个参数,但你传了 {:d} 个。' diff --git a/server/src/language.lua b/server/src/language.lua index 3782562e..bf549132 100644 --- a/server/src/language.lua +++ b/server/src/language.lua @@ -61,12 +61,12 @@ local function loadLang(name, language) local str = self[key] local index = 0 local args = {...} - str:gsub('%{(.-)%}', function (pat) + return str:gsub('%{(.-)%}', function (pat) local id, fmt local pos = pat:find(':', 1, true) if pos then id = pat:sub(1, pos-1) - fmg = pat:sub(pos+1) + fmt = pat:sub(pos+1) else id = pat fmt = 's' diff --git a/server/src/matcher/diagnostics.lua b/server/src/matcher/diagnostics.lua index ba537694..9fc26ada 100644 --- a/server/src/matcher/diagnostics.lua +++ b/server/src/matcher/diagnostics.lua @@ -94,7 +94,7 @@ local function searchSpaces(vm, lines, callback) if isInString(vm, start, finish) then goto NEXT_LINE end - callback(start, finish, 'Line with spaces only') -- LOCALE + callback(start, finish, lang.script.DIAG_LINE_ONLY_SPACE) goto NEXT_LINE end @@ -105,7 +105,7 @@ local function searchSpaces(vm, lines, callback) if isInString(vm, start, finish) then goto NEXT_LINE end - callback(start, finish, 'Line with postspace') -- LOCALE + callback(start, finish, lang.script.DIAG_LINE_POST_SPACE) goto NEXT_LINE end ::NEXT_LINE:: @@ -198,7 +198,7 @@ return function (vm, lines, uri) start = start, finish = finish, level = 'Information', - message = ('Unused local `%s`'):format(key), -- LOCALE + message = lang.script('DIAG_UNUSED_LOCAL', key), } end) -- 读取未定义全局变量 @@ -207,7 +207,7 @@ return function (vm, lines, uri) start = start, finish = finish, level = 'Warning', - message = ('Undefined global `%s`'):format(key), -- LOCALE + message = lang.script('DIAG_UNDEFINED_GLOBAL', key), } end) -- 未使用的Label @@ -216,7 +216,7 @@ return function (vm, lines, uri) start = start, finish = finish, level = 'Information', - message = ('Unused label `%s`'):format(key), -- LOCALE + message = lang.script('DIAG_UNUSED_LABEL', key) } end) -- 只有空格与制表符的行,以及后置空格 @@ -234,7 +234,7 @@ return function (vm, lines, uri) start = start, finish = finish, level = 'Information', - message = ('Redefined local `%s`'):format(key), -- LOCALE + message = lang.script('DIAG_REDEFINED_LOCAL', key), related = related, } end) @@ -244,7 +244,7 @@ return function (vm, lines, uri) start = start, finish = finish, level = 'Warning', - message = 'Parsed as function call for the previous line. It may be necessary to add a `;` before.', -- LOCALE + message = lang.script.DIAG_PREVIOUS_CALL, } end) -- 调用函数时的参数数量是否超过函数的接收数量 @@ -253,7 +253,7 @@ return function (vm, lines, uri) start = start, finish = finish, level = 'Warning', - message = ('The function takes only %d parameters, but you passed %d.'):format(max, passed), -- LOCALE + message = lang.script('DIAG_OVER_MAX_ARGS', max, passed), } end) return datas |