mirror of
https://repo.or.cz/minetest_inventory_icon.git
synced 2024-12-04 12:53:47 +01:00
Add intllib support
This commit is contained in:
parent
59c822095b
commit
c4f1ae3992
@ -1,2 +1,3 @@
|
|||||||
bags?
|
bags?
|
||||||
unified_inventory?
|
unified_inventory?
|
||||||
|
intllib?
|
||||||
|
16
init.lua
16
init.lua
@ -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 = {}
|
local inventory_icon = {}
|
||||||
inventory_icon.hudids = {}
|
inventory_icon.hudids = {}
|
||||||
|
|
||||||
@ -47,7 +55,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
offset = {x=-36,y=-20},
|
offset = {x=-36,y=-20},
|
||||||
alignment = {x=0,y=0},
|
alignment = {x=0,y=0},
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
text = string.format("%d/%d", occupied, size)
|
text = string.format(S("%d/%d"), occupied, size)
|
||||||
})
|
})
|
||||||
if mod_ui or mod_bags then
|
if mod_ui or mod_bags then
|
||||||
inventory_icon.hudids[name].bags = {}
|
inventory_icon.hudids[name].bags = {}
|
||||||
@ -62,7 +70,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
else
|
else
|
||||||
scale = { x = 1, y = 1 }
|
scale = { x = 1, y = 1 }
|
||||||
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
|
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)
|
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
|
||||||
if occupied >= size then
|
if occupied >= size then
|
||||||
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
|
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
|
||||||
@ -108,7 +116,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
icon = "inventory_icon_backpack_free.png"
|
icon = "inventory_icon_backpack_free.png"
|
||||||
end
|
end
|
||||||
player:hud_change(hudids.main.icon, "text", icon)
|
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
|
if mod_ui or mod_bags then
|
||||||
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
|
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
|
||||||
@ -122,7 +130,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
else
|
else
|
||||||
scale = { x = 1, y = 1 }
|
scale = { x = 1, y = 1 }
|
||||||
local occupied, size = inventory_icon.get_inventory_state(player:get_inventory(), "bag"..i.."contents")
|
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)
|
icon = inventory_icon.replace_icon(minetest.registered_items[bag:get_name()].inventory_image)
|
||||||
if occupied >= size then
|
if occupied >= size then
|
||||||
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
|
icon = icon .. "^" .. inventory_icon.COLORIZE_STRING
|
||||||
|
1
locale/de.txt
Normal file
1
locale/de.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
%d/%d = %d/%d
|
4
locale/template.txt
Normal file
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 =
|
Loading…
Reference in New Issue
Block a user