From e7bd33ff213afb6f4d6d666d215107651ab27a1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= <sumneko@hotmail.com>
Date: Thu, 28 Mar 2019 15:45:31 +0800
Subject: =?UTF-8?q?=E7=BF=BB=E8=AF=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 server/locale/zh-CN/script.lni                 | 11 +++++++++++
 server/src/method/textDocument/codeAction.lua  | 20 +++++++++++---------
 server/src/method/workspace/executeCommand.lua |  5 +++--
 3 files changed, 25 insertions(+), 11 deletions(-)

(limited to 'server')

diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni
index 487b3cce..0b8bec1b 100644
--- a/server/locale/zh-CN/script.lni
+++ b/server/locale/zh-CN/script.lni
@@ -41,5 +41,16 @@ PARSER_REDEFINE_LABEL   = '标签`{label}`重复定义。'
 
 SYMBOL_ANONYMOUS        = '<匿名函数>'
 
+ACTION_DISABLE_DIAG     = '禁用诊断({})'
+ACTION_MARK_GLOBAL      = '标记 `{}` 为已定义的全局变量'
+ACTION_REMOVE_SPACE     = '清除所有后置空格'
+ACTION_ADD_SEMICOLON    = '添加 `;`'
+ACTION_ADD_BRACKETS     = '添加括号'
+
+COMMAND_DISABLE_DIAG    = '禁用诊断'
+COMMAND_MARK_GLOBAL     = '标记全局变量'
+COMMAND_REMOVE_SPACE    = '清除所有后置空格'
+COMMAND_ADD_BRACKETS    = '添加括号'
+
 DEBUG_MEMORY_LEAK       = '{} 很抱歉发生了严重的内存泄漏,语言服务即将重启。'
 DEBUG_RESTART_NOW       = '立即重启'
diff --git a/server/src/method/textDocument/codeAction.lua b/server/src/method/textDocument/codeAction.lua
index 80faee51..e2ff2e50 100644
--- a/server/src/method/textDocument/codeAction.lua
+++ b/server/src/method/textDocument/codeAction.lua
@@ -1,9 +1,11 @@
+local lang = require 'language'
+
 local function disableDiagnostic(lsp, uri, data, callback)
     callback {
-        title = ('禁用诊断(%s)'):format(data.code),
+        title = lang.script('ACTION_DISABLE_DIAG', data.code),
         kind = 'quickfix',
         command = {
-            title = '禁用诊断',
+            title = lang.script.COMMAND_DISABLE_DIAG,
             command = 'config',
             arguments = {
                 {
@@ -28,10 +30,10 @@ local function solveUndefinedGlobal(lsp, uri, data, callback)
         return
     end
     callback {
-        title = ('标记 `%s` 为已定义的全局变量'):format(name),
+        title = lang.script('ACTION_MARK_GLOBAL', name),
         kind = 'quickfix',
         command = {
-            title = '标记全局变量',
+            title = lang.script.COMMAND_MARK_GLOBAL,
             command = 'config',
             arguments = {
                 {
@@ -46,10 +48,10 @@ end
 
 local function solveTrailingSpace(lsp, uri, data, callback)
     callback {
-        title = '清除所有后置空格',
+        title = lang.script.ACTION_REMOVE_SPACE,
         kind = 'quickfix',
         command = {
-            title = '清除所有后置空格',
+            title = lang.script.COMMAND_REMOVE_SPACE,
             command = 'removeSpace',
             arguments = {
                 {
@@ -62,7 +64,7 @@ end
 
 local function solveNewlineCall(lsp, uri, data, callback)
     callback {
-        title = '添加 `;`',
+        title = lang.script.ACTION_ADD_SEMICOLON,
         kind = 'quickfix',
         edit = {
             changes = {
@@ -82,10 +84,10 @@ end
 
 local function solveAmbiguity1(lsp, uri, data, callback)
     callback {
-        title = '添加括号',
+        title = lang.script.ACTION_ADD_BRACKETS,
         kind = 'quickfix',
         command = {
-            title = '添加括号',
+            title = lang.script.COMMAND_ADD_BRACKETS,
             command = 'solve',
             arguments = {
                 {
diff --git a/server/src/method/workspace/executeCommand.lua b/server/src/method/workspace/executeCommand.lua
index 173eaa22..0d579848 100644
--- a/server/src/method/workspace/executeCommand.lua
+++ b/server/src/method/workspace/executeCommand.lua
@@ -2,6 +2,7 @@ local fs = require 'bee.filesystem'
 local json = require 'json'
 local config = require 'config'
 local rpc = require 'rpc'
+local lang = require 'language'
 
 local command = {}
 
@@ -109,7 +110,7 @@ function command.removeSpace(lsp, data)
     end
 
     rpc:request('workspace/applyEdit', {
-        label = '清除所有后置空格',
+        label = lang.script.COMMAND_REMOVE_SPACE,
         edit = {
             changes = {
                 [uri] = textEdit,
@@ -148,7 +149,7 @@ function command.solve(lsp, data)
     end
 
     rpc:request('workspace/applyEdit', {
-        label = '添加括号',
+        label = lang.script.COMMAND_ADD_BRACKETS,
         edit = {
             changes = {
                 [uri] = {
-- 
cgit v1.2.3