模組:Documentation/functions/zh dial or syn

維基詞典,自由的多語言詞典


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 = "发音"
			where = "方言"
		elseif type_of_data == "syn" then
			what = "近义词"
			where = "方言与变体"
		end
		
		if what then
			local link = require("Module:links").full_link{
				lang = require "Module:languages".getByCode("zh"),
				term = character:gsub("-[0-9]", ""),
			}
			local text = ("本-{zh-hans:模块;zh-hant:模組}-包含%s在汉语各%s上的%s。")
				: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