From 9623aec62e1bcdcc93523dff68c09f7bd80beda1 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Thu, 2 Feb 2017 20:27:54 -0700 Subject: [PATCH] Not much to translate here, but why not. Internationalization library support. --- depends.txt | 3 ++- init.lua | 8 ++++++-- intllib.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ locale/de.po | 25 +++++++++++++++++++++++++ locale/es.po | 25 +++++++++++++++++++++++++ locale/fr.po | 25 +++++++++++++++++++++++++ locale/template.pot | 25 +++++++++++++++++++++++++ 7 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 intllib.lua create mode 100644 locale/de.po create mode 100644 locale/es.po create mode 100644 locale/fr.po create mode 100644 locale/template.pot diff --git a/depends.txt b/depends.txt index 21c2521..6eec83b 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,2 @@ -default? \ No newline at end of file +default? +intllib? \ No newline at end of file diff --git a/init.lua b/init.lua index fab9372..c490904 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,9 @@ dynamic_liquid = {} -- global table to expose liquid_abm for other mods' usage +-- internationalization boilerplate +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") + -- By making this giant table of all possible permutations of horizontal direction we can avoid -- lots of redundant calculations. local all_direction_permutations = { @@ -134,7 +138,7 @@ end -- register damp clay whether we're going to set the ABM or not, if the user disables this feature we don't want existing -- spring clay to turn into unknown nodes. local clay_def = duplicate_def("default:clay") -clay_def.description = "Damp Clay" +clay_def.description = S("Damp Clay") if not springs then clay_def.groups.not_in_creative_inventory = 1 -- take it out of creative inventory though end @@ -190,7 +194,7 @@ if springs then -- This is a creative-mode only node that produces a modest amount of water continuously no matter where it is. -- Allow this one to turn into "unknown node" when this feature is disabled, since players had to explicitly place it. minetest.register_node("dynamic_liquid:spring", { - description = "Spring", + description = S("Spring"), drops = "default:gravel", tiles = {"default_cobble.png^[combine:16x80:0,-48=crack_anylength.png", "default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png", 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/de.po b/locale/de.po new file mode 100644 index 0000000..ec3e869 --- /dev/null +++ b/locale/de.po @@ -0,0 +1,25 @@ +# Dynamic liquid Minetest mod. +# Copyright (C) 2017 +# This file is distributed under the same license as the dynamic_liquid package. +# FaceDeer +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-02 20:18-0700\n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: init.lua:141 +msgid "Damp Clay" +msgstr "Feuchten Lehm" + +#: init.lua:197 +msgid "Spring" +msgstr "Quelle" diff --git a/locale/es.po b/locale/es.po new file mode 100644 index 0000000..433f27b --- /dev/null +++ b/locale/es.po @@ -0,0 +1,25 @@ +# Dynamic liquid Minetest mod. +# Copyright (C) 2017 +# This file is distributed under the same license as the dynamic_liquid package. +# FaceDeer +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-02 20:18-0700\n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: init.lua:141 +msgid "Damp Clay" +msgstr "Arcilla húmeda" + +#: init.lua:197 +msgid "Spring" +msgstr "Manantial" diff --git a/locale/fr.po b/locale/fr.po new file mode 100644 index 0000000..4e712e2 --- /dev/null +++ b/locale/fr.po @@ -0,0 +1,25 @@ +# Dynamic liquid Minetest mod. +# Copyright (C) 2017 +# This file is distributed under the same license as the dynamic_liquid package. +# FaceDeer +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-02 20:18-0700\n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: init.lua:141 +msgid "Damp Clay" +msgstr "Argile humide" + +#: init.lua:197 +msgid "Spring" +msgstr "Source" diff --git a/locale/template.pot b/locale/template.pot new file mode 100644 index 0000000..dfcbd11 --- /dev/null +++ b/locale/template.pot @@ -0,0 +1,25 @@ +# Dynamic liquid Minetest mod. +# Copyright (C) 2017 +# This file is distributed under the same license as the dynamic_liquid package. +# FaceDeer +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-02 20:18-0700\n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: init.lua:141 +msgid "Damp Clay" +msgstr "" + +#: init.lua:197 +msgid "Spring" +msgstr ""