Difference between revisions 3433 and 10926 on mnwwiktionary

local export = {}

-- it is either here, or in [[Module:ugly hacks]], and it is not in ugly hacks.
function export.CONTENTMODEL()
	return mw.title.getCurrentTitle().contentModel
end

local skins = {
(contracted; show full)		= title.fullText:match("^Module:Unicode data/([^/]+)/(%x%x%x)$")
	if subpage == "names" or subpage == "images" then
		local low, high =
			tonumber(first_three_of_code_point .. "000", 16),
			tonumber(first_three_of_code_point .. "FFF", 16)
		return string.format(
			"This data module contains the %s of " ..
			"[[Appendix:
Unicodeယူနဳကုဒ်|Unicode]] code points within the range U+%04X to U+%04X.",
			subpage == "images" and "titles of images" or "names",
			low, high)
	end
end

-- This provides categories and documentation for various data modules, so that
-- [[Category:Uncategorized modulesမဝ်ဂျူဟွံမွဲကဏ္ဍဂမၠိုင်]] isn’t unnecessarily cluttered.
-- It is a list of tables, each of which have three possible fields:

-- The “regex” field is required. It is a Lua pattern to match the module’s
-- title. If it matches, the data will be used. If the pattern contains one
-- capture, and a category has been specified, the capture will be used as a
-- sortkey.

-- The “doc” field is required. This may be a function or a
-- string. If it is a function, it receives a title and an array (see
-- [[Module:array]]) of categories that will be added to the documentation as
-- its first and second arguments, and may return a string, which will be used
-- as documentation. If it is a string, it is the name of a submodule under
-- “Module:documentation/functions/” which returns a function, of the same type
-- as described above.

-- The “cat” field is optional. It is a category in which the module should be
-- placed. The inner part of the category link is generated as follows:
-- mw.ustring.gsub(full_title, cat_field)
-- So if the “cat” field is present, the “regex” field should match the whole
-- title, and if there is “|%1” at the end of the “cat” field, for a sortkey,
-- there should be one capture in the “regex” field.
local module_regex = {
	{
		regex = "^Module:languages/.+$",
		cat = "Modules dealing with languages and scriptsမဝ်ဂျူမဆေင်ကဵုအက္ခရ်အရေဝ်ဘာသာဂမၠိုင်",
	},
	{
		regex = "^Module:scripts/.+$",
		cat = "Modules dealing with languages and scriptsမဝ်ဂျူမဆေင်ကဵုအက္ခရ်အရေဝ်ဘာသာဂမၠိုင်",
	},
	{
		regex = "^Module:data tables/data..?.?.?$",
		cat = "Reference module sharded data tablesစရင်မဝ်ဂျူဒေတာနိဿဲဂမၠိုင်",
	},
	{
		regex = "^Module:Quotations/...?.?.?.?.?.?$",
		cat = "Quotation data modules",
	},
	{
		regex = "^Module:zh/data/dial%-pron/.+$",
		cat = "Chinese dialectal pronunciation data modulesမဝ်ဂျူဒေတာဗွဟ်ရမ္သာင်ကြုက်အဒေါဝ်ဂမၠိုင်",
		doc = "zh dial or syn",
	},
	{
		regex = "^Module:zh/data/dial%-syn/.+$",
		cat = "Chinese dialectal synonyms data modulesမဝ်ဂျူဒေတာပ္ၚံက်အဓိပ္ပါဲဝေါဟာကြုက်ဂမၠိုင်",
		doc = "zh dial or syn",
	},
	{
		regex = "^Module:zh/data/glyph%-data/.+$",
		cat = "Chinese historical character forms data modulesမဝ်ဂျူဒေတာဗီုနာမူနာဝင်ဗျဥ်အက္ခရ်ကြုက်ဂမၠိုင်",
		doc = function(title, cats)
			local character = title.fullText:match("^Module:zh/data/glyph%-data/(.+)")
			if character then
				return ("This module contains data on historical forms of the Chinese character %s.")
					:format(zh_link(character))
			end
		end,
	},
	{
		regex = "^Module:zh/data/ltc%-pron/(.+)$",
		cat = "Middle Chinese pronunciation data modulesမဝ်ဂျူဒေတာဗွဟ်ရမ္သာင်ကြုက်အဒေါဝ်ဂမၠိုင်|%1",
		doc = "zh data",
	},
	{
		regex = "^Module:zh/data/och%-pron%-BS/(.+)$",
		cat = "Old Chinese (Baxter-Sagart) pronunciation data modulesမဝ်ဂျူဒေတာဗွဟ်ရမ္သာင်(Baxter-Sagart)ကြုက်တြေံဂမၠိုင်|%1",
		doc = "zh data",
	},
	{
		regex = "^Module:zh/data/och%-pron%-ZS/(.+)$",
		cat = "Old Chinese (Zhengzhang) pronunciation data modules|%1",
		doc = "zh data",
	},
(contracted; show full)			"^#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]]-)%]%]"))
	end

	output:insert("<dl class=\"plainlinks\" style=\"font-size: smaller;\">")
	if doc_title.exists then
		output:insert(
			"<dd><i style=\"font-size: larger;\">The following " ..
			"[[Help:
Documenting templates and modulesစရင်ထာမ်ပလိက်ကဵုမဝ်ဂျူဂမၠိုင်|documentation]] is located at [[" ..
			doc_title.fullText .. "]]. " ..
			"<sup>[[" .. doc_title:fullUrl { action = 'edit' } .. " edit]]</sup> </i></dd>")
	else
		if contentModel == "Scribunto" then
			local automatic_cat
			if user_name then
				fallback_docs = 'documentation/fallback/user module'
(contracted; show full)
				"generated by [[" .. (doc_content_module or "Module:documentation") .. "]]. <sup>[[" ..
				mw.title.new("Module:documentation"):fullUrl { action = 'edit' } ..
				" edit]]</sup> </i></dd>")
		elseif not nodoc then
			output:insert(
				"<dd><i style=\"font-size: larger;\">This " .. pagetype ..
				" lacks a [[Help:
Documenting templates and modulesစရင်ထာမ်ပလိက်ကဵုမဝ်ဂျူဂမၠိုင်|documentation subpage]]. " ..
				(fallback_docs and "You may " or "Please ") ..
				"[" .. doc_title:fullUrl { action = 'edit', preload = preload }
				.. " create it].</i></dd>\n")
		end
	end
	
	if title.fullText:match("^MediaWiki:Gadget%-") then
(contracted; show full)		
		if user_name then
			links:insert("[[User:" .. user_name .. "|user page]]")
			links:insert("[[User talk:" .. user_name .. "|user talk page]]")
			links:insert("[[Special:PrefixIndex/User:" .. user_name .. "/|userspace]]")
		else
			-- If sandbox module, add a link to the module that this is a sandbox of.
			-- Exclude user sandbox modules like [[User:
Dine2016咽頭べさ/sandbox]].
			if title.text:find("/sandbox%d*%f[/%z]") then
				cats:insert("Sandbox modules")
				
				-- Sandbox modules don’t really need documentation.
				needs_doc = false
				
				-- Will behave badly if “/sandbox” occurs twice in title!
(contracted; show full)		:map(languageObjects[1].makeCategoryLink)
		:serial_comma_join()
	
	return "It is " .. ( codeInPagenameInList and "also" or "" ) ..
		" used to transliterate " .. langs .. "." .. categories:concat()
end

return export