Skip to content

Commit

Permalink
add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
SwissalpS committed Apr 22, 2024
1 parent 836d8eb commit ee660bd
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 29 deletions.
30 changes: 24 additions & 6 deletions crafts.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

local S = deltaglider.translator

local has_basic_materials = minetest.get_modpath("basic_materials")
local has_farming = minetest.get_modpath("farming")
local has_pipeworks = minetest.get_modpath("pipeworks")
Expand All @@ -24,6 +26,24 @@ local dye_colors = {
pink = "ff7f9f",
}

local translated_colors = {
white = S("white"),
grey = S("grey"),
dark_grey = S("dark_grey"),
black = S("black"),
violet = S("violet"),
blue = S("blue"),
cyan = S("cyan"),
dark_green = S("dark_green"),
green = S("green"),
yellow = S("yellow"),
brown = S("brown"),
orange = S("orange"),
red = S("red"),
magenta = S("magenta"),
pink = S("pink"),
}

local function get_dye_color(name)
local color
if has_unifieddyes then
Expand All @@ -40,15 +60,13 @@ end

local function get_color_name(name)
name = string.gsub(name, "^dye:", "")
name = string.gsub(name, "_", " ")
name = string.gsub(name, "(%l)(%w*)", function(a, b) return string.upper(a) .. b end)
return name
return translated_colors[name]
end

local function get_color_name_from_color(color)
for name, color_hex in pairs(dye_colors) do
if color == color_hex then
return name
return translated_colors[name]
end
end

Expand All @@ -58,7 +76,7 @@ end
-- This recipe is just a placeholder
do
local item = ItemStack("deltaglider:glider")
item:get_meta():set_string("description", "Coloured Delta Glider")
item:get_meta():set_string("description", S("Coloured Delta Glider"))
minetest.register_craft({
output = item:to_string(),
recipe = { "deltaglider:glider", "group:dye" },
Expand Down Expand Up @@ -93,7 +111,7 @@ minetest.register_on_craft(function(crafted_item, _, old_craft_grid)
end

local meta = crafted_item:get_meta()
meta:set_string("description", color_name .. " Delta Glider")
meta:set_string("description", S("@1 Delta Glider", color_name))
meta:set_string("inventory_image",
"deltaglider_glider.png^(deltaglider_glider_color.png^[multiply:#"
.. color .. ")")
Expand Down
47 changes: 25 additions & 22 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ local vector_zero = vector.zero
-- global table for exposed functions
deltaglider = {
version = 20240419.161300,
translator = minetest.get_translator('deltaglider'),
}
local S = deltaglider.translator

local has_areas = minetest.get_modpath("areas")
local has_hangglider = minetest.get_modpath("hangglider")
Expand Down Expand Up @@ -74,39 +76,39 @@ deltaglider.allow_hangglider_while_gliding = minetest.settings:get_bool(
deltaglider.allow_while_hanggliding = minetest.settings:get_bool(
"deltaglider.allow_while_hanggliding", false)

local flak_warning = "You have entered restricted airspace!\n"
.. "You will be shot down in " .. flak_warning_time
.. " seconds by anti-aircraft guns!"
local flak_warning = S("You have entered restricted airspace!@n"
.. "You will be shot down in @1"
.. " seconds by anti-aircraft guns!", flak_warning_time)

-- only register chatcommand if [hangglider] isn't available
if enable_flak and not has_hangglider then
minetest.register_chatcommand("area_flak", {
params = "<ID>",
description = "Toggle airspace restrictions for area <ID>",
params = S("<ID>"),
description = S("Toggle airspace restrictions for area <ID>"),
func = function(name, param)
local id = tonumber(param)
if not id then
return false, "Invalid usage, see /help area_flak."
return false, S("Invalid usage, see /help area_flak.")
end

if not areas:isAreaOwner(id, name) then
return false, "Area " .. id
.. " does not exist or is not owned by you."
return false, S("Area @1 does not exist or"
.. " is not owned by you.", id)
end

local open = not areas.areas[id].flak
-- Save false as nil to avoid inflating the DB.
areas.areas[id].flak = open or nil
areas:save()
return true, "Area " .. id .. " airspace "
.. (open and "closed" or "opened")
return true, S("Area @1 airspace @2", id,
open and S("closed") or S("opened"))
end
})
end

minetest.register_chatcommand("deltagliderToggleHUD", {
params = "",
description = "Toggle delta-glider HUD",
description = S("Toggle delta-glider HUD"),
func = function(name)
local meta = minetest.get_player_by_name(name):get_meta()
-- think: deltaglider.HUDdisabled
Expand Down Expand Up @@ -277,14 +279,15 @@ local function update_hud(name, player, rot, rocket_time, speed, vV)
local heading = math_floor((yaw * rad2deg) + 0.5)
local climb = string.format("%.1f", math_abs(vV))
local sign = 0 == vV and "=" or (0 < vV and "+" or "-")
info = "Pitch: " .. pitch .. "°"
.. " Heading: " .. heading .. "°"
info = S("Pitch") .. ": " .. pitch .. "°"
.. " " .. S("Heading") .. ": " .. heading .. "°"
.. "\n"
.. "Lift: " .. sign .. climb
.. " Altitude: " .. math_floor(player:get_pos().y + 0.5)
.. " Speed: " .. math_floor(speed + 0.5)
.. S("Lift") .. ": " .. sign .. climb
.. " " .. S("Altitude") .. ": "
.. math_floor(player:get_pos().y + 0.5)
.. " " .. S("Speed") .. ": " .. math_floor(speed + 0.5)
.. (0 < rocket_time
and ("\nCooldown: "
and ("\n" .. S("Cooldown") .. ": "
.. math_floor(rocket_time + 0.5) .. "s") or "")
end

Expand Down Expand Up @@ -637,8 +640,8 @@ local function on_place(_, player)

minetest.chat_send_player(player:get_player_name(),
pro
and "Normal up/down activated (pro pilot)."
or "Inverted up/down activated (novice).")
and S("Normal up/down activated (pro pilot).")
or S("Inverted up/down activated (novice)."))

elseif mouse_controls and keyboard_controls
and keys.sneak
Expand All @@ -650,8 +653,8 @@ local function on_place(_, player)

minetest.chat_send_player(player:get_player_name(),
key_c
and "Keyboard controls activated."
or "Mouse controls activated.")
and S("Keyboard controls activated.")
or S("Mouse controls activated."))
end
end

Expand All @@ -672,7 +675,7 @@ minetest.register_entity("deltaglider:hangglider", {
})

minetest.register_tool("deltaglider:glider", {
description = "Delta Glider",
description = S("Delta Glider"),
inventory_image = "deltaglider_glider.png",
on_use = on_use,
on_secondary_use = on_place,
Expand Down
40 changes: 40 additions & 0 deletions locale/deltaglider.ca.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# textdomain: deltaglider
white=blanc
grey=gris
dark_grey=gris fosc
black=negre
violet=violeta
blue=blau
cyan=cian
dark_green=verd fosc
green=verd
yellow=groc
brown=marró
orange=taronja
red=vermell
magenta=magenta
pink=rosa
Coloured Delta Glider=Planador delta de color
@1 Delta Glider=Planador delta @1
You have entered restricted airspace!@@You will be shot down in @1 seconds by anti-aircraft guns!=Has entrat a l'espai aeri restringit!@@Seràs abatut en @1 segons per canons antiaeris!
<ID>=
Toggle airspace restrictions for area <ID>=Activa o desactiva les restriccions d'espai aeri per a l'àrea <ID>.
Invalid usage, see /help area_flak.=Ús no vàlid, consulta /help area_flak.
Area @1 does not exist or is not owned by you.=L'àrea @1 no existeix o no és propietat teva.
Area @1 airspace @2=L'àrea @1 espai aeri és @2.
closed=tancat
opened=obert
Toggle delta-glider HUD=Alterna HUD del planador delta.
Pitch=Inclinació
Heading=Rumb
Lift=Elevació
Altitude=Altitud
Speed=Velocitat
Cooldown=Temps d'espera
Normal up/down activated (pro pilot).=Amunt/avall normal activat (pilot professional).
Inverted up/down activated (novice).=Amunt/avall invertit activat (novice).
Keyboard controls activated.=Els controls del teclat s'han activat.
Mouse controls activated.=Els controls del ratolí s'han activat.
Delta Glider=Planador Delta
Rocket (Use while gliding to boost delta glider speed)=Coet (Utilitzar-lo per augmentar la velocitat del planador delta.)

1 change: 1 addition & 0 deletions locale/deltaglider.de.tr
40 changes: 40 additions & 0 deletions locale/deltaglider.de_CH.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# textdomain: deltaglider
white=Weisser
grey=Grauer
dark_grey=Dunkelgrauer
black=Schwarzer
violet=Violeter
blue=Blauer
cyan=Cyan farbener
dark_green=Dunkelgrüner
green=Grüner
yellow=Gelber
brown=Brauner
orange=Orange farbener
red=Roter
magenta=Magenta farbener
pink=Rosa
Coloured Delta Glider=Farbiger Deltasegler
@1 Delta Glider=@1 Deltasegler
You have entered restricted airspace!@@You will be shot down in @1 seconds by anti-aircraft guns!=Du bist in eingeschränktem Luftraum eingedrungen!@nDu wirst in @1 Sekunden von FLAK abgeschossen.
<ID>=
Toggle airspace restrictions for area <ID>=Luftraumbeschränkungen für Gebiet <ID> umschalten.
Invalid usage, see /help area_flak.=Ungültige Verwendung, siehe /help area_flak.=
Area @1 does not exist or is not owned by you.=Gebiet @1 existiert nicht oder es gehört dir nicht.
Area @1 airspace @2=Gebiet @1 Luftraum ist @2.
closed=eingeschränkt
opened=geöffnet
Toggle delta-glider HUD=Deltasegler HUD ein-/ausschalten.
Pitch=Neigung
Heading=Richtung
Lift=Steigung
Altitude=Höhe
Speed=Geschwindigkeit
Cooldown=Abklingzeit
Normal up/down activated (pro pilot).=Normales auf/ab aktiviert (Pro-Pilot).
Inverted up/down activated (novice).=Invertiertes auf/ab aktiviert (Anfänger).
Keyboard controls activated.=Tastatursteuerung aktiviert.
Mouse controls activated.=Maussteuerung aktiviert.
Delta Glider=Deltasegler
Rocket (Use while gliding to boost delta glider speed)=Rakete (Verwenden um die Geschwindigkeit des Deltaseglers zu erhöhen.)

1 change: 1 addition & 0 deletions locale/deltaglider.en.tr
41 changes: 41 additions & 0 deletions locale/deltaglider.en_AU.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# textdomain: deltaglider
# Tounge-in-cheek Aussie translation.
white=Bog Standard
grey=Gray
dark_grey=Dark-Gray
black=Black
violet=Violet
blue=Blue
cyan=Cyan
dark_green=Dark-Green
green=Green
yellow=Yellow
brown=Brown
orange=Orange
red=Red
magenta=Magenta
pink=Pink
Coloured Delta Glider=Coloured Delta-Glider
@1 Delta Glider=@1 Delta-Glider
You have entered restricted airspace!@@You will be shot down in @1 seconds by anti-aircraft guns!=Rack off ya bloody galah!@nAnti-aircraft guns'll turn ya cactus in @1 secs!
<ID>=
Toggle airspace restrictions for area <ID>=Toggle airspace restrictions for area <ID>.
Invalid usage, see /help area_flak.=Mate, try /help area_flak.
Area @1 does not exist or is not owned by you.=Area @1 doesn't exist or isn't yours.
Area @1 airspace @2=Aight, area @1 airspace is fair dinkum @2, mate.
closed=
opened=
Toggle delta-glider HUD=Toggle delta-glider's HUD.
Pitch=
Heading=
Lift=
Altitude=
Speed=
Cooldown=Cool-down
Normal up/down activated (pro pilot).=Normal up/down activated (bush-pilot).
Inverted up/down activated (novice).=Inverted up/down activated (joey).
Keyboard controls activated.=Keyboard controls activated mate.
Mouse controls activated.=Mouse controls activated cobber.
Delta Glider=Delta-Glider
Rocket (Use while gliding to boost delta glider speed)=Rocket (Use to keep up with emus.)

40 changes: 40 additions & 0 deletions locale/deltaglider.en_US.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# textdomain: deltaglider
white=White
grey=Grey
dark_grey=Dark Grey
black=Black
violet=Violet
blue=Blue
cyan=Cyan
dark_green=Dark Green
green=Green
yellow=Yellow
brown=Brown
orange=Orange
red=Red
magenta=Magenta
pink=Pink
Coloured Delta Glider=Colored Delta Glider
@1 Delta Glider=
You have entered restricted airspace!@@You will be shot down in @1 seconds by anti-aircraft guns!
<ID>=
Toggle airspace restrictions for area <ID>=Toggle airspace restrictions for area <ID>.
Invalid usage, see /help area_flak.=
Area @1 does not exist or is not owned by you.=
Area @1 airspace @2=Area @1 airspace is @2.
closed=
opened=
Toggle delta-glider HUD=Toggle delta glider's HUD.
Pitch=
Heading=
Lift=
Altitude=
Speed=Velocity
Cooldown=Cool Down
Normal up/down activated (pro pilot).=
Inverted up/down activated (novice).=Inverted up/down activated (rookie).
Keyboard controls activated.=
Mouse controls activated.=
Delta Glider=
Rocket (Use while gliding to boost delta glider speed)=Rocket (Use while gliding to boost delta glider speed.)

40 changes: 40 additions & 0 deletions locale/deltaglider.es.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# textdomain: deltaglider
white=blanco
grey=gris
dark_grey=gris oscuro
black=negro
violet=violeta
blue=azul
cyan=cian
dark_green=verde oscuro
green=verde
yellow=amarillo
brown=marrón
orange=naranja
red=rojo
magenta=magenta
pink=rosa
Coloured Delta Glider=Planeador Delta Colorizado
@1 Delta Glider=Planeador delta @1
You have entered restricted airspace!@@You will be shot down in @1 seconds by anti-aircraft guns!=¡Has entrado en espacio aéreo restringido!@n¡Serás derribado en @1 segundos por cañones antiaéreos!
<ID>=
Toggle airspace restrictions for area <ID>=Alternar restricciones de espacio aéreo para el área <ID>
Invalid usage, see /help area_flak.=Uso no válido, consulta /help area_flak.
Area @1 does not exist or is not owned by you.=El área @1 no existe o no es tuya.
Area @1 airspace @2=Área @1 espacio aéreo está @2.
closed=cerrado
opened=abierto
Toggle delta-glider HUD=Alternar HUD del planeador delta
Pitch=Inclinación
Heading=Rumbo
Lift=Elevación
Altitude=Altitud
Speed=Velocidad
Cooldown=Tiempo de reutilización
Normal up/down activated (pro pilot).=Arriba/abajo normal activado (piloto pro).
Inverted up/down activated (novice).=Arriba/abajo invertido activado (novato).
Keyboard controls activated.=Controles de teclado activados.
Mouse controls activated.=Controles del ratón activados.
Delta Glider=Planeador Delta
Rocket (Use while gliding to boost delta glider speed)=Cohete (Úsalo mientras planeas para aumentar la velocidad del planeador delta.)

Loading

0 comments on commit ee660bd

Please sign in to comment.