Module:documentation/functions/zh dial or syn

From Wiktionary, the free dictionary
Jump to navigation Jump to search


return function(title, cats)
	local type_of_data, character = title.fullText:match("^Module:zh/data/dial%-(%l+)/(.+)$")
	if character then
		local what, where
		if type_of_data == "pron" then
			what = "the pronunciation"
			where = "dialects"
		elseif type_of_data == "syn" then
			what = "synonyms"
			where = "dialects and varieties"
		end
		
		if what then
			local link = require("Module:links").full_link{
				lang = require "Module:languages".getByCode("zh"),
				term = character:gsub("-[0-9]", ""),
			}
			local text = ("This module contains data on %s of %s in %s of Chinese.")
				:format(what, link, where)
			if type_of_data == "syn" then
				text = text .. "\n" .. mw.getCurrentFrame():expandTemplate{ title = 'zh-dial', args = { character } }
			end
			return text
		end
	end
end