mirror of
https://github.com/pyrollo/display_modpack.git
synced 2025-06-28 14:16:19 +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:
@ -2,3 +2,4 @@ default
|
||||
dye
|
||||
display_lib
|
||||
|
||||
intllib?
|
||||
|
@ -21,10 +21,11 @@
|
||||
ontime_clocks = {}
|
||||
ontime_clocks.path = minetest.get_modpath("ontime_clocks")
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
ontime_clocks.intllib = S
|
||||
|
||||
dofile(ontime_clocks.path.."/common.lua")
|
||||
dofile(ontime_clocks.path.."/nodes.lua")
|
||||
dofile(ontime_clocks.path.."/crafts.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
|
45
ontime_clocks/intllib.lua
Normal file
45
ontime_clocks/intllib.lua
Normal 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
|
43
ontime_clocks/locale/fr.po
Normal file
43
ontime_clocks/locale/fr.po
Normal file
@ -0,0 +1,43 @@
|
||||
# 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:20+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 "Green digital clock"
|
||||
msgstr "Horloge numérique verte"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Red digital clock"
|
||||
msgstr "Horloge numérique rouge"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "White clock"
|
||||
msgstr "Horloge blanche"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless clock"
|
||||
msgstr "Horloge sans cadre"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless gold clock"
|
||||
msgstr "Horloge dorée sans cadre"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless white clock"
|
||||
msgstr "Horloge blanche sans cadre"
|
42
ontime_clocks/locale/template.pot
Normal file
42
ontime_clocks/locale/template.pot
Normal file
@ -0,0 +1,42 @@
|
||||
# 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 "Green digital clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Red digital clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "White clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless gold clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless white clock"
|
||||
msgstr ""
|
@ -18,9 +18,11 @@
|
||||
along with ontime_clocks. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = ontime_clocks.intllib
|
||||
|
||||
-- Green digital clock
|
||||
minetest.register_node("ontime_clocks:green_digital", {
|
||||
description = "Green digital clock",
|
||||
description = S("Green digital clock"),
|
||||
inventory_image = "ontime_clocks_green_digital_inventory.png",
|
||||
wield_image = "ontime_clocks_green_digital_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -58,7 +60,7 @@ minetest.register_abm({
|
||||
|
||||
-- Red digital clock
|
||||
minetest.register_node("ontime_clocks:red_digital", {
|
||||
description = "Red digital clock",
|
||||
description = S("Red digital clock"),
|
||||
inventory_image = "ontime_clocks_red_digital_inventory.png",
|
||||
wield_image = "ontime_clocks_red_digital_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -96,7 +98,7 @@ minetest.register_abm({
|
||||
|
||||
|
||||
minetest.register_node("ontime_clocks:white", {
|
||||
description = "White clock",
|
||||
description = S("White clock"),
|
||||
inventory_image = "ontime_clocks_white_inventory.png",
|
||||
wield_image = "ontime_clocks_white_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -133,7 +135,7 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
minetest.register_node("ontime_clocks:frameless_black", {
|
||||
description = "Frameless clock",
|
||||
description = S("Frameless clock"),
|
||||
inventory_image = "ontime_clocks_frameless_inventory.png",
|
||||
wield_image = "ontime_clocks_frameless_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -170,7 +172,7 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
minetest.register_node("ontime_clocks:frameless_gold", {
|
||||
description = "Frameless gold clock",
|
||||
description = S("Frameless gold clock"),
|
||||
inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0",
|
||||
wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0",
|
||||
paramtype = "light",
|
||||
@ -207,7 +209,7 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
minetest.register_node("ontime_clocks:frameless_white", {
|
||||
description = "Frameless white clock",
|
||||
description = S("Frameless white clock"),
|
||||
inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
|
||||
wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
|
||||
paramtype = "light",
|
||||
|
25
ontime_clocks/tools/updatepo.sh
Executable file
25
ontime_clocks/tools/updatepo.sh
Executable 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
|
Reference in New Issue
Block a user