mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Gettext and plural support for client-side translations (#14726)
--------- Co-authored-by: Ekdohibs <nathanael.courant@laposte.net> Co-authored-by: y5nw <y5nw@protonmail.com> Co-authored-by: rubenwardy <rw@rubenwardy.com>
This commit is contained in:
parent
dbbe0ca065
commit
e3aa79cffb
28 changed files with 1360 additions and 74 deletions
26
games/devtest/mods/testtranslations/init.lua
Normal file
26
games/devtest/mods/testtranslations/init.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
local S, NS = minetest.get_translator("testtranslations")
|
||||
|
||||
local function send_compare(name, text)
|
||||
core.chat_send_player(name, ("%s | %s | %s"):format(
|
||||
core.get_translated_string("", text), text, core.get_translated_string("fr", text)))
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("testtranslations", {
|
||||
params = "",
|
||||
description = "Test translations",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Please ensure your locale is set to \"fr\"")
|
||||
core.chat_send_player(name, "Untranslated | Client-side translation | Server-side translation (fr)")
|
||||
send_compare(name, S("Testing .tr files: untranslated"))
|
||||
send_compare(name, S("Testing .po files: untranslated"))
|
||||
send_compare(name, S("Testing .mo files: untranslated"))
|
||||
send_compare(name, S("Testing fuzzy .po entry: untranslated (expected)"))
|
||||
send_compare(name, core.translate("translation_po", "Testing .po without context: untranslated"))
|
||||
send_compare(name, core.translate("translation_mo", "Testing .mo without context: untranslated"))
|
||||
for i = 0,4 do
|
||||
send_compare(name, NS("@1: .po singular", "@1: .po plural", i, tostring(i)))
|
||||
send_compare(name, NS("@1: .mo singular", "@1: .mo plural", i, tostring(i)))
|
||||
end
|
||||
end
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue