Module:Crh: Difference between revisions

Content deleted Content added
HTML `lang` and `title`
added custom label param
 
(One intermediate revision by the same user not shown)
Line 13:
 
-- Helper function to parse boolean parameters
local function isFalse(value)
if value == "no" or value == "n" or value == "false" or value == "0" or value == "off" or value == "none" then
return true
else
return false
end
end
 
local function parseBoolean(value, default)
if value == nil then
Line 20 ⟶ 28:
if value == "yes" or value == "y" or value == "true" or value == "1" or value == "on" then
return true
elseif isFalse(value == "no" or value == "n" or value == "false" or value == "0" or value == "off") then
return false
end
Line 49 ⟶ 57:
local link = parseBoolean(args["link"], true)
local lead = parseBoolean(args["lead"], true)
local label = args["label"]
local labelOnly = parseBoolean(args["label-only"], true)
if not latinText or latinText == "" then
return errorMessage("Latin text required")
end
 
local output = {}
local parts = {}
 
if lead and linklabel then
if not isFalse(label) then
table.insert(output, "[[Crimean Tatar language|Crimean Tatar]]: ")
table.insert(output, "Crimeanlabel Tatar.. ": ")
elseif lead and not link then
else
table.insert(output, "Crimean Tatar: ")
end
elseif lead then
if link then
table.insert(output, "[[Crimean Tatar language|Crimean Tatar]]: ")
else
table.insert(output, "Crimean Tatar: ")
end
end
 
-- if leadlabel and not labelOnly and linkisFalse(label) then
local spannedLatin = "<span title=\"Crimean Tatar-language text\" lang=\"crh-Latn\">" .. latinText .. "</span>"
-- table.insert(parts, "''" .. spannedLatinlabel .. "'':")
if lead and not labelOnly and link then
-- elseif label and isFalse(label) then
table.insert(parts, "[[Latin alphabet|Latin]]: ''" .. spannedLatin .. "''")
-- do return end
elseif lead and not labelOnly and link then
-- elseif lead and link then
table.insert(parts, "Latin: ''" .. spannedLatin .. "''")
-- table.insert(output, "[[Crimean Tatar language|Crimean Tatar]]: ")
else
-- elseif lead and not link then
table.insert(parts, "''" .. spannedLatin .. "''")
-- table.insert(output, "Crimean Tatar: ")
end
-- end
 
if latinText then
local spannedLatin = "<span title=\"Crimean Tatar-language text\" lang=\"crh-Latn\">" .. latinText .. "</span>"
if lead and not labelOnly and link then
table.insert(parts, "[[Latin alphabet|Latin]]: ''" .. spannedLatin .. "''")
elseif lead and not labelOnly and link then
table.insert(parts, "Latin: ''" .. spannedLatin .. "''")
else
table.insert(parts, "''" .. spannedLatin .. "''")
end
end
 
if cyrillicText then