mirror of
https://github.com/arsdragonfly/random_messages.git
synced 2024-11-05 18:00:35 +01:00
add intllib support (i18n)
add french translation
This commit is contained in:
parent
55e197dc6e
commit
1c507021bf
1
depends.txt
Normal file
1
depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
intllib?
|
16
init.lua
16
init.lua
|
@ -13,6 +13,10 @@ 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")
|
||||
|
||||
function table.count( t )
|
||||
local i = 0
|
||||
for k in pairs( t ) do i = i + 1 end
|
||||
|
@ -58,8 +62,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("Blame the server admin! He/She has probably not edited the random messages yet.\n")
|
||||
output:write("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"))
|
||||
else
|
||||
-- or write default_input content in worldpath message file
|
||||
local content = default_input:read("*all")
|
||||
|
@ -130,7 +134,7 @@ end)
|
|||
local register_chatcommand_table = {
|
||||
params = "viewmessages | removemessage <number> | addmessage <number>",
|
||||
privs = {server = true},
|
||||
description = "View and/or alter the server's random messages",
|
||||
description = S("View and/or alter the server's random messages"),
|
||||
func = function(name,param)
|
||||
local t = string.split(param, " ")
|
||||
if t[1] == "viewmessages" then
|
||||
|
@ -141,7 +145,7 @@ local register_chatcommand_table = {
|
|||
function (params)
|
||||
if not tonumber(params[2]) or
|
||||
random_messages.messages[tonumber(params[2])] == nil then
|
||||
return false,"ERROR: No such message."
|
||||
return false,S("ERROR: No such message.")
|
||||
end
|
||||
return true
|
||||
end,
|
||||
|
@ -149,12 +153,12 @@ local register_chatcommand_table = {
|
|||
random_messages.remove_message(t[2])
|
||||
elseif t[1] == "addmessage" then
|
||||
if not t[2] then
|
||||
minetest.chat_send_player(name,"ERROR: No message.")
|
||||
minetest.chat_send_player(name,S("ERROR: No message."))
|
||||
else
|
||||
random_messages.add_message(t)
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name,"ERROR: Invalid command.")
|
||||
minetest.chat_send_player(name,S("ERROR: Invalid command."))
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
45
intllib.lua
Normal file
45
intllib.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
|
||||
-- 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
Normal file
50
locale/fr.po
Normal file
|
@ -0,0 +1,50 @@
|
|||
# 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."
|
44
locale/template.pot
Normal file
44
locale/template.pot
Normal file
|
@ -0,0 +1,44 @@
|
|||
# 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 ""
|
Loading…
Reference in New Issue
Block a user