From 52011bdfa433ceefc2b2e6beca110aa57603d5c1 Mon Sep 17 00:00:00 2001 From: alexerate <35458285+alexerate@users.noreply.github.com> Date: Tue, 6 Feb 2018 15:15:32 +0100 Subject: [PATCH] localisation --- interact.lua | 8 ++++---- intllib.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ locale/fr.po | 23 +++++++++++++++++++++++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 intllib.lua create mode 100644 locale/fr.po diff --git a/interact.lua b/interact.lua index 9a457d2..78a1f6f 100644 --- a/interact.lua +++ b/interact.lua @@ -1,3 +1,5 @@ +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") local old_is_protected = minetest.is_protected function minetest.is_protected(pos, name) @@ -12,10 +14,8 @@ minetest.register_on_protection_violation(function(pos, name) local playerpos = player:getpos() if not areas:canInteract(pos, name) then local owners = areas:getNodeOwners(pos) - minetest.chat_send_player(name, - ("%s is protected by %s."):format( - minetest.pos_to_string(pos), - table.concat(owners, ", "))) + --minetest.chat_send_player(name, ("%s is protected by %s."):format(minetest.pos_to_string(pos), table.concat(owners, ", "))) + minetest.chat_send_player(name,S("@1 is protected by @2",minetest.pos_to_string(pos),table.concat(owners, ", "))) minetest.after(1,anti_lag,{player=player,playerpos=playerpos}) end end) diff --git a/intllib.lua b/intllib.lua new file mode 100644 index 0000000..6669d72 --- /dev/null +++ b/intllib.lua @@ -0,0 +1,45 @@ + +-- 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 new file mode 100644 index 0000000..b0dde4b --- /dev/null +++ b/locale/fr.po @@ -0,0 +1,23 @@ +# 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: 2018-01-29 11:28+0200\n" +"PO-Revision-Date: 2018-01-29 09:18+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\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" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: init.lua +msgid "@1 is protected by @2" +msgstr "@1 est protégé par @2"