Translation support for package metadata

This commit is contained in:
Aaron Suen 2022-04-22 07:29:54 -04:00
parent 7f284808a8
commit 6401faa87b
4 changed files with 24 additions and 7 deletions

View File

@ -31,14 +31,15 @@ for i = 1, 5 do
screenshots[#screenshots + 1] = readbinary('.cdb-screen' .. i .. '.jpg')
end
local version = dofile("./mods/nc_api/version.lua")
local pkgmeta = dofile("./mods/nc_api/pkgmeta.lua")
return {
pkg = alpha and "nodecore_alpha" or "nodecore",
version = dofile("./mods/nc_api/version.lua"),
version = version,
type = "game",
title = "NodeCore" .. (alpha and " ALPHA" or ""),
short_description = (alpha
and "Early-access edition of NodeCore with latest features (and maybe bugs)"
or "Minetest's top original voxel game about emergent mechanics and exploration"),
title = "NodeCore" .. pkgmeta.title(alpha),
short_description = pkgmeta.desc(alpha),
dev_state = alpha and "BETA" or "ACTIVELY_DEVELOPED",
tags = tags,
content_warnings = {},

View File

@ -1,4 +1,5 @@
name = NodeCore
description = An original, immersive puzzle/adventure game with NO popup GUIs, minimal HUDs.
textdomain = nc_api
min_minetest_version = 5.4
disabled_settings = creative_mode, !enable_damage

10
mods/nc_api/pkgmeta.lua Normal file
View File

@ -0,0 +1,10 @@
return {
title = function(alpha)
return "NodeCore" .. (alpha and " ALPHA" or "")
end,
desc = function(alpha)
return alpha
and "Early-access edition of NodeCore with latest features (and maybe bugs)"
or "Minetest's top original voxel game about emergent mechanics and exploration"
end
}

View File

@ -1,6 +1,6 @@
-- LUALOCALS < ---------------------------------------------------------
local ipairs, minetest, nodecore, pairs, string, table, type
= ipairs, minetest, nodecore, pairs, string, table, type
local include, ipairs, minetest, nodecore, pairs, string, table, type
= include, ipairs, minetest, nodecore, pairs, string, table, type
local string_format, string_match, table_sort
= string.format, string.match, table.sort
-- LUALOCALS > ---------------------------------------------------------
@ -37,6 +37,11 @@ function nodecore.translate_inform(str)
return true
end
for _, v in pairs(include('pkgmeta')) do
nodecore.translate_inform(v(true))
nodecore.translate_inform(v(false))
end
function nodecore.translate(str, ...)
if not nodecore.translate_inform(str) then return str end
return minetest.translate(modname, str, ...)