Module:translit-redirect/templates
Appearance
Documentation for this module may be created at Module:translit-redirect/templates/doc
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 ("[[:Category:%s|%s]] (<code>%s</code>)")
:format(lang:getCategoryName(), canonical_name, lang:getCode())
or ("[[:Category:%s|%s]] (<code>%s</code>) [[Category:%s modules|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