Change intllib for v5 minetest.get_translator

This commit is contained in:
Olivier Dragon 2020-08-30 23:47:57 -04:00 committed by Buckaroo Banzai
parent 979516c13d
commit 4dc9a81ec2
12 changed files with 11 additions and 61 deletions

View File

@ -4,7 +4,6 @@ unused_args = false
globals = {
"wieldview",
"armor",
"armor_i18n",
"inventory_plus"
}
@ -21,7 +20,6 @@ read_globals = {
"default",
"minetest",
"unified_inventory",
"intllib",
"wardrobe",
"player_monoids",
"armor_monoid",

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = armor.get_translator
local skin_previews = {}
local use_player_monoids = minetest.global_exists("player_monoids")

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = armor.get_translator
armor:register_armor("3d_armor:helmet_admin", {
description = S("Admin Helmet"),

View File

@ -5,4 +5,3 @@ pova?
fire?
ethereal?
bakedclay?
intllib?

View File

@ -5,14 +5,12 @@ local last_punch_time = {}
local pending_players = {}
local timer = 0
-- support for i18n
armor_i18n = { }
armor_i18n.gettext, armor_i18n.ngettext = dofile(modpath.."/intllib.lua")
-- local functions
local S = armor_i18n.gettext
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
armor.get_translator = S
dofile(modpath.."/api.lua")
-- integration test

View File

@ -1,45 +0,0 @@
-- 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

View File

@ -1,4 +1,4 @@
name = 3d_armor
depends = default
optional_depends = player_monoids, armor_monoid, pova, fire, ethereal, bakedclay, intllib
optional_depends = player_monoids, armor_monoid, pova, fire, ethereal, bakedclay
description = Adds craftable armor that is visible to other players.

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
if not minetest.global_exists("inventory_plus") then

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = minetest.get_translator(minetest.get_current_modname())
if not minetest.global_exists("sfinv") then
minetest.log("warning", S("3d_armor_sfinv: Mod loaded but unused."))

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = minetest.get_translator(minetest.get_current_modname())
local armor_stand_formspec = "size[8,7]" ..
default.gui_bg ..

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
local has_technic = minetest.get_modpath("technic") ~= nil

View File

@ -1,5 +1,5 @@
-- support for i18n
local S = armor_i18n.gettext
local S = minetest.get_translator(minetest.get_current_modname())
local disable_sounds = minetest.settings:get_bool("shields_disable_sounds")
local function play_sound_effect(player, name)