Module:list description

Wiktionary වෙතින්
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

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, "list:", "")
	end
	
	local description
	local category = ""
	if lang then
		if matches == 1 then
			description =  "මෙය " .. lang:getCanonicalName() .. " භාෂාව තුළ භාවිතා වන, " .. listName .. " ලැයිස්තුවක් වේ."
			if mw.ustring.match(listName, "Latin script") or mw.ustring.match(listName, "ලතින් අක්ෂරක්‍රමය") then
				category = "[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය පිළිබඳ සැකිලි]]"
			end
		else
			description = "මෙය " .. lang:getCanonicalName() .. " භාෂාව හා සබැඳි ලැයිස්තුවක් වේ."
		end
	end
	
	if description then
		return description .. category
	end
end

return export
"https://si.wiktionary.org/w/index.php?title=Module:list_description&oldid=34398" වෙතින් සම්ප්‍රවේශනය කෙරිණි