Add intllib support

This commit is contained in:
Wuzzy 2016-09-01 20:27:21 +02:00
parent 59c822095b
commit c4f1ae3992
4 changed files with 18 additions and 4 deletions

@ -1,2 +1,3 @@
bags?
unified_inventory?
intllib?

@ -1,3 +1,11 @@
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
local inventory_icon = {}
inventory_icon.hudids = {}
@ -47,7 +55,7 @@ minetest.register_on_joinplayer(function(player)
offset = {x=-36,y=-20},
alignment = {x=0,y=0},
number = 0xFFFFFF,
text = string.format("%d/%d", occupied, size)
text = string.format(S("%d/%d"), occupied, size)
})
if mod_ui or mod_bags then
inventory_icon.hudids[name].bags = {}
@ -62,7 +70,7 @@ minetest.register_on_joinplayer(function(player)
else
scale = { x = 1, y = 1 }
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
text = string.format("%d/%d", occupied, size)
text = string.format(S("%d/%d"), occupied, size)
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
if occupied >= size then
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
@ -108,7 +116,7 @@ minetest.register_globalstep(function(dtime)
icon = "inventory_icon_backpack_free.png"
end
player:hud_change(hudids.main.icon, "text", icon)
player:hud_change(hudids.main.text, "text", string.format("%d/%d", occupied, size))
player:hud_change(hudids.main.text, "text", string.format(S("%d/%d"), occupied, size))
if mod_ui or mod_bags then
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
@ -122,7 +130,7 @@ minetest.register_globalstep(function(dtime)
else
scale = { x = 1, y = 1 }
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
text = string.format("%d/%d", occupied, size)
text = string.format(S("%d/%d"), occupied, size)
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
if occupied >= size then
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING

1
locale/de.txt Normal file

@ -0,0 +1 @@
%d/%d = %d/%d

4
locale/template.txt Normal file

@ -0,0 +1,4 @@
# Shows number of occupied (first number) vs number of total inventory slots (second number).
# “%d” is a placeholder which stands for a number.
# Try to keep the translation short.
%d/%d =