From 172a4e127c72c60c8be63b747e05fb6c04d1e5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Tue, 24 Jan 2017 00:40:48 -0300 Subject: [PATCH] Add minimal example mod. --- intltest/README.md | 10 +++++++++ intltest/depends.txt | 1 + intltest/init.lua | 28 ++++++++++++++++++++++++ intltest/intllib.lua | 3 +++ intltest/locale/es.po | 40 +++++++++++++++++++++++++++++++++++ intltest/locale/template.pot | 41 ++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+) create mode 100644 intltest/README.md create mode 100644 intltest/depends.txt create mode 100644 intltest/init.lua create mode 100644 intltest/intllib.lua create mode 100644 intltest/locale/es.po create mode 100644 intltest/locale/template.pot diff --git a/intltest/README.md b/intltest/README.md new file mode 100644 index 0000000..9122d9e --- /dev/null +++ b/intltest/README.md @@ -0,0 +1,10 @@ + +# Intllib example + +This is a simple mod showing how to use intllib. + +It defines a test `intltest:test` item whose description is translated +according to the user's language. + +Additionally, it demonstrates how to use plural forms by counting the +number of times the item has been used. diff --git a/intltest/depends.txt b/intltest/depends.txt new file mode 100644 index 0000000..77e8d97 --- /dev/null +++ b/intltest/depends.txt @@ -0,0 +1 @@ +intllib? diff --git a/intltest/init.lua b/intltest/init.lua new file mode 100644 index 0000000..e855621 --- /dev/null +++ b/intltest/init.lua @@ -0,0 +1,28 @@ + +-- Load support for intllib. +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") + +local use_count = 0 + +minetest.log("action", S("Hello, world!")) + +minetest.register_craftitem("intltest:test", { + -- Example use of replacements. + -- Translators: @1 is color, @2 is object. + description = S("Test: @1 @2", S("Blue"), S("Car")), + + inventory_image = "default_sand.png", + + on_use = function(stack, user, pt) + use_count = use_count + 1 + -- Example use of `ngettext` function. + -- First `use_count` is `n` for ngettext; + -- Second one is actual replacement. + -- Translators: @1 is use count. + local message = NS("Item has been used @1 time.", + "Item has been used @1 times.", + use_count, use_count) + minetest.chat_send_player(user:get_player_name(), message) + end, +}) diff --git a/intltest/intllib.lua b/intltest/intllib.lua new file mode 100644 index 0000000..c2eb8dc --- /dev/null +++ b/intltest/intllib.lua @@ -0,0 +1,3 @@ + +-- This file should be replaced by `intllib/lib/intllib.lua`. +return dofile(minetest.get_modpath("intllib").."/lib/intllib.lua") diff --git a/intltest/locale/es.po b/intltest/locale/es.po new file mode 100644 index 0000000..4638ff9 --- /dev/null +++ b/intltest/locale/es.po @@ -0,0 +1,40 @@ +# I18N Test Mod. +# Copyright (C) 2013-2017 Diego Martínez +# This file is distributed under the same license as the intllib mod. +# Diego Martínez , 2013-2017. +# +msgid "" +msgstr "" +"Project-Id-Version: I18N Test Mod 0.1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-24 00:46-0300\n" +"PO-Revision-Date: 2017-01-23 17:36-0300\n" +"Last-Translator: Diego Martnez \n" +"Language-Team: Spanish\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: init.lua:8 +msgid "Hello, world!" +msgstr "¡Hola, mundo!" + +#: init.lua:13 +msgid "Blue" +msgstr "Azul" + +#: init.lua:13 +msgid "Car" +msgstr "Carro" + +#: init.lua:13 +msgid "Test: @1 @2" +msgstr "Prueba: @2 @1" + +#: init.lua:23 +msgid "Item has been used @1 time." +msgid_plural "Item has been used @1 times." +msgstr[0] "El objeto ha sido usado @1 vez." +msgstr[1] "El objeto ha sido usado @1 veces." diff --git a/intltest/locale/template.pot b/intltest/locale/template.pot new file mode 100644 index 0000000..39a9cbd --- /dev/null +++ b/intltest/locale/template.pot @@ -0,0 +1,41 @@ +# 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. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-24 00:46-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + +#: init.lua:8 +msgid "Hello, world!" +msgstr "" + +#: init.lua:13 +msgid "Blue" +msgstr "" + +#: init.lua:13 +msgid "Car" +msgstr "" + +#: init.lua:13 +msgid "Test: @1 @2" +msgstr "" + +#: init.lua:23 +msgid "Item has been used @1 time." +msgid_plural "Item has been used @1 times." +msgstr[0] "" +msgstr[1] ""