Module:a

د ويکيسيند لخوا
Jump to navigation Jump to search

Documentation for this module may be created at Module:a/لاسوند

local export = {}

function export.show(frame)
	data = require("Module:a/data")
	local args = frame:getParent().args
	if not args[1] or args[1] == "" then
		if mw.title.getCurrentTitle().nsText == "Template" then
			return '<span class="ib-brac"><span class="qualifier-brac">(</span></span><span class="ib-content"><span class="qualifier-content">{{{1}}}</span></span><span class="ib-brac"><span class="qualifier-brac">)</span></span>'
		else
			error("No accents specified.", 2)
			return
		end
	end
	
	local accents = {}
	
	for i,j in ipairs(args) do
		if j then 
			local accent = mw.text.trim(j)
			if accent == "" then
				--ignore
			elseif data[accent] then
				if data[accent].link then
					table.insert(accents, "[[w:" .. data[accent].link .. "|" .. (data[accent].display or data[accent].link) .. "]]")
				elseif data[accent].display then
					table.insert(accents, data[accent].display)
				end
			else
				table.insert(accents, accent)
			end
		end
	end
	
	local output = table.concat(accents, ", ")
	if output == "" then
		error("No accents specified.", 2)
		return
	else
		return
			'<span class="ib-brac"><span class="qualifier-brac">(</span></span><span class="ib-content"><span class="qualifier-content">' ..
			output .. '</span></span><span class="ib-brac"><span class="qualifier-brac">)</span></span>'
	end
end

return export