mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2025-06-28 12:56:01 +02:00
Split I18N stuff into its own submod.
This commit is contained in:
1
homedecor_i18n/depends.txt
Normal file
1
homedecor_i18n/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
intllib?
|
7
homedecor_i18n/init.lua
Normal file
7
homedecor_i18n/init.lua
Normal 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")
|
45
homedecor_i18n/intllib.lua
Normal file
45
homedecor_i18n/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
|
1666
homedecor_i18n/locale/de.po
Normal file
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
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
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
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
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
1535
homedecor_i18n/locale/pt.po
Normal file
File diff suppressed because it is too large
Load Diff
1325
homedecor_i18n/locale/template.pot
Normal file
1325
homedecor_i18n/locale/template.pot
Normal file
File diff suppressed because it is too large
Load Diff
20
homedecor_i18n/tools/updatepo.sh
Executable file
20
homedecor_i18n/tools/updatepo.sh
Executable 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
|
Reference in New Issue
Block a user