mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Add support for translating content titles and descriptions (#12208)
This commit is contained in:
parent
57de599a29
commit
b4be483d3e
12 changed files with 252 additions and 47 deletions
|
@ -150,6 +150,8 @@ function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
|||
toadd.virtual_path = mod_virtual_path
|
||||
toadd.type = "mod"
|
||||
|
||||
pkgmgr.update_translations({ toadd })
|
||||
|
||||
-- Check modpack.txt
|
||||
-- Note: modpack.conf is already checked above
|
||||
local modpackfile = io.open(mod_path .. DIR_DELIM .. "modpack.txt")
|
||||
|
@ -189,6 +191,8 @@ function pkgmgr.get_texture_packs()
|
|||
load_texture_packs(txtpath_system, retval)
|
||||
end
|
||||
|
||||
pkgmgr.update_translations(retval)
|
||||
|
||||
table.sort(retval, function(a, b)
|
||||
return a.title:lower() < b.title:lower()
|
||||
end)
|
||||
|
@ -775,6 +779,29 @@ function pkgmgr.update_gamelist()
|
|||
table.sort(pkgmgr.games, function(a, b)
|
||||
return a.title:lower() < b.title:lower()
|
||||
end)
|
||||
pkgmgr.update_translations(pkgmgr.games)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function pkgmgr.update_translations(list)
|
||||
for _, item in ipairs(list) do
|
||||
local info = core.get_content_info(item.path)
|
||||
assert(info.path)
|
||||
assert(info.textdomain)
|
||||
|
||||
assert(not item.is_translated)
|
||||
item.is_translated = true
|
||||
|
||||
if info.title and info.title ~= "" then
|
||||
item.title = core.get_content_translation(info.path, info.textdomain,
|
||||
core.translate(info.textdomain, info.title))
|
||||
end
|
||||
|
||||
if info.description and info.description ~= "" then
|
||||
item.description = core.get_content_translation(info.path, info.textdomain,
|
||||
core.translate(info.textdomain, info.description))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
@ -114,12 +114,13 @@ local function get_formspec(tabview, name, tabdata)
|
|||
modscreenshot = defaulttexturedir .. "no_screenshot.png"
|
||||
end
|
||||
|
||||
local info = core.get_content_info(selected_pkg.path)
|
||||
local desc = fgettext("No package description available")
|
||||
if info.description and info.description:trim() ~= "" then
|
||||
desc = core.formspec_escape(info.description)
|
||||
if selected_pkg.description and selected_pkg.description:trim() ~= "" then
|
||||
desc = core.formspec_escape(selected_pkg.description)
|
||||
end
|
||||
|
||||
local info = core.get_content_info(selected_pkg.path)
|
||||
|
||||
local title_and_name
|
||||
if selected_pkg.type == "game" then
|
||||
title_and_name = selected_pkg.name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue