1
0
mirror of https://github.com/minetest-mods/intllib.git synced 2025-10-18 00:25:21 +02:00

Add Selected gettext

This commit is contained in:
BrunoMine
2017-07-13 14:11:08 -03:00
parent f7a8c24fa6
commit e5636432aa
9 changed files with 169 additions and 293 deletions

View File

@@ -1,7 +1,7 @@
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local S, NS, SS = dofile(MP.."/intllib.lua")
local use_count = 0
@@ -26,3 +26,8 @@ minetest.register_craftitem("intltest:test", {
minetest.chat_send_player(user:get_player_name(), message)
end,
})
minetest.log("action", "(nil)"..SS(nil, "Test: @1 @2", SS(nil, "Blue"), SS(nil, "Car")))
minetest.log("action", "(es) "..SS("es", "Test: @1 @2", SS("es", "Blue"), SS("es", "Car")))
minetest.log("action", "(pt) "..SS("pt", "Test: @1 @2", SS("pt", "Blue"), SS("pt", "Car")))
minetest.log("action", "(de) "..SS("de", "Test: @1 @2", SS("de", "Blue"), SS("de", "Car")))

View File

@@ -1,3 +1,47 @@
-- This file should be replaced by `intllib/lib/intllib.lua`.
return dofile(minetest.get_modpath("intllib").."/lib/intllib.lua")
-- 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, sgettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext, sgettext = 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
sgettext = sgettext or gettext
return gettext, ngettext, sgettext

45
intltest/locale/de.po Normal file
View File

@@ -0,0 +1,45 @@
# I18N Test Mod.
# Copyright (C) 2013-2017 Diego Martínez <kaeza@users.sf.net>
# This file is distributed under the same license as the intllib mod.
# Diego Martínez <kaeza@users.sf.net>, 2013-2017.
# Diego Martnez <kaeza@users.sf.net>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: I18N Test Mod 0.1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-25 20:40-0300\n"
"PO-Revision-Date: 2017-07-13 13:36-0300\n"
"Last-Translator: Diego Martnez <kaeza@users.sf.net>\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Gtranslator 2.91.7\n"
#: init.lua
msgid "Hello, world!"
msgstr "Hallo Welt!"
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Blue"
msgstr "Blau"
#: init.lua
msgid "Car"
msgstr "Auto"
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Test: @1 @2"
msgstr "Test: @2 @1"
#. Translators: @1 is use count.
#: init.lua
msgid "Item has been used @1 time."
msgid_plural "Item has been used @1 times."
msgstr[0] ""
msgstr[1] ""

45
intltest/locale/pt.po Normal file
View File

@@ -0,0 +1,45 @@
# I18N Test Mod.
# Copyright (C) 2013-2017 Diego Martínez <kaeza@users.sf.net>
# This file is distributed under the same license as the intllib mod.
# Diego Martínez <kaeza@users.sf.net>, 2013-2017.
# Diego Martnez <kaeza@users.sf.net>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: I18N Test Mod 0.1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-25 20:40-0300\n"
"PO-Revision-Date: 2017-07-13 13:35-0300\n"
"Last-Translator: Diego Martnez <kaeza@users.sf.net>\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Gtranslator 2.91.7\n"
#: init.lua
msgid "Hello, world!"
msgstr "Ola, mundo!"
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Blue"
msgstr "Azul"
#: init.lua
msgid "Car"
msgstr "Carro"
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Test: @1 @2"
msgstr "Teste: @2 @1"
#. Translators: @1 is use count.
#: init.lua
msgid "Item has been used @1 time."
msgid_plural "Item has been used @1 times."
msgstr[0] "Esse objeto foi usado @1 vez."
msgstr[1] "Esse objeto foi usado @2 vezes."