Skip to content
Snippets Groups Projects
Commit aabca124 authored by Otowa Kotori's avatar Otowa Kotori
Browse files

added chinese locale

parent ead3c516
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -29,6 +29,7 @@ newPackage{ id = "basic", name = "Basic", weight = 1, ...@@ -29,6 +29,7 @@ newPackage{ id = "basic", name = "Basic", weight = 1,
classic = {font="/data/font/Vera.ttf", normal=12, small=10, big=14}, classic = {font="/data/font/Vera.ttf", normal=12, small=10, big=14},
classic_mono = {font="/data/font/VeraMono.ttf", normal=12, small=10, big=14}, classic_mono = {font="/data/font/VeraMono.ttf", normal=12, small=10, big=14},
insular = {font="/data/font/INSULA__.ttf", normal=14, small=12, big=16}, insular = {font="/data/font/INSULA__.ttf", normal=14, small=12, big=16},
terminal = {font="/data/font/VeraMono.ttf", normal=12, small=10, big=14},
} }
newPackage{ id = "web", name = "Web", weight = 10, newPackage{ id = "web", name = "Web", weight = 10,
...@@ -45,6 +46,7 @@ newPackage{ id = "web", name = "Web", weight = 10, ...@@ -45,6 +46,7 @@ newPackage{ id = "web", name = "Web", weight = 10,
classic = {font="/data/font/USENET_.ttf", normal=16, small=14, big=18}, classic = {font="/data/font/USENET_.ttf", normal=16, small=14, big=18},
classic_mono = {font="/data/font/SVBasicManual.ttf", normal=14, small=10, big=16}, classic_mono = {font="/data/font/SVBasicManual.ttf", normal=14, small=10, big=16},
insular = {font="/data/font/INSULA__.ttf", normal=14, small=12, big=16}, insular = {font="/data/font/INSULA__.ttf", normal=14, small=12, big=16},
terminal = {font="/data/font/DroidSansMono.ttf", normal=12, small=10, big=14},
} }
newPackage{ id = "fantasy", name = "Fantasy", weight = 100, newPackage{ id = "fantasy", name = "Fantasy", weight = 100,
...@@ -60,6 +62,7 @@ newPackage{ id = "fantasy", name = "Fantasy", weight = 100, ...@@ -60,6 +62,7 @@ newPackage{ id = "fantasy", name = "Fantasy", weight = 100,
classic = {font="/data/font/USENET_.ttf", normal=16, small=14, big=18}, classic = {font="/data/font/USENET_.ttf", normal=16, small=14, big=18},
classic_mono = {font="/data/font/SVBasicManual.ttf", normal=14, small=10, big=16}, classic_mono = {font="/data/font/SVBasicManual.ttf", normal=14, small=10, big=16},
insular = {font="/data/font/INSULA__.ttf", normal=14, small=12, big=16}, insular = {font="/data/font/INSULA__.ttf", normal=14, small=12, big=16},
terminal = {font="/data/font/DroidSansMono.ttf", normal=12, small=10, big=14},
} }
...@@ -75,4 +78,5 @@ newPackage{ id = "chinese", name = "Chinese", weight = 100, ...@@ -75,4 +78,5 @@ newPackage{ id = "chinese", name = "Chinese", weight = 100,
resources_small = {font="/data/font/WenQuanYiMicroHei.ttf", normal=14}, resources_small = {font="/data/font/WenQuanYiMicroHei.ttf", normal=14},
classic = {font="/data/font/WenQuanYiMicroHei.ttf", normal=16, small=14, big=18}, classic = {font="/data/font/WenQuanYiMicroHei.ttf", normal=16, small=14, big=18},
classic_mono = {font="/data/font/WenQuanYiMicroHeiMono.ttf", normal=14, small=10, big=16}, classic_mono = {font="/data/font/WenQuanYiMicroHeiMono.ttf", normal=14, small=10, big=16},
terminal = {font="/data/font/WenQuanYiMicroHeiMono.ttf", normal=12, small=10, big=14},
} }
This diff is collapsed.
...@@ -134,7 +134,7 @@ function _M:init() ...@@ -134,7 +134,7 @@ function _M:init()
self.blink_period = 20 self.blink_period = 20
self.blink = self.blink_period self.blink = self.blink_period
local w, h = core.display.size() local w, h = core.display.size()
engine.Dialog.init(self, _t"Lua Console", w, h, 0, 0, nil, core.display.newFont(FontPackage:getFont("mono"), 12)) engine.Dialog.init(self, _t"Lua Console", w, h, 0, 0, nil, core.display.newFont(FontPackage:getFont("terminal"), 12))
game:onTickEnd(function() self.key:unicodeInput(true) end) game:onTickEnd(function() self.key:unicodeInput(true) end)
self:keyCommands{ self:keyCommands{
_RETURN = function() _RETURN = function()
......
This diff is collapsed.
...@@ -68,7 +68,7 @@ Talents.newTalent = function(self, t) ...@@ -68,7 +68,7 @@ Talents.newTalent = function(self, t)
end end
if t.is_race_evolution then if t.is_race_evolution then
t.short_name = (t.short_name or t.name):upper():gsub("[ ']", "_") t.short_name = (t.short_name or t.name):upper():gsub("[ ']", "_")
t.name = ("#SANDY_BROWN# (Race Evolution)"):tformat(_t(t.name)) t.name = ("#SANDY_BROWN#%s (Race Evolution)"):tformat(_t(t.name))
end end
return oldNewTalent(self, t) return oldNewTalent(self, t)
......
...@@ -204,13 +204,14 @@ local merged_src = {} ...@@ -204,13 +204,14 @@ local merged_src = {}
local translated = 0 local translated = 0
local all_entry = 0 local all_entry = 0
local not_merged = 0 local not_merged = 0
local function write_section(f, f2, f3, section) local function write_section(f, f2, section)
local result = ""
local f2_count = 0 local f2_count = 0
t = locales_sections[section] t = locales_sections[section]
f:write("------------------------------------------------\n") f:write("------------------------------------------------\n")
f:write(('section "%s"\n\n'):format(section)) f:write(('section "%s"\n\n'):format(section))
f3:write("------------------------------------------------\n") result = result .. "------------------------------------------------\n"
f3:write(('section "%s"\n\n'):format(section)) result = result .. ('section "%s"\n\n'):format(section)
local f2_text = "" local f2_text = ""
local list = {} local list = {}
for _, e in pairs(t) do for _, e in pairs(t) do
...@@ -259,7 +260,7 @@ local function write_section(f, f2, f3, section) ...@@ -259,7 +260,7 @@ local function write_section(f, f2, f3, section)
print_str = print_str .. ")" print_str = print_str .. ")"
end end
if not (section ~= "always_merge" and e.bogus) then if not (section ~= "always_merge" and e.bogus) then
f3:write(print_str .. "\n") result = result .. print_str .. "\n"
end end
else else
print_str = "t(" .. suitable_string(src) .. ", " .. suitable_string(src) .. ", " .. suitable_string(tag) .. ")" print_str = "t(" .. suitable_string(src) .. ", " .. suitable_string(src) .. ", " .. suitable_string(tag) .. ")"
...@@ -278,7 +279,7 @@ local function write_section(f, f2, f3, section) ...@@ -278,7 +279,7 @@ local function write_section(f, f2, f3, section)
end end
end end
f:write("\n\n") f:write("\n\n")
f3:write("\n\n") result = result .. "\n\n"
if f2_text ~= "" then if f2_text ~= "" then
f2:write("------------------------------------------------\n") f2:write("------------------------------------------------\n")
f2:write(('section "%s"\n'):format(section)) f2:write(('section "%s"\n'):format(section))
...@@ -286,21 +287,87 @@ local function write_section(f, f2, f3, section) ...@@ -286,21 +287,87 @@ local function write_section(f, f2, f3, section)
f2:write(f2_text) f2:write(f2_text)
f2:write("\n\n") f2:write("\n\n")
end end
return result
end
local output_filename ={}
local output_content = {}
local function copy_file(filename)
local fc = io.open(filename, "rb")
local result = 'locale "' .. locale .. '"'
if fc then
while true do
local l = fc:read()
if not l then break end
result = result .. l
end
end
return result .. "\n"
end
local function get_section_shortname(section)
if section == "always_merge" then
return "engine"
elseif section:find("game/engines/default/") then
return "engine"
elseif section:find("game/modules/tome/") then
return "tome"
elseif section:find("game/addons/") then
return "addon-" .. section:gsub("game/addons/tome%-([^/]+).+", "%1")
elseif section:find("game/dlcs/") then
return "dlc-" .. section:gsub("game/dlcs/tome%-([^/]+).+", "%1")
else
return nil
end
end
local function setup_section(shortname)
local file_name = ""
if shortname == "tome" then
lfs.mkdir("../game/modules/tome/data/locales")
file_name = "../game/modules/tome/data/locales/" .. locale .. ".lua"
elseif shortname == "engine" then
lfs.mkdir("../game/engines/default/data/locales")
lfs.mkdir("../game/engines/default/data/locales/engine")
file_name = "../game/engines/default/data/locales/engine/" .. locale .. ".lua"
elseif shortname:find("addon-") then
local name = shortname:gsub("^addon%-", "")
lfs.mkdir("../game/addons/tome-" .. name .. "/data/locales")
file_name = "../game/addons/tome-" .. name .. "/data/locales/" .. locale .. ".lua"
elseif shortname:find("dlc-") then
local name = shortname:gsub("^dlc%-", "")
lfs.mkdir("../game/dlcs/tome-" .. name .. "/data/locales")
file_name = "../game/dlcs/tome-" .. name .. "/data/locales/" .. locale .. ".lua"
end
output_filename[shortname] = file_name
output_content[shortname] = copy_file(shortname .. "." .. locale .. ".copy.lua")
end
local function check_section(section, result)
local shortname = get_section_shortname(section)
if shortname then
if not output_filename[shortname] then
setup_section(shortname)
end
output_content[shortname] = output_content[shortname] .. result
end
end end
local function print_file(file_out, file_out_2, file_out_3, file_copy) local function print_file(file_out, file_out_2, file_out_3, file_copy)
local f = io.open(file_out, "w") local f = io.open(file_out, "w")
local f2 = io.open(file_out_2, "w") local f2 = io.open(file_out_2, "w")
local f3 = io.open(file_out_3, "w")
local fc = io.open(file_copy, "rb")
f3:write("locale \"" .. locale .. "\"\n")
while true do
local l = fc:read()
if not l then break end
f3:write(l)
end
table.sort(sections) table.sort(sections)
for _, section in ipairs(sections) do for _, section in ipairs(sections) do
write_section(f, f2, f3, section) local result = write_section(f, f2, section)
check_section(section, result)
end
for shortname, content in pairs(output_content) do
print(shortname)
lfs.mkdir("outputs")
local fn = "outputs/" .. shortname .. "." .. locale .. ".lua"
local ff = io.open(fn, "w")
ff:write(content)
ff:close()
fn = output_filename[shortname]
print(fn)
ff = io.open(fn, "w")
ff:write(content)
ff:close()
end end
print(("%d / %d entries translated"):format(translated, all_entry)) print(("%d / %d entries translated"):format(translated, all_entry))
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment