diff --git a/crafts.lua b/crafts.lua index e726e7a..47984a1 100644 --- a/crafts.lua +++ b/crafts.lua @@ -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") @@ -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 @@ -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 @@ -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" }, @@ -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 .. ")") diff --git a/init.lua b/init.lua index 420c058..8890373 100644 --- a/init.lua +++ b/init.lua @@ -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") @@ -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 = "", - description = "Toggle airspace restrictions for area ", + params = S(""), + description = S("Toggle airspace restrictions for area "), 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 @@ -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 @@ -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 @@ -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 @@ -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, diff --git a/locale/deltaglider.ca.tr b/locale/deltaglider.ca.tr new file mode 100644 index 0000000..dfd550a --- /dev/null +++ b/locale/deltaglider.ca.tr @@ -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! += +Toggle airspace restrictions for area =Activa o desactiva les restriccions d'espai aeri per a l'àrea . +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.) + diff --git a/locale/deltaglider.de.tr b/locale/deltaglider.de.tr new file mode 120000 index 0000000..9e1424f --- /dev/null +++ b/locale/deltaglider.de.tr @@ -0,0 +1 @@ +deltaglider.de_CH.tr \ No newline at end of file diff --git a/locale/deltaglider.de_CH.tr b/locale/deltaglider.de_CH.tr new file mode 100644 index 0000000..2cb910a --- /dev/null +++ b/locale/deltaglider.de_CH.tr @@ -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. += +Toggle airspace restrictions for area =Luftraumbeschränkungen für Gebiet 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.) + diff --git a/locale/deltaglider.en.tr b/locale/deltaglider.en.tr new file mode 120000 index 0000000..ece39df --- /dev/null +++ b/locale/deltaglider.en.tr @@ -0,0 +1 @@ +deltaglider.en_US.tr \ No newline at end of file diff --git a/locale/deltaglider.en_AU.tr b/locale/deltaglider.en_AU.tr new file mode 100644 index 0000000..1575faa --- /dev/null +++ b/locale/deltaglider.en_AU.tr @@ -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! += +Toggle airspace restrictions for area =Toggle airspace restrictions for area . +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.) + diff --git a/locale/deltaglider.en_US.tr b/locale/deltaglider.en_US.tr new file mode 100644 index 0000000..67e19aa --- /dev/null +++ b/locale/deltaglider.en_US.tr @@ -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! += +Toggle airspace restrictions for area =Toggle airspace restrictions for area . +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.) + diff --git a/locale/deltaglider.es.tr b/locale/deltaglider.es.tr new file mode 100644 index 0000000..a805a48 --- /dev/null +++ b/locale/deltaglider.es.tr @@ -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! += +Toggle airspace restrictions for area =Alternar restricciones de espacio aéreo para el área +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.) + diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..ae36338 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,41 @@ +# textdomain: deltaglider +white= +grey= +dark_grey= +black= +violet= +blue= +cyan= +dark_green= +green= +yellow= +brown= +orange= +red= +magenta= +pink= +Coloured Delta Glider= +@1 Delta Glider= + +You have entered restricted airspace!@@You will be shot down in @1 seconds by anti-aircraft guns!= + += +Toggle airspace restrictions for area = +Invalid usage, see /help area_flak.= +Area @1 does not exist or is not owned by you.= +Area @1 airspace @2= +closed= +opened= +Toggle delta-glider HUD= +Pitch= +Heading= +Lift= +Altitude= +Speed= +Cooldown= +Normal up/down activated (pro pilot).= +Inverted up/down activated (novice).= +Keyboard controls activated.= +Mouse controls activated.= +Delta Glider= +Rocket (Use while gliding to boost delta glider speed)= diff --git a/rocket.lua b/rocket.lua index e68ebd8..457f305 100644 --- a/rocket.lua +++ b/rocket.lua @@ -1,7 +1,8 @@ +local S = deltaglider.translator local rocket_cooldown = deltaglider.rocket_cooldown minetest.register_craftitem("deltaglider:rocket", { - description = "Rocket (Use while gliding to boost delta glider speed)", + description = S("Rocket (Use while gliding to boost delta glider speed)"), inventory_image = "deltaglider_rocket.png", on_use = function(itemstack, player) local attach = player:get_attach()