Split I18N stuff into its own submod.

This commit is contained in:
Diego Martínez
2017-01-29 20:12:02 -03:00
parent 010c07f23a
commit dc7b60c11f
36 changed files with 1694 additions and 435 deletions

View File

@ -0,0 +1 @@
intllib?

7
homedecor_i18n/init.lua Normal file
View File

@ -0,0 +1,7 @@
-- This file intentionally left blank.
homedecor_i18n = { }
local MP = minetest.get_modpath(minetest.get_current_modname())
homedecor_i18n.gettext, homedecor_i18n.ngettext = dofile(MP.."/intllib.lua")

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

1666
homedecor_i18n/locale/de.po Normal file

File diff suppressed because it is too large Load Diff

1333
homedecor_i18n/locale/es.po Normal file

File diff suppressed because it is too large Load Diff

1614
homedecor_i18n/locale/fr.po Normal file

File diff suppressed because it is too large Load Diff

1688
homedecor_i18n/locale/it.po Normal file

File diff suppressed because it is too large Load Diff

1688
homedecor_i18n/locale/ms.po Normal file

File diff suppressed because it is too large Load Diff

1535
homedecor_i18n/locale/pt.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
#! /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 \
--keyword=S \
--keyword=NS:1,2 \
--keyword=N_ \
-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