1
0
mirror of https://github.com/pyrollo/display_modpack.git synced 2025-06-28 06:12:01 +02:00

add intllib support (i18n)

-> mods ontime_clocks, signs, signs_roads & steles

add french translations
add updatepo.sh script to update po/pot files
add specific array for full description of steles
This commit is contained in:
fat115
2017-08-05 10:12:43 +02:00
parent 54108e8054
commit 2fef15d878
30 changed files with 715 additions and 50 deletions

View File

@ -3,3 +3,4 @@ dye
display_lib
font_lib
signs
intllib?

View File

@ -22,10 +22,10 @@
signs_road = {}
signs_road.path = minetest.get_modpath("signs_road")
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
signs_road.intllib = S
dofile(signs_road.path.."/nodes.lua")
dofile(signs_road.path.."/crafts.lua")

45
signs_road/intllib.lua Normal file
View File

@ -0,0 +1,45 @@
-- 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

35
signs_road/locale/fr.po Normal file
View File

@ -0,0 +1,35 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-08-05 09:50+0200\n"
"PO-Revision-Date: 2017-05-08 06:40+0200\n"
"Last-Translator: Peppy <peppy@twang-factory.com>\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"
#: nodes.lua
msgid "Blue street sign"
msgstr "Plaque de rue bleue"
#: nodes.lua
msgid "Green street sign"
msgstr "Plaque de rue verte"
#: nodes.lua
msgid "Black direction sign"
msgstr "Panneau indicateur noir"
#: nodes.lua
msgid "Green direction sign"
msgstr "Panneau indicateur vert"

View File

@ -0,0 +1,34 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-08-05 09:50+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: nodes.lua
msgid "Blue street sign"
msgstr ""
#: nodes.lua
msgid "Green street sign"
msgstr ""
#: nodes.lua
msgid "Black direction sign"
msgstr ""
#: nodes.lua
msgid "Green direction sign"
msgstr ""

View File

@ -19,6 +19,8 @@
along with signs_road. If not, see <http://www.gnu.org/licenses/>.
--]]
local S = signs_road.intllib
local models = {
blue_street={
depth = 1/16,
@ -30,7 +32,7 @@ local models = {
color="#fff",
},
node_fields = {
description="Blue street sign",
description=S("Blue street sign"),
tiles={"signs_blue_street.png"},
inventory_image="signs_blue_street_inventory.png",
},
@ -45,7 +47,7 @@ local models = {
color="#fff",
},
node_fields = {
description="Green street sign",
description=S("Green street sign"),
tiles={"signs_green_street.png"},
inventory_image="signs_green_street_inventory.png",
},
@ -60,7 +62,7 @@ local models = {
color="#000",
},
node_fields = {
description="Black direction sign",
description=S("Black direction sign"),
tiles={"signs_black_right.png"},
inventory_image="signs_black_inventory.png",
on_place=signs.on_place_direction,
@ -77,7 +79,7 @@ local models = {
color="#000",
},
node_fields = {
description="Black direction sign",
description=S("Black direction sign"),
tiles={"signs_black_left.png"},
inventory_image="signs_black_inventory.png",
groups={not_in_creative_inventory=1},
@ -97,7 +99,7 @@ local models = {
color="#fff",
},
node_fields = {
description="Green direction sign",
description=S("Green direction sign"),
tiles={"signs_green_direction.png"},
inventory_image="signs_green_dir_inventory.png",
on_place=signs.on_place_direction,
@ -125,7 +127,7 @@ local models = {
color="#fff",
},
node_fields = {
description="Green direction sign",
description=S("Green direction sign"),
tiles={"signs_green_direction.png"},
inventory_image="signs_green_dir_inventory.png",
on_place=signs.on_place_direction,

25
signs_road/tools/updatepo.sh Executable file
View File

@ -0,0 +1,25 @@
#! /bin/bash
# To create a new translation:
# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot
cd "$(dirname "${BASH_SOURCE[0]}")/..";
# Extract translatable strings.
xgettext --from-code=UTF-8 \
--language=Lua \
--sort-by-file \
--keyword=S \
--keyword=NS:1,2 \
--keyword=N_ \
--keyword=F \
--add-comments='Translators:' \
--add-location=file \
-o locale/template.pot \
$(find . -name '*.lua')
# Update translations.
find locale -name '*.po' | while read -r file; do
echo $file
msgmerge --update $file locale/template.pot;
done