From 83fb1227de392fb30e2bbeebd0e025daf7584487 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Tue, 3 Aug 2021 15:29:43 -0700 Subject: [PATCH] Add localization support --- TODO.txt | 1 - api.lua | 4 +++- changelog.txt | 4 ++++ items.lua | 4 +++- locale/template.txt | 7 +++++++ mod.conf | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 locale/template.txt diff --git a/TODO.txt b/TODO.txt index 0842f6d..1f688c9 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,3 @@ TODO: -- add localization support - add Spanish translation diff --git a/api.lua b/api.lua index 75d2386..d405487 100644 --- a/api.lua +++ b/api.lua @@ -29,6 +29,8 @@ -- @module api.lua +local S = core.get_translator(asm.modname) + local registered_eggs = {} --- Retrieves egg that spawns specified entity. @@ -75,7 +77,7 @@ local function formatTitle(s) table.insert(t, v) end - return table.concat(t, " ") .. " Spawn Egg" + return S("@1 Spawn Egg", table.concat(t, " ")) end --- Registers new egg in game. diff --git a/changelog.txt b/changelog.txt index 5029c01..1072732 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,17 +3,21 @@ v1.2 ---- - added method to retrieve registered egg by entity name - added optional field "title" for EggDef +- added localization support + v1.1 ---- - egg names are titleized & underscores are replaced with space + v1.0 ---- - made independent of any other mods or games - renamed to "asm_spawneggs" (Another Spawneggs Mod) - added API reference + v0.1 ---- - created mod for Antum game diff --git a/items.lua b/items.lua index 2c20c6a..8ac8b32 100644 --- a/items.lua +++ b/items.lua @@ -25,7 +25,9 @@ --]] +local S = core.get_translator(asm.modname) + core.register_craftitem(":spawneggs:egg", { - description = "Spawn Egg", + description = S("Spawn Egg"), inventory_image = "spawneggs_egg.png", }) diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..6efddc9 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,7 @@ +# textdomain:asm_spawneggs + +# Translators: + + +Spawn Egg= +@1 Spawn Egg= diff --git a/mod.conf b/mod.conf index f91effe..5a9c2de 100644 --- a/mod.conf +++ b/mod.conf @@ -4,4 +4,4 @@ author = AntumDeluge description = Spawneggs for adding entities to game. license = MIT version = 1.1 -min_minetest_version = 0.4 +min_minetest_version = 5.0