diff --git a/.luacheckrc b/.luacheckrc index 1502aa3..74dfefb 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,5 +1,6 @@ globals = { "areas", + "hangglider", } read_globals = { diff --git a/crafts.lua b/crafts.lua index 379ee8a..b3b7274 100644 --- a/crafts.lua +++ b/crafts.lua @@ -1,4 +1,6 @@ +local S = hangglider.translator + local has_unifieddyes = minetest.get_modpath("unifieddyes") local dye_colors = { @@ -19,6 +21,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 @@ -35,15 +55,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 end @@ -51,7 +69,7 @@ end -- This recipe is just a placeholder do local item = ItemStack("hangglider:hangglider") - item:get_meta():set_string("description", "Colored Glider") + item:get_meta():set_string("description", S("Colored Glider")) minetest.register_craft({ output = item:to_string(), recipe = {"hangglider:hangglider", "group:dye"}, @@ -85,7 +103,7 @@ minetest.register_on_craft(function(crafted_item, _, old_craft_grid) return ItemStack({name = "hangglider:hangglider", wear = wear}) end local meta = crafted_item:get_meta() - meta:set_string("description", color_name.." Glider") + meta:set_string("description", S("@1 Glider", color_name)) meta:set_string("inventory_image", "hangglider_item.png^(hangglider_color.png^[multiply:#"..color..")") meta:set_string("hangglider_color", color) crafted_item:set_wear(wear) diff --git a/init.lua b/init.lua index 3953e5d..25c8d8f 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,9 @@ +hangglider = { + translator = minetest.get_translator('hangglider'), +} +local S = hangglider.translator + local has_player_monoids = minetest.get_modpath("player_monoids") local has_areas = minetest.get_modpath("areas") @@ -7,29 +12,31 @@ local enable_flak = has_areas and minetest.settings:get_bool("hangglider.enable_ local flak_warning_time = tonumber(minetest.settings:get("hangglider.flak_warning_time")) or 2 local hangglider_uses = tonumber(minetest.settings:get("hangglider.uses")) or 250 -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) local hanggliding_players = {} local hud_overlay_ids = {} if enable_flak 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 is @2.", id, + open and S("closed") or S("opened")) end }) end @@ -236,7 +243,7 @@ minetest.register_entity("hangglider:glider", { }) minetest.register_tool("hangglider:hangglider", { - description = "Glider", + description = S("Glider"), inventory_image = "hangglider_item.png", sound = {breaks = "default_tool_breaks"}, on_use = hangglider_use, diff --git a/locale/hangglider.ca.tr b/locale/hangglider.ca.tr new file mode 100644 index 0000000..a718172 --- /dev/null +++ b/locale/hangglider.ca.tr @@ -0,0 +1,28 @@ +# textdomain: hangglider +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 +Colored Glider=Planador de color +@1 Glider=Planador @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 is @2.=L'àrea @1 espai aeri és @2. +closed=tancat +opened=obert +Glider=Planador + diff --git a/locale/hangglider.de.tr b/locale/hangglider.de.tr new file mode 100644 index 0000000..e64c474 --- /dev/null +++ b/locale/hangglider.de.tr @@ -0,0 +1,28 @@ +# textdomain: hangglider +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 +Colored Glider=Farbiger Gleitschirm +@1 Glider=@1 Gleitschirm +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 is @2.=Gebiet @1 Luftraum ist @2. +closed=eingeschränkt +opened=geöffnet +Glider=Gleitschirm + diff --git a/locale/hangglider.es.tr b/locale/hangglider.es.tr new file mode 100644 index 0000000..a01fab4 --- /dev/null +++ b/locale/hangglider.es.tr @@ -0,0 +1,28 @@ +# textdomain: hangglider +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 +Colored Glider=Planeador Colorizado +@1 Glider=Planeador @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 is @2.=Área @1 espacio aéreo está @2. +closed=cerrado +opened=abierto +Glider=Planeador + diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..5c8962d --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,28 @@ +# textdomain: hangglider +White= +Grey= +Dark_grey= +Black= +Violet= +Blue= +Cyan= +Dark_green= +Green= +Yellow= +Brown= +Orange= +Red= +Magenta= +Pink= +Colored Glider= +@1 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 is @2.= +closed= +opened= +Glider= +