From 8f6f8dda7e07ceb1a8b751de2efada929c0de362 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Wed, 13 Feb 2019 14:15:29 +0100 Subject: [PATCH] Use engine translator, ditch intllib --- depends.txt | 3 +- init.lua | 3 +- intllib.lua | 45 ------------------------------ locale/{de.po => craftguide.de.tr} | 0 locale/{ms.po => craftguide.ms.tr} | 0 locale/{ru.po => craftguide.ru.tr} | 0 6 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 intllib.lua rename locale/{de.po => craftguide.de.tr} (100%) rename locale/{ms.po => craftguide.ms.tr} (100%) rename locale/{ru.po => craftguide.ru.tr} (100%) diff --git a/depends.txt b/depends.txt index 87c6271..ad29828 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,2 @@ sfinv? -sfinv_buttons? -intllib? \ No newline at end of file +sfinv_buttons? \ No newline at end of file diff --git a/init.lua b/init.lua index 65dd37e..cf5b18a 100644 --- a/init.lua +++ b/init.lua @@ -21,8 +21,7 @@ local show_formspec = mt.show_formspec local get_player_by_name = mt.get_player_by_name local serialize, deserialize = mt.serialize, mt.deserialize --- Intllib -local S = dofile(mt.get_modpath("craftguide") .. "/intllib.lua") +local S = mt.get_translator("craftguide") -- Lua 5.3 removed `table.maxn`, use this alternative in case of breakage: -- https://github.com/kilbith/xdecor/blob/master/handlers/helpers.lua#L1 diff --git a/intllib.lua b/intllib.lua deleted file mode 100644 index 6669d72..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/de.po b/locale/craftguide.de.tr similarity index 100% rename from locale/de.po rename to locale/craftguide.de.tr diff --git a/locale/ms.po b/locale/craftguide.ms.tr similarity index 100% rename from locale/ms.po rename to locale/craftguide.ms.tr diff --git a/locale/ru.po b/locale/craftguide.ru.tr similarity index 100% rename from locale/ru.po rename to locale/craftguide.ru.tr