-
Notifications
You must be signed in to change notification settings - Fork 3
/
langDialog.lua
63 lines (54 loc) · 1.88 KB
/
langDialog.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local script_name = debug.getinfo(1, "S").source:sub(2)
local script_path = script_name:match("(.*[/\\])")
execute = function(plugin)
local tempLang = {
["en-us"] = assert(loadfile(script_path .. "lang/en-us.lua"))(),
["zh-cn"] = assert(loadfile(script_path .. "lang/zh-cn.lua"))(),
["ja-jp"] = assert(loadfile(script_path .. "lang/ja-jp.lua"))()
}
local currentLang = plugin.preferences.lang
local langDic = {}
local langNameList = {}
local index = 1
for key, value in pairs(tempLang) do
langNameList[index] = value.Name
langDic[value.Name] = key
index = index + 1
end
local function renewDialog()
LangDialog:modify { title = tempLang[currentLang].LangDialog.Title }
LangDialog:modify { id = "ok", text = tempLang[currentLang].LangDialog.ok }
LangDialog:modify {
id = "lang",
label = tempLang[currentLang].LangDialog.langCombo.label,
}
LangDialog:modify { id = "warn", text = tempLang[currentLang].LangDialog.warn }
end
LangDialog = Dialog {
title = tempLang[currentLang].LangDialog.Title,
notitlebar = false,
onclose = nil
}
:combobox {
id = "lang",
option = tempLang[currentLang].Name,
options = langNameList,
onchange = function()
currentLang = langDic[LangDialog.data.lang]
renewDialog()
end
}
:button {
id = "ok",
text = tempLang[currentLang].LangDialog.ok,
focus = true
}
:label {
id = "warn",
label = "",
text = tempLang[currentLang].LangDialog.warn
}
LangDialog:show()
plugin.preferences.lang = currentLang
end
return execute