Springe nei ynhâld

Module:labels/analysis

Ut Wikiwurdboek
local export = {}

local m_labeldata = mw.loadData("Module:labels/data")

function export.printConflicts(frame)
	local replacements = m_labeldata.replacements
	
	local output = {"; labels:"}
	
	local labels = {}
	
	for label, data in pairs(replacements.labels) do
		local lang, langCode
		if data.languages then
			langCode = data.languages[1]
			lang = require("Module:languages").getByCode(langCode)
		end
		
		local canonicalName
		if lang then
			canonicalName = lang.getCanonicalName()
		end
		
		table.insert(labels, label)
		
		if langCode or canonicalName then
			table.insert(output, " (")
		end
		
		if langCode then
			table.insert(output, "<code>" .. langCode .. "</code>")
		end
		
		if canonicalName then
			if langCode then
				table.insert(output, ", ")
			end
			
			table.insert(output, canonicalName)
		end
		
		if langCode or canonicalName then
			table.insert(output, ")")
		end
	end
	
	table.sort(labels)
	
	for _, label in ipairs(labels) do
		table.insert(output, "\n* " .. label)
	end
	
	return table.concat(output)
end

return export