Module:Crh: Difference between revisions

Content deleted Content added
Created Crimean Tatar language module for {{crh}}
 
added custom label param
 
(4 intermediate revisions by the same user not shown)
Line 4:
 
-- Errors
local error_msg = {
}
 
local err_category = {
['crh'] = '[[Category:crh template errors]]'
Line 17 ⟶ 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 24 ⟶ 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 53 ⟶ 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
-- table.insert(parts, "[[Latin alphabet|Latin]]: ''" .. latinTextlabel .. "'':")
-- elseif lead and not labelOnlylabel and linkisFalse(label) then
-- do return end
table.insert(parts, "Latin: ''" .. latinText .. "''")
-- elseif lead and link then
else
-- table.insert(partsoutput, "''"[[Crimean ..Tatar latinTextlanguage|Crimean ..Tatar]]: "''")
-- elseif lead and not link then
end
-- table.insert(output, "Crimean Tatar: ")
-- end
 
if latinText then
if cyrillicText and not labelOnly and link then
local spannedLatin = "<span title=\"Crimean Tatar-language text\" lang=\"crh-Latn\">" .. latinText .. "</span>"
table.insert(parts, "[[Cyrillic script|Cyrillic]]: " .. cyrillicText)
elseifif cyrillicTextlead and not labelOnly and not link then
table.insert(parts, "Cyrillic[[Latin alphabet|Latin]]: ''" .. cyrillicTextspannedLatin .. "''")
elseif cyrillicTextlead and not labelOnly and link then
table.insert(parts, cyrillicText"Latin: ''" .. spannedLatin .. "''")
endelse
table.insert(parts, "Latin: ''" .. latinTextspannedLatin .. "''")
end
end
 
if arabicText and not labelOnly and linkcyrillicText then
local spannedCyrillic = "<span title=\"Crimean Tatar-language text\" lang=\"crh-Cyrl\">" .. cyrillicText .. "</span>"
table.insert(parts, "[[Arabic script|Arabic]]: " .. arabicText)
elseif arabicText andif not labelOnly and not link then
table.insert(parts, "Arabic[[Cyrillic script|Cyrillic]]: " .. arabicTextspannedCyrillic)
elseif arabicTextcyrillicText and not labelOnly and not link then
table.insert(parts, arabicText"Cyrillic: " .. spannedCyrillic)
elseif cyrillicText and labelOnly then
end
table.insert(parts, spannedCyrillic)
end
end
if arabicText then
local spannedArabic = "<span title=\"Crimean Tatar-language text\" lang=\"crh-Arab\" dir=\"rtl\">" .. arabicText .. "</span>"
 
if cyrillicText and not labelOnly and link then
table.insert(parts, "[[CyrillicArabic script|CyrillicArabic]]: " .. cyrillicTextspannedArabic)
elseif not labelOnly and not link then
table.insert(parts, "[[Arabic script|Arabic]]: " .. arabicTextspannedArabic)
elseif labelOnly then
table.insert(parts, spannedArabic)
end
end
 
if literalTranslation and link then