Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Commit

Permalink
Add i18n for health mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppy authored and jeremyshannon committed Apr 21, 2022
1 parent ae8fb2e commit bfeb148
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
5 changes: 4 additions & 1 deletion mods/health/food.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ over a fire.
#TODO: Test this ^^ after the cooking pot supports both tables
]]--

-- Internationalization
local S = HEALTH.S

dofile(minetest.get_modpath('health')..'/data_food.lua')

local function do_food_harm(user, nodename)
Expand Down Expand Up @@ -53,7 +56,7 @@ function exile_eatdrink(itemstack, user)
end
if not food_table[name] then
minetest.chat_send_player(user:get_player_name(),
"This is inedible.")
S("This is inedible."))
return
end
do_food_harm(user, name)
Expand Down
18 changes: 11 additions & 7 deletions mods/health/hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

----------------------------------------------------------------------
local hud = {}

-- Internationalization
local S = HEALTH.S

local hudupdateseconds = tonumber(minetest.settings:get("exile_hud_update"))
local overlaid = {}

Expand All @@ -25,7 +29,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.694, y = 0.925}, text = "Health:"
position = {x = 0.694, y = 0.925}, text = S("Health:")
})

hud_data.hp_hud = player:hud_add({
Expand All @@ -40,7 +44,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.44, y = 0.88}, text = "Energy:"
position = {x = 0.44, y = 0.88}, text = S("Energy:")
})

hud_data.energy_hud = player:hud_add({
Expand All @@ -55,7 +59,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.261, y = 0.925}, text = "Thirst:"
position = {x = 0.261, y = 0.925}, text = S("Thirst:")
})

hud_data.thirst_hud = player:hud_add({
Expand All @@ -69,7 +73,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.265, y = 0.97}, text = "Hunger:"
position = {x = 0.265, y = 0.97}, text = S("Hunger:")
})

hud_data.hunger_hud = player:hud_add({
Expand All @@ -83,7 +87,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.705, y = 0.97}, text = "Body Temp:"
position = {x = 0.705, y = 0.97}, text = S("Body Temp:")
})

hud_data.body_temp_hud = player:hud_add({
Expand All @@ -98,7 +102,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.351, y = 0.88}, text = "Temp:"
position = {x = 0.351, y = 0.88}, text = S("Temp:")
})

hud_data.enviro_temp_hud = player:hud_add({
Expand All @@ -113,7 +117,7 @@ local setup_hud = function(player)
alignment = "right",
hud_elem_type = "text",
number = col, offset = {x = 0, y = 0},
position = {x = 0.265, y = 0.88}, text = "Effects:"
position = {x = 0.265, y = 0.88}, text = S("Effects:")
})

hud_data.effects_hud = player:hud_add({
Expand Down
6 changes: 6 additions & 0 deletions mods/health/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Slow applies internal metabolism effects (here)

HEALTH = {}

-- Internationalization
HEALTH.S = minetest.get_translator("health")
HEALTH.FS = function(...)
return minetest.formspec_escape(HEALTH.S(...))
end

dofile(minetest.get_modpath('health')..'/health_effects.lua')
dofile(minetest.get_modpath('health')..'/on_actions.lua')
dofile(minetest.get_modpath('health')..'/hud.lua')
Expand Down
13 changes: 13 additions & 0 deletions mods/health/locale/template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# textdomain: health

# hud.lua
Health:=
Energy:=
Thirst:=
Hunger:=
Body Temp:=
Temp:=
Effects:=

# food.lua
This is inedible.=

0 comments on commit bfeb148

Please sign in to comment.