diff --git a/init.lua b/init.lua index 75138c1..5d8618e 100644 --- a/init.lua +++ b/init.lua @@ -23,7 +23,11 @@ minetest.register_globalstep(function(dtime) -- This will run every tick, so aro if lookat then if player_to_cnode[player] ~= lookat.name then -- Only do anything if they are looking at a different type of block than before player_to_animtime[player] = nil -- Reset the animation - local nodename, mod = describe_node(lookat) -- Get the details of the block in a nice looking way + local locale = core.get_player_information(player:get_player_name())["lang_code"] + if locale == nil then + locale = 'en' + end + local nodename, mod = describe_node(lookat, locale) -- Get the details of the block in a nice looking way player:hud_change(player_to_id_text[player], "text", nodename) -- If they are looking at something, display that player:hud_change(player_to_id_mtext[player], "text", mod) local node_object = minetest.registered_nodes[lookat.name] -- Get information about the block @@ -109,13 +113,13 @@ function get_looking_node(player) -- Return the node the given player is looking return lookat end -function describe_node(node) -- Return a string that describes the node and mod +function describe_node(node, locale) -- Return a string that describes the node and mod local mod, nodename = minetest.registered_nodes[node.name].mod_origin, minetest.registered_nodes[node.name].description -- Get basic (not pretty) info if nodename == "" then -- If it doesn't have a proper name, just use the technical one nodename = node.name end mod = remove_unneeded(capitalize(mod)) -- Make it look good - nodename = remove_unneeded(capitalize(nodename)) + nodename = remove_unneeded(capitalize(core.get_translated_string(locale, nodename))) return nodename, mod end @@ -124,7 +128,7 @@ function remove_unneeded(str) -- Remove characters like '-' and '_' to make the end function capitalize(str) -- Capitalize every word in a string, looks good for node names - return string.gsub(" "..str, "%W%l", string.upper):sub(2) + return string.gsub(" "..str, " %W%l", string.upper):sub(2) end function handle_tiles(node) -- Return an image of the tile