forked from mtcontrib/random_messages
Merge branch 'github'
This commit is contained in:
commit
fc37a4b303
@ -1 +0,0 @@
|
||||
intllib?
|
27
init.lua
27
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
|
||||
|
45
intllib.lua
45
intllib.lua
@ -1,45 +0,0 @@
|
||||
|
||||
-- Fallback functions for when `intllib` is not installed.
|
||||
-- Code released under Unlicense <http://unlicense.org>.
|
||||
|
||||
-- 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
|
50
locale/fr.po
50
locale/fr.po
@ -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 <EMAIL@ADDRESS>, 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 <fat115@framasoft.org>\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."
|
8
locale/random_messages.fr.tr
Normal file
8
locale/random_messages.fr.tr
Normal file
@ -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.
|
@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\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 ""
|
8
locale/template.txt
Normal file
8
locale/template.txt
Normal file
@ -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.=
|
2
mod.conf
2
mod.conf
@ -1 +1,3 @@
|
||||
name = random_messages
|
||||
description = Configure your random messages.
|
||||
author = arsdragonfly
|
||||
|
2
settingtypes.txt
Normal file
2
settingtypes.txt
Normal file
@ -0,0 +1,2 @@
|
||||
# Default is 120 seconds.
|
||||
random_messages_interval (Time between two subsequent messages) int 120
|
Loading…
Reference in New Issue
Block a user