Use new intllib format strings

This commit is contained in:
Wuzzy 2016-11-09 01:55:18 +01:00
parent 700fd8b4a6
commit 608943de66
3 changed files with 8 additions and 9 deletions

@ -2,7 +2,7 @@ local S
if (minetest.get_modpath("intllib")) then
S = intllib.Getter()
else
S = function ( s ) return s end
S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
end
local inventory_icon = {}
@ -54,7 +54,7 @@ minetest.register_on_joinplayer(function(player)
offset = {x=-36,y=-20},
alignment = {x=0,y=0},
number = 0xFFFFFF,
text = string.format(S("%d/%d"), occupied, size)
text = S("@1/@2", occupied, size)
})
if mod_ui or mod_bags then
inventory_icon.hudids[name].bags = {}
@ -69,7 +69,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(S("%d/%d"), occupied, size)
text = S("@1/@2", 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
@ -115,7 +115,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(S("%d/%d"), occupied, size))
player:hud_change(hudids.main.text, "text", S("@1/@2", occupied, size))
if mod_ui or mod_bags then
local bags_inv = minetest.get_inventory({type = "detached", name = playername.."_bags"})
@ -129,7 +129,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(S("%d/%d"), occupied, size)
text = S("@1/@2", 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 +1 @@
%d/%d = %d/%d
@1/@2 = @1/@2

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