Translator used per-string, not automatially due to client side implemenation

This commit is contained in:
Oversword
2021-04-03 12:55:30 +01:00
parent 5996ea1d43
commit 2fe554899b
3 changed files with 13 additions and 11 deletions

View File

@ -1,3 +1,4 @@
local S = minetest.get_translator("unified_inventory")
unified_inventory.registered_categories = {} unified_inventory.registered_categories = {}
unified_inventory.registered_category_items = {} unified_inventory.registered_category_items = {}
@ -7,13 +8,13 @@ function update_category_list()
local category_list = {} local category_list = {}
table.insert(category_list, { table.insert(category_list, {
name = "all", name = "all",
label = "All Items", label = S("All Items"),
symbol = "ui_category_all.png", symbol = "ui_category_all.png",
index = -2, index = -2,
}) })
table.insert(category_list, { table.insert(category_list, {
name = "uncategorized", name = "uncategorized",
label = "Misc. Items", label = S("Misc. Items"),
symbol = "ui_category_none.png", symbol = "ui_category_none.png",
index = -1, index = -1,
}) })

View File

@ -1,27 +1,28 @@
local S = minetest.get_translator("unified_inventory")
unified_inventory.register_category('plants', { unified_inventory.register_category('plants', {
symbol = "flowers:tulip", symbol = "flowers:tulip",
label = "Plant Life" label = S("Plant Life")
}) })
unified_inventory.register_category('building', { unified_inventory.register_category('building', {
symbol = "default:brick", symbol = "default:brick",
label = "Building Materials" label = S("Building Materials")
}) })
unified_inventory.register_category('tools', { unified_inventory.register_category('tools', {
symbol = "default:pick_diamond", symbol = "default:pick_diamond",
label = "Tools" label = S("Tools")
}) })
unified_inventory.register_category('minerals', { unified_inventory.register_category('minerals', {
symbol = "default:iron_lump", symbol = "default:iron_lump",
label = "Minerals and Metals" label = S("Minerals and Metals")
}) })
unified_inventory.register_category('environment', { unified_inventory.register_category('environment', {
symbol = "default:dirt_with_grass", symbol = "default:dirt_with_grass",
label = "Environment and Worldgen" label = S("Environment and Worldgen")
}) })
unified_inventory.register_category('lighting', { unified_inventory.register_category('lighting', {
symbol = "default:torch", symbol = "default:torch",
label = "Lighting" label = S("Lighting")
}) })

View File

@ -36,7 +36,7 @@ local function formspec_button(ui_peruser, name, image, offset, pos, scale, labe
(offset.x or offset[1]) + ( ui_peruser.btn_spc * (pos.x or pos[1]) ) + spc, (offset.x or offset[1]) + ( ui_peruser.btn_spc * (pos.x or pos[1]) ) + spc,
(offset.y or offset[2]) + ( ui_peruser.btn_spc * (pos.y or pos[2]) ) + spc, (offset.y or offset[2]) + ( ui_peruser.btn_spc * (pos.y or pos[2]) ) + spc,
size, size, image, name) .. size, size, image, name) ..
string.format("tooltip[%s;%s]", name, F(S(label or name))) string.format("tooltip[%s;%s]", name, F(label or name))
end end
function ui.get_formspec(player, page) function ui.get_formspec(player, page)
@ -157,12 +157,12 @@ function ui.get_formspec(player, page)
end end
if category_count > ui_peruser.pagecols and scroll_offset > 0 then if category_count > ui_peruser.pagecols and scroll_offset > 0 then
-- prev -- prev
formspec[n] = formspec_button(ui_peruser, "prev_category", "ui_left_icon.png", categories_scroll_pos, {ui_peruser.pagecols - 2, 0}, 0.8, "Scroll categories left") formspec[n] = formspec_button(ui_peruser, "prev_category", "ui_left_icon.png", categories_scroll_pos, {ui_peruser.pagecols - 2, 0}, 0.8, S("Scroll categories left"))
n = n + 1 n = n + 1
end end
if category_count > ui_peruser.pagecols and category_count - scroll_offset > ui_peruser.pagecols then if category_count > ui_peruser.pagecols and category_count - scroll_offset > ui_peruser.pagecols then
-- next -- next
formspec[n] = formspec_button(ui_peruser, "next_category", "ui_right_icon.png", categories_scroll_pos, {ui_peruser.pagecols - 1, 0}, 0.8, "Scroll categories right") formspec[n] = formspec_button(ui_peruser, "next_category", "ui_right_icon.png", categories_scroll_pos, {ui_peruser.pagecols - 1, 0}, 0.8, S("Scroll categories right"))
n = n + 1 n = n + 1
end end