Add translation support and `ca`, `de` and `es` translations (#18)

This commit is contained in:
Luke aka SwissalpS 2024-04-25 06:23:20 +02:00 committed by GitHub
parent 8fc1f596d2
commit 3e304e3e5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 152 additions and 14 deletions

View File

@ -1,5 +1,6 @@
globals = {
"areas",
"hangglider",
}
read_globals = {

View File

@ -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)

View File

@ -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 = "<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 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,

28
locale/hangglider.ca.tr Normal file
View File

@ -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!
<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 is @2.=L'àrea @1 espai aeri és @2.
closed=tancat
opened=obert
Glider=Planador

28
locale/hangglider.de.tr Normal file
View File

@ -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.
<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 is @2.=Gebiet @1 Luftraum ist @2.
closed=eingeschränkt
opened=geöffnet
Glider=Gleitschirm

28
locale/hangglider.es.tr Normal file
View File

@ -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!
<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 is @2.=Área @1 espacio aéreo está @2.
closed=cerrado
opened=abierto
Glider=Planeador

28
locale/template.txt Normal file
View File

@ -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!=
<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 is @2.=
closed=
opened=
Glider=