Modul:pendokumenan/functions/number list

return function (title, cats)
	local suffix = title.fullText:match("^Module:number list/data/(.+)$")
	local lang_code = suffix:match "^([^/]+)/sandbox$" or suffix
	local lang = require("Module:languages").getByCode(lang_code)
	
	local function page_exists(title)
		local success, title_obj = pcall(mw.title.new, title)
		return success and title_obj.exists
	end
	
	if lang then
		local canonical_name = lang:getCanonicalName()
		local language_data_modules = "Modul data " .. canonical_name
		
		cats:insert((page_exists("Kategori:" .. language_data_modules)
			and language_data_modules or "Modul bahasa " .. canonical_name)
			.. "|number list")
		cats:insert("Number data modules|" .. canonical_name)
		
		return ("This module contains data on various types of numbers in %s.\n%s")
			:format(lang:makeCategoryLink(), require("Module:number list/show").table() or '')
	end
end