From 0895cf7ce460f442c37dff1dabfb450bb8ce1e8c Mon Sep 17 00:00:00 2001 From: sys4 Date: Sat, 25 Jun 2022 21:22:38 +0200 Subject: [PATCH] Mod refresh and remove intllib support to Minetest translator - Remove depends.txt - Update mod.conf - Add settingtypes.txt for interval between two subsequent messages --- depends.txt | 1 - init.lua | 27 ++++++++++--------- intllib.lua | 45 -------------------------------- locale/fr.po | 50 ------------------------------------ locale/random_messages.fr.tr | 8 ++++++ locale/template.pot | 44 ------------------------------- locale/template.txt | 8 ++++++ mod.conf | 2 ++ settingtypes.txt | 2 ++ 9 files changed, 35 insertions(+), 152 deletions(-) delete mode 100644 depends.txt delete mode 100644 intllib.lua delete mode 100644 locale/fr.po create mode 100644 locale/random_messages.fr.tr delete mode 100644 locale/template.pot create mode 100644 locale/template.txt create mode 100644 settingtypes.txt diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 77e8d97..0000000 --- a/depends.txt +++ /dev/null @@ -1 +0,0 @@ -intllib? diff --git a/init.lua b/init.lua index 654b034..54ea552 100644 --- a/init.lua +++ b/init.lua @@ -13,9 +13,18 @@ math.randomseed(os.time()) random_messages = {} random_messages.messages = {} --This table contains all messages. --- Load support for intllib. -local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S +if minetest.get_translator ~= nil then + S = minetest.get_translator("random_messages") +else + S = function(str, ...) + local args={...} + return str:gsub( + "@%d+", + function(match) return args[tonumber(match:sub(2))] end + ) + end +end function table.count( t ) local i = 0 @@ -32,14 +41,8 @@ function table.random( t ) end end -function random_messages.initialize() --Set the interval in minetest.conf. - minetest.settings:set("random_messages_interval",120) - minetest.settings:write(); - return 120 -end - function random_messages.set_interval() --Read the interval from minetest.conf(set it if it doesn'st exist) - MESSAGE_INTERVAL = tonumber(minetest.settings:get("random_messages_interval")) or random_messages.initialize() + MESSAGE_INTERVAL = tonumber(minetest.settings:get("random_messages_interval") or 120) end function random_messages.check_params(name,func,params) @@ -62,8 +65,8 @@ function random_messages.read_messages() local output = io.open(minetest.get_worldpath().."/random_messages","w") if not default_input then -- blame the admin if not found - output:write(S("Blame the server admin! He/She has probably not edited the random messages yet.\n")) - output:write(S("Tell your dumb admin that this line is in (worldpath)/random_messages\n")) + output:write(S("Blame the server admin! He/She has probably not edited the random messages yet.").."\n") + output:write(S("Tell your dumb admin that this line is in (worldpath)/random_messages").."\n") return else -- or write default_input content in worldpath message file 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/fr.po b/locale/fr.po deleted file mode 100644 index eb7c919..0000000 --- a/locale/fr.po +++ /dev/null @@ -1,50 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -msgid "" -msgstr "" -"Project-Id-Version: \n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-04 15:04+0200\n" -"PO-Revision-Date: 2017-08-04 15:05+0200\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.8.12\n" -"Last-Translator: fat115 \n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" -"Language: fr\n" - -#: init.lua -msgid "" -"Blame the server admin! He/She has probably not edited the random messages " -"yet.\n" -msgstr "" -"Tirez les oreilles à l'administrateur du serveur. Il/elle n'a pas encore " -"modifié les messages aléatoires.\n" - -#: init.lua -msgid "" -"Tell your dumb admin that this line is in (worldpath)/random_messages\n" -msgstr "" -"Dites à votre administrateur à la noix que cette ligne se trouve dans " -"(worldpath)/random_messages\n" - -#: init.lua -msgid "View and/or alter the server's random messages" -msgstr "Afficher et/ou modifier les messages aléatoires du serveur" - -#: init.lua -msgid "ERROR: No such message." -msgstr "ERREUR : ce message est inexistant." - -#: init.lua -msgid "ERROR: No message." -msgstr "ERREUR : pas de message." - -#: init.lua -msgid "ERROR: Invalid command." -msgstr "ERREUR : Commande invalide." diff --git a/locale/random_messages.fr.tr b/locale/random_messages.fr.tr new file mode 100644 index 0000000..333d2b3 --- /dev/null +++ b/locale/random_messages.fr.tr @@ -0,0 +1,8 @@ +# textdomain: random_messages + +Blame the server admin! He/She has probably not edited the random messages yet.=Tirez les oreilles à l'administrateur du serveur. Il/elle n'a pas encore modifié les messages aléatoires. +Tell your dumb admin that this line is in (worldpath)/random_messages=Dites à votre administrateur à la noix que cette ligne se trouve dans (worldpath)/random_messages +View and/or alter the server's random messages=Afficher et/ou modifier les messages aléatoires du serveur +ERROR: No such message.=ERREUR : ce message est inexistant. +ERROR: No message.=ERREUR : pas de message. +ERROR: Invalid command.=ERREUR : Commande invalide. diff --git a/locale/template.pot b/locale/template.pot deleted file mode 100644 index 9384e0f..0000000 --- a/locale/template.pot +++ /dev/null @@ -1,44 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-04 15:04+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: init.lua -msgid "" -"Blame the server admin! He/She has probably not edited the random messages " -"yet.\n" -msgstr "" - -#: init.lua -msgid "Tell your dumb admin that this line is in (worldpath)/random_messages\n" -msgstr "" - -#: init.lua -msgid "View and/or alter the server's random messages" -msgstr "" - -#: init.lua -msgid "ERROR: No such message." -msgstr "" - -#: init.lua -msgid "ERROR: No message." -msgstr "" - -#: init.lua -msgid "ERROR: Invalid command." -msgstr "" diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..8a5abe4 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,8 @@ +# textdomain: random_messages + +Blame the server admin! He/She has probably not edited the random messages yet.= +Tell your dumb admin that this line is in (worldpath)/random_messages= +View and/or alter the server's random messages= +ERROR: No such message.= +ERROR: No message.= +ERROR: Invalid command.= diff --git a/mod.conf b/mod.conf index 42e14dd..071883d 100644 --- a/mod.conf +++ b/mod.conf @@ -1 +1,3 @@ name = random_messages +description = Configure your random messages. +author = arsdragonfly diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..844d7b0 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# Default is 120 seconds. +random_messages_interval (Time between two subsequent messages) int 120