Module:translit-redirect/templates

Wiktionary වෙතින්

local export = {}

local getByCode = require("Module:languages").getByCode

local langs = {}
setmetatable(langs, { -- Auto-create language objects: langs.en -> language object for English.
	__index = function(self, key)
		local lang = getByCode(key) or error("No language with code " .. key .. ".")
		self[key] = lang
		return lang
	end
})

function export.documentation(frame)
	local data = mw.loadData "Module:translit-redirect/data"
	local documentation_page = mw.title.getCurrentTitle().subpageText == "documentation"
	
	local output = {}
	for lang_code in pairs(data) do
		local lang = langs[lang_code]
		local canonical_name = lang:getCanonicalName()
		table.insert(output, 
			documentation_page and ("[[:ප්‍රවර්ගය:%s|%s]] (<code>%s</code>)")
					:format(lang:getCategoryName(), canonical_name, lang:getCode())
			or ("[[:ප්‍රවර්ගය:%s|%s]] (<code>%s</code>) [[ප්‍රවර්ගය:%s මොඩියුල|transliteration]]")
				:format(lang:getCategoryName(), canonical_name, lang:getCode(), canonical_name))
	end
	
	-- Sort by canonical name.
	table.sort(
		output,
		function (label1, label2)
			return label1:match("|([^%]]+)") < label2:match("|([^%]]+)")
		end)
	
	return "Languages whose transliteration is handled by this module: "
		.. table.concat(output, ", ") .. "."
end

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