From d2933894e641075653e9a6e5d81d65216d6f6ece Mon Sep 17 00:00:00 2001
From: Louis Royer <55180044+louisroyer@users.noreply.github.com>
Date: Tue, 4 Feb 2020 22:05:38 +0100
Subject: [PATCH] Migrate translations to the Minetest localization format
 (#38)

* Translation using MT5 translation api

Fix #36

* Add hoe to french translation
---
 init.lua                  | 21 +++++++++----------
 intllib.lua               | 44 ---------------------------------------
 locale/de.txt             | 21 -------------------
 locale/es.txt             | 21 -------------------
 locale/fr.txt             | 21 -------------------
 locale/it.txt             | 21 -------------------
 locale/moreores.de.tr     | 22 ++++++++++++++++++++
 locale/moreores.en.tr     | 21 +++++++++++++++++++
 locale/moreores.es.tr     | 22 ++++++++++++++++++++
 locale/moreores.fr.tr     | 23 ++++++++++++++++++++
 locale/moreores.it.tr     | 22 ++++++++++++++++++++
 locale/moreores.nl.tr     | 19 +++++++++++++++++
 locale/moreores.pl.tr     | 22 ++++++++++++++++++++
 locale/moreores.pt_br.txt | 23 ++++++++++++++++++++
 locale/moreores.tr.tr     | 28 +++++++++++++++++++++++++
 locale/nl.txt             | 19 -----------------
 locale/pl.txt             | 21 -------------------
 locale/pt_br.txt          | 21 -------------------
 locale/tr.txt             | 25 ----------------------
 mod.conf                  |  2 +-
 20 files changed, 213 insertions(+), 226 deletions(-)
 delete mode 100644 intllib.lua
 delete mode 100644 locale/de.txt
 delete mode 100644 locale/es.txt
 delete mode 100644 locale/fr.txt
 delete mode 100644 locale/it.txt
 create mode 100644 locale/moreores.de.tr
 create mode 100644 locale/moreores.en.tr
 create mode 100644 locale/moreores.es.tr
 create mode 100644 locale/moreores.fr.tr
 create mode 100644 locale/moreores.it.tr
 create mode 100644 locale/moreores.nl.tr
 create mode 100644 locale/moreores.pl.tr
 create mode 100644 locale/moreores.pt_br.txt
 create mode 100644 locale/moreores.tr.tr
 delete mode 100644 locale/nl.txt
 delete mode 100644 locale/pl.txt
 delete mode 100644 locale/pt_br.txt
 delete mode 100644 locale/tr.txt

diff --git a/init.lua b/init.lua
index 59e2798..73cf0ea 100644
--- a/init.lua
+++ b/init.lua
@@ -12,9 +12,8 @@ moreores = {}
 
 local modpath = minetest.get_modpath("moreores")
 
-local S, NS = dofile(modpath .. "/intllib.lua")
+local S = minetest.get_translator("moreores")
 moreores.S = S
-moreores.NS = NS
 
 dofile(modpath .. "/_config.txt")
 
@@ -86,7 +85,7 @@ local function add_ore(modname, description, mineral_name, oredef)
 
 	if oredef.makes.ore then
 		minetest.register_node(modname .. ":mineral_" .. mineral_name, {
-			description = S("%s Ore"):format(S(description)),
+			description = S("@1 Ore", S(description)),
 			tiles = {"default_stone.png^" .. modname .. "_mineral_" .. mineral_name .. ".png"},
 			groups = {cracky = 2},
 			sounds = default_stone_sounds,
@@ -101,7 +100,7 @@ local function add_ore(modname, description, mineral_name, oredef)
 	if oredef.makes.block then
 		local block_item = item_base .. "_block"
 		minetest.register_node(block_item, {
-			description = S("%s Block"):format(S(description)),
+			description = S("@1 Block", S(description)),
 			tiles = {img_base .. "_block.png"},
 			groups = {snappy = 1, bendy = 2, cracky = 1, melty = 2, level = 2},
 			sounds = default_metal_sounds,
@@ -126,7 +125,7 @@ local function add_ore(modname, description, mineral_name, oredef)
 
 	if oredef.makes.lump then
 		minetest.register_craftitem(lump_item, {
-			description = S("%s Lump"):format(S(description)),
+			description = S("@1 Lump", S(description)),
 			inventory_image = img_base .. "_lump.png",
 		})
 		minetest.register_alias(mineral_name .. "_lump", lump_item)
@@ -144,7 +143,7 @@ local function add_ore(modname, description, mineral_name, oredef)
 
 	if oredef.makes.ingot then
 		minetest.register_craftitem(ingot, {
-			description = S("%s Ingot"):format(S(description)),
+			description = S("@1 Ingot", S(description)),
 			inventory_image = img_base .. "_ingot.png",
 		})
 		minetest.register_alias(mineral_name .. "_ingot", ingot)
@@ -187,25 +186,25 @@ local function add_ore(modname, description, mineral_name, oredef)
 		if tool_name == "sword" then
 			tdef.tool_capabilities.full_punch_interval = oredef.full_punch_interval
 			tdef.tool_capabilities.damage_groups = oredef.damage_groups
-			tdef.description = S("%s Sword"):format(S(description))
+			tdef.description = S("@1 Sword", S(description))
 		end
 
 		if tool_name == "pick" then
 			tdef.tool_capabilities.full_punch_interval = oredef.full_punch_interval
 			tdef.tool_capabilities.damage_groups = oredef.damage_groups
-			tdef.description = S("%s Pickaxe"):format(S(description))
+			tdef.description = S("@1 Pickaxe", S(description))
 		end
 
 		if tool_name == "axe" then
 			tdef.tool_capabilities.full_punch_interval = oredef.full_punch_interval
 			tdef.tool_capabilities.damage_groups = oredef.damage_groups
-			tdef.description = S("%s Axe"):format(S(description))
+			tdef.description = S("@1 Axe", S(description))
 		end
 
 		if tool_name == "shovel" then
 			tdef.full_punch_interval = oredef.full_punch_interval
 			tdef.tool_capabilities.damage_groups = oredef.damage_groups
-			tdef.description = S("%s Shovel"):format(S(description))
+			tdef.description = S("@1 Shovel", S(description))
 			tdef.wield_image = toolimg_base .. tool_name .. ".png^[transformR90"
 		end
 
@@ -213,7 +212,7 @@ local function add_ore(modname, description, mineral_name, oredef)
 
 		if tool_name == "hoe" and minetest.get_modpath("farming") then
 			tdef.max_uses = tooldef.uses
-			tdef.description = S("%s Hoe"):format(S(description))
+			tdef.description = S("@1 Hoe", S(description))
 			farming.register_hoe(fulltool_name, tdef)
 		end
 
diff --git a/intllib.lua b/intllib.lua
deleted file mode 100644
index c7af2c2..0000000
--- a/intllib.lua
+++ /dev/null
@@ -1,44 +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
diff --git a/locale/de.txt b/locale/de.txt
deleted file mode 100644
index 070faf9..0000000
--- a/locale/de.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translation by Xanthin
-
-[moreores] loaded. = [moreores] geladen.
-
-%s Ore = %serz
-%s Lump = %sklumpen
-%s Ingot = %sbarren
-%s Block = %sblock
-%s Pickaxe = %sspitzhacke
-%s Shovel = %sschaufel
-%s Axe = %saxt
-%s Sword = %sschwert
-
-Copper = Kupfer
-Tin = Zinn
-Bronze = Bronze
-Silver = Silber
-Gold = Gold
-Mithril = Mithril
-
-Copper Rail = Kupferschiene
diff --git a/locale/es.txt b/locale/es.txt
deleted file mode 100644
index 1344a5a..0000000
--- a/locale/es.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translation by kaeza
-
-[moreores] loaded. = [moreores] cargado.
-
-%s Ore = Mineral de %s
-%s Lump = Pepita de %s
-%s Ingot = Lingote de %s
-%s Block = Bloque de %s
-%s Pickaxe = Pico de %s
-%s Shovel = Pala de %s
-%s Axe = Hacha de %s
-%s Sword = Espada de %s
-
-Copper = cobre
-Tin = estaño
-Bronze = bronce
-Silver = plata
-Gold = oro
-Mithril = mitrilo
-
-Copper Rail = Riel de Cobre
diff --git a/locale/fr.txt b/locale/fr.txt
deleted file mode 100644
index 65687fa..0000000
--- a/locale/fr.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translation by Calinou
-
-[moreores] loaded. = [moreores] a été chargé.
-
-%s Ore = Minerai en %s
-%s Lump = Roche en %s
-%s Ingot = Lingot en %s
-%s Block = Bloc en %s
-%s Pickaxe = Pioche en %s
-%s Shovel = Pelle en %s
-%s Axe = Hache en %s
-%s Sword = Épée en %s
-
-Copper = cuivre
-Tin = étain
-Bronze = bronze
-Silver = argent
-Gold = or
-Mithril = mithril
-
-Copper Rail = Rail en cuivre
diff --git a/locale/it.txt b/locale/it.txt
deleted file mode 100644
index db1644c..0000000
--- a/locale/it.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translation by Pagliaccio
-
-[moreores] loaded. = [moreores] caricato.
-
-%s Ore = Minerale di %s
-%s Lump = %s grezzo
-%s Ingot = Lingotto di %s
-%s Block = Blocco di %s
-%s Pickaxe = Piccone di %s
-%s Shovel = Badile di %s
-%s Axe = Ascia di %s
-%s Sword = Spada di %s
-
-Copper = Rame
-Tin = Stagno
-Bronze = Bronzo
-Silver = Argento
-Gold = Oro
-Mithril = Mithril
-
-Copper Rail = Binario di rame
diff --git a/locale/moreores.de.tr b/locale/moreores.de.tr
new file mode 100644
index 0000000..aac97be
--- /dev/null
+++ b/locale/moreores.de.tr
@@ -0,0 +1,22 @@
+# textdomain: moreores
+
+# Translation by Xanthin
+
+[moreores] loaded.=[moreores] geladen.
+
+@1 Ore=@1erz
+@1 Lump=@1klumpen
+@1 Ingot=@1barren
+@1 Block=@1block
+@1 Pickaxe=@1spitzhacke
+@1 Shovel=@1schaufel
+@1 Axe=@1axt
+@1 Sword=@1schwert
+
+Copper=Kupfer
+Tin=Zinn
+Bronze=Bronze
+Silver=Silber
+Gold=Gold
+Mithril=Mithril
+Copper Rail=Kupferschiene
diff --git a/locale/moreores.en.tr b/locale/moreores.en.tr
new file mode 100644
index 0000000..b13188d
--- /dev/null
+++ b/locale/moreores.en.tr
@@ -0,0 +1,21 @@
+# textdomain: moreores
+
+[moreores] loaded.=[moreores] loaded.
+
+@1 Ore=@1 Ore
+@1 Lump=@1 Lump
+@1 Ingot=@1 Ingot
+@1 Block=@1 Block
+@1 Pickaxe=@1 Pickaxe
+@1 Shovel=@1 Shovel
+@1 Axe=@1 Axe
+@1 Sword=@1 Sword
+@1 Hoe=@1 Hoe
+
+Copper=Copper
+Tin=Tin
+Bronze=Bronze
+Silver=Silver
+Gold=Gold
+Mithril=Mithril
+Copper Rail=Copper Rail
diff --git a/locale/moreores.es.tr b/locale/moreores.es.tr
new file mode 100644
index 0000000..3b709a3
--- /dev/null
+++ b/locale/moreores.es.tr
@@ -0,0 +1,22 @@
+# textdomain: moreores
+
+# Translation by kaeza
+
+[moreores] loaded.=[moreores] cargado.
+
+@1 Ore=Mineral de @1
+@1 Lump=Pepita de @1
+@1 Ingot=Lingote de @1
+@1 Block=Bloque de @1
+@1 Pickaxe=Pico de @1
+@1 Shovel=Pala de @1
+@1 Axe=Hacha de @1
+@1 Sword=Espada de @1
+
+Copper=cobre
+Tin=estaño
+Bronze=bronce
+Silver=plata
+Gold=oro
+Mithril=mitrilo
+Copper Rail=Riel de Cobre
diff --git a/locale/moreores.fr.tr b/locale/moreores.fr.tr
new file mode 100644
index 0000000..2ac45a8
--- /dev/null
+++ b/locale/moreores.fr.tr
@@ -0,0 +1,23 @@
+# textdomain: moreores
+
+# Translation by Calinou
+
+[moreores] loaded.=[moreores] a été chargé.
+
+@1 Ore=Minerai en @1
+@1 Lump=Roche en @1
+@1 Ingot=Lingot en @1
+@1 Block=Bloc en @1
+@1 Pickaxe=Pioche en @1
+@1 Shovel=Pelle en @1
+@1 Axe=Hache en @1
+@1 Sword=Épée en @1
+@1 Hoe=Houe en @1
+
+Copper=cuivre
+Tin=étain
+Bronze=bronze
+Silver=argent
+Gold=or
+Mithril=mithril
+Copper Rail=Rail en cuivre
diff --git a/locale/moreores.it.tr b/locale/moreores.it.tr
new file mode 100644
index 0000000..96541f7
--- /dev/null
+++ b/locale/moreores.it.tr
@@ -0,0 +1,22 @@
+# textdomain: moreores
+
+# Translation by Pagliaccio
+
+[moreores] loaded.=[moreores] caricato.
+
+@1 Ore=Minerale di @1
+@1 Lump=@1 grezzo
+@1 Ingot=Lingotto di @1
+@1 Block=Blocco di @1
+@1 Pickaxe=Piccone di @1
+@1 Shovel=Badile di @1
+@1 Axe=Ascia di @1
+@1 Sword=Spada di @1
+
+Copper=Rame
+Tin=Stagno
+Bronze=Bronzo
+Silver=Argento
+Gold=Oro
+Mithril=Mithril
+Copper Rail=Binario di rame
diff --git a/locale/moreores.nl.tr b/locale/moreores.nl.tr
new file mode 100644
index 0000000..e572ff3
--- /dev/null
+++ b/locale/moreores.nl.tr
@@ -0,0 +1,19 @@
+# textdomain: moreores
+
+[moreores] loaded.=[moreores] geladen.
+
+@1 Ore=@1 Erts
+@1 Lump=@1 Klomp
+@1 Ingot=@1 Staaf
+@1 Block=@1 Blok
+@1 Pickaxe=@1 Pikhouweel
+@1 Shovel=@1 Schep
+@1 Axe=@1 Bijl
+@1 Sword=@1 Zwaard
+
+Copper=Koper
+Tin=Tin
+Bronze=Brons
+Silver=Silver
+Gold=Goud
+Mithril=Mithril
diff --git a/locale/moreores.pl.tr b/locale/moreores.pl.tr
new file mode 100644
index 0000000..2eb2993
--- /dev/null
+++ b/locale/moreores.pl.tr
@@ -0,0 +1,22 @@
+# textdomain: moreores
+
+# Translation by mat9117
+
+[moreores] loaded.=[moreores] załadowano.
+
+@1 Ore=@1 Ruda
+@1 Lump=@1 Bryłka
+@1 Ingot=@1 Sztabka
+@1 Block=@1 Blok
+@1 Pickaxe=@1 Kilof
+@1 Shovel=@1 Łopatka
+@1 Axe=@1 Siekiera
+@1 Sword=@1 Miecz
+
+Copper=Miedź
+Tin=Cyna
+Bronze=BrÄ…z
+Silver=Srebro
+Gold=ZÅ‚oto
+Mithril=Mithril
+Copper Rail=Miedziany tor
diff --git a/locale/moreores.pt_br.txt b/locale/moreores.pt_br.txt
new file mode 100644
index 0000000..613209d
--- /dev/null
+++ b/locale/moreores.pt_br.txt
@@ -0,0 +1,23 @@
+# textdomain: moreores
+
+# Translation by github.com/caiorrs
+
+[moreores] loaded.=[moreores] carregado.
+
+@1 Ore=Minério de @1
+@1 Lump=Pepita de @1
+@1 Ingot=Lingote de @1
+@1 Block=Bloco de @1
+@1 Pickaxe=Picareta de @1
+@1 Shovel=Pá de @1
+@1 Axe=Machado de @1
+@1 Sword=Espada de @1
+
+Copper=Cobre
+Tin=Estanho
+Bronze=Bronze
+Silver=Prata
+Gold=Ouro
+Mithril=Mitrilo
+
+Copper Rail=Trilho de Cobre
diff --git a/locale/moreores.tr.tr b/locale/moreores.tr.tr
new file mode 100644
index 0000000..e41f8e3
--- /dev/null
+++ b/locale/moreores.tr.tr
@@ -0,0 +1,28 @@
+# textdomain: moreores
+
+# Translation by Mahmutelmas06
+# mahmutelmas06@hotmail.com
+
+# Türkçe Çeviri
+# Turkish translation
+# Language 2 letter iso code is "tr"
+
+[moreores] loaded.=[moreores] yüklendi.
+
+@1 Ore=@1 madeni
+@1 Lump=@1 yığını
+@1 Ingot=@1 külçesi
+@1 Block=@1 blok
+@1 Pickaxe=@1 kazma
+@1 Shovel=@1 kürek
+@1 Axe=@1 balta
+@1 Sword=@1 kılıç
+
+Copper=Bakır
+Tin=Kalay
+Bronze=Bronz
+Silver=Gümüş
+Gold=Altın
+Mithril=Mithril
+
+Copper Rail=Bakır ray
diff --git a/locale/nl.txt b/locale/nl.txt
deleted file mode 100644
index 954045f..0000000
--- a/locale/nl.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-[moreores] loaded. = [moreores] geladen.
-
-%s Ore = %s Erts
-%s Lump = %s Klomp
-%s Ingot = %s Staaf
-%s Block = %s Blok
-%s Pickaxe = %s Pikhouweel
-%s Shovel = %s Schep
-%s Axe = %s Bijl
-%s Sword = %s Zwaard
-
-Copper = Koper
-Tin = Tin
-Bronze = Brons
-Silver = Silver
-Gold = Goud
-Mithril = Mithril
-
-Copper Rail = Koperen Spoor
diff --git a/locale/pl.txt b/locale/pl.txt
deleted file mode 100644
index e6c585e..0000000
--- a/locale/pl.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translation by mat9117
-
-[moreores] loaded. = [moreores] załadowano.
-
-%s Ore = %s Ruda
-%s Lump = %s Bryłka
-%s Ingot = %s Sztabka
-%s Block = %s Blok
-%s Pickaxe = %s Kilof
-%s Shovel = %s Łopatka
-%s Axe = %s Siekiera
-%s Sword = %s Miecz
-
-Copper = Miedź
-Tin = Cyna
-Bronze = BrÄ…z
-Silver = Srebro
-Gold = ZÅ‚oto
-Mithril = Mithril
-
-Copper Rail = Miedziany tor
diff --git a/locale/pt_br.txt b/locale/pt_br.txt
deleted file mode 100644
index ab84eeb..0000000
--- a/locale/pt_br.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Translation by github.com/caiorrs
-
-[moreores] loaded. = [moreores] carregado.
-
-%s Ore = Minério de %s
-%s Lump = Pepita de %s
-%s Ingot = Lingote de %s
-%s Block = Bloco de %s
-%s Pickaxe = Picareta de %s
-%s Shovel = Pá de %s
-%s Axe = Machado de %s
-%s Sword = Espada de %s
-
-Copper = Cobre
-Tin = Estanho
-Bronze = Bronze
-Silver = Prata
-Gold = Ouro
-Mithril = Mitrilo
-
-Copper Rail = Trilho de Cobre
diff --git a/locale/tr.txt b/locale/tr.txt
deleted file mode 100644
index 4f20286..0000000
--- a/locale/tr.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-# Translation by Mahmutelmas06
-# mahmutelmas06@hotmail.com
-# Türkçe Çeviri
-# Turkish translation
-# Language 2 letter iso code is "tr"
-
-[moreores] loaded. = [moreores] yüklendi.
-
-%s Ore = %s madeni
-%s Lump = %s yığını
-%s Ingot = %s külçesi
-%s Block = %s blok
-%s Pickaxe = %s kazma
-%s Shovel = %s kürek
-%s Axe = %s balta
-%s Sword = %s kılıç
-
-Copper = Bakır
-Tin = Kalay
-Bronze = Bronz
-Silver = Gümüş
-Gold = Altın
-Mithril = Mithril
-
-Copper Rail = Bakır ray
diff --git a/mod.conf b/mod.conf
index 928eefe..d4dc0c2 100644
--- a/mod.conf
+++ b/mod.conf
@@ -1,4 +1,4 @@
 name = moreores
 description = Adds new ore types.
 depends = default
-optional_depends = carts,farming,frame,intllib,mg,toolranks
+optional_depends = carts,farming,frame,mg,toolranks
-- 
GitLab