Modul:languages/memoize sortkeys

A modult a Modul:languages/memoize sortkeys/doc lapon tudod dokumentálni

local export = {}
local m_languages = require("Module:languages")

local title = mw.title.getCurrentTitle()

local pagename = title.subpageText
	:gsub("^Unsupported titles/(.*)", function(m)
		for title, page in pairs(require("Module:links/data").unsupported_titles) do
			if page == m then
				return title
			end
		end
		return m
	end)
	
local content = title:getContent()
local sc

for lang in content:gmatch("%f[^%z\n]==([^\n=]+)==%f[%z\n]") do
	lang = m_languages.getByCanonicalName(mw.text.trim(lang))
	sc = lang:findBestScript(pagename)
	table.insert(export, lang:getCode() .. sc:getCode() .. lang:makeSortKey(pagename, sc, true))
end
if not export.mul then
	local lang = m_languages.getByCode("mul")
	sc = lang:findBestScript(pagename)
	local mul_key = sc:getCode() .. lang:makeSortKey(pagename, sc, true)
	table.insert(export, "mul".. mul_key)
	table.insert(export, "und".. mul_key)
end

return {table.concat(export)}