Pergi ke kandungan

Modul:list description

Daripada Wikikamus

local export = {}

function export.show(frame)
	local title = mw.title.getCurrentTitle()
	local rootpagename = title.rootText
	local isSubpage = title.isSubpage
	local subpagename = title.subpageText
	mw.log(rootpagename, isSubpage, subpagename)
	
	local lang, canonicalName
	if isSubpage then
		lang = require("Module:languages").getByCode(subpagename)
	end
	
	local listName, matches
	if rootpagename then
		listName, matches = mw.ustring.gsub(rootpagename, "senarai:", "")
	end
	
	local description
	local category = ""
	if lang then
		if matches == 1 then
			description =  "Berikut merupakan senarai " .. listName .. " pada bahasa " .. lang:getCanonicalName() .. "."
			if mw.ustring.match(listName, "tulisan Rumi") then
				category = "[[Kategori:Templat tulisan Rumi]]"
			end
		else
			description = "Berikut merupakan senarai dalam bahasa " .. lang:getCanonicalName() .. "."
		end
	end
	
	if description then
		return description .. category
	end
end

return export