mirror of
https://github.com/mt-mods/hangglider.git
synced 2025-06-30 07:20:53 +02:00
Add translation support and ca
, de
and es
translations (#18)
This commit is contained in:
committed by
GitHub
parent
8fc1f596d2
commit
3e304e3e5d
30
crafts.lua
30
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)
|
||||
|
Reference in New Issue
Block a user