From 05934e36e90fe8d00ff9b62545792ba9845f55cb Mon Sep 17 00:00:00 2001 From: Louis Royer <55180044+louisroyer@users.noreply.github.com> Date: Sun, 12 Jul 2020 09:11:21 +0200 Subject: [PATCH] Use builtin client-side translation support from minetest 5 --- depends.txt | 1 - init.lua | 16 ++++++++-------- intllib.lua | 45 --------------------------------------------- locale/template.txt | 9 +++++++++ mod.conf | 3 ++- 5 files changed, 19 insertions(+), 55 deletions(-) delete mode 100644 depends.txt delete mode 100644 intllib.lua create mode 100644 locale/template.txt diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 562cf63..0000000 --- a/depends.txt +++ /dev/null @@ -1 +0,0 @@ -default diff --git a/init.lua b/init.lua index 387a101..f5d4b61 100644 --- a/init.lua +++ b/init.lua @@ -1,12 +1,12 @@ -local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP..'/intllib.lua') +-- Translation support +local S = minetest.get_translator("algae") -- -- Algae -- local algae_thin_def = { - description = S("Algae_thin"), + description = S("Thin algae"), drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", @@ -51,7 +51,7 @@ local algae_thin_def = { itemstack:take_item() end else - minetest.chat_send_player(player_name, "Node is protected") + minetest.chat_send_player(player_name, S("Node is protected.")) minetest.record_protection_violation(pos, player_name) end end @@ -61,7 +61,7 @@ local algae_thin_def = { } local algae_medium_def = { - description = S("Algae_Medium"), + description = S("Medium algae"), drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", @@ -106,7 +106,7 @@ local algae_medium_def = { itemstack:take_item() end else - minetest.chat_send_player(player_name, "Node is protected") + minetest.chat_send_player(player_name, S("Node is protected.")) minetest.record_protection_violation(pos, player_name) end end @@ -116,7 +116,7 @@ local algae_medium_def = { } local algae_thick_def = { - description = S("Algae_thick"), + description = S("Thick algae"), drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", @@ -166,7 +166,7 @@ local algae_thick_def = { itemstack:take_item() end else - minetest.chat_send_player(player_name, "Node is protected") + minetest.chat_send_player(player_name, S("Node is protected.")) minetest.record_protection_violation(pos, player_name) end end diff --git a/intllib.lua b/intllib.lua deleted file mode 100644 index a9cb5df..0000000 --- a/intllib.lua +++ /dev/null @@ -1,45 +0,0 @@ - --- Fallback functions for when `intllib` is not installed. --- Code released under Unlicense . - --- Get the latest version of this file at: --- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua - -local function format(str, ...) - local args = { ... } - local function repl(escape, open, num, close) - if escape == '' then - local replacement = tostring(args[tonumber(num)]) - if open == '' then - replacement = replacement..close - end - return replacement - else - return '@'..open..num..close - end - end - return (str:gsub('(@?)@(%(?)(%d+)(%)?)', repl)) -end - -local gettext, ngettext -if minetest.get_modpath('intllib') then - if intllib.make_gettext_pair then - -- New method using gettext. - gettext, ngettext = intllib.make_gettext_pair() - else - -- Old method using text files. - gettext = intllib.Getter() - end -end - --- Fill in missing functions. - -gettext = gettext or function(msgid, ...) - return format(msgid, ...) -end - -ngettext = ngettext or function(msgid, msgid_plural, n, ...) - return format(n==1 and msgid or msgid_plural, ...) -end - -return gettext, ngettext diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..cefe05f --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,9 @@ +# textdomain: algae + + +### init.lua ### + +Medium algae= +Node is protected.= +Thick algae= +Thin algae= diff --git a/mod.conf b/mod.conf index 9b68782..4d692cf 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,4 @@ name = algae description = Algae mapgen addition to "Minetest Game" -depends = default \ No newline at end of file +depends = default +min_minetest_version = 5.0