模組:Documentation/functions/zh data

return function (title, cats)
	local output = require("Module:array")()
	
	local function zh_link(word)
		return require("Module:links").full_link{
			lang = require "Module:languages".getByCode("zh"),
			term = word
		}
	end
	
	local zh_data_subpage, lang_code, reconstruction, last_segment =
		mw.ustring.match(title.fullText,
			"^Module:Zh/data/((%l%l%l)%-pron%-?([^/]-))/(.+)$")
	if zh_data_subpage == "ltc-pron" or zh_data_subpage == "och-pron-BS"
			or zh_data_subpage == "och-pron-ZS" then
		--require('Module:zh-track').track_data_module(title.fullText)
		
		local lang = require "Module:languages".getByCode(lang_code)
		
		local characters, extra
		-- Last segment is either a Han character or three hexadecimal digits
		-- (the first three digits of the code point).
		if mw.ustring.len(last_segment) == 1 then
			characters = zh_link(last_segment)
			extra = ""
		else
			local code_point_prefix = last_segment
			local function make_code_point(digit)
				return tonumber(code_point_prefix .. (digit):rep(6 - #code_point_prefix), 16)
			end
			characters = (("在Unicode範圍U+%04X–U+%04X內的字符"):format(
				make_code_point("0"), make_code_point("F")))
			
			extra = "僅為測試,無實際使用。其"
		end
		output:insert(('本-{zh-hans:模块;zh-hant:模組}-%s包含%s的發音-{zh-hans:数据;zh-hant:資料}-')
			:format(extra, characters))
		
		local see_also_link
		if reconstruction == "BS" then
			see_also_link = 'Wiktionary:原始藏漢語專題#白一平-加沙爾重構(2014年)'
		elseif reconstruction == "ZS" then
			see_also_link = 'Wiktionary:原始藏漢語專題#鄭張尚芳重構(2003年)'
		else
			reconstruction = nil
		end
		
		local lang_link = lang:makeCategoryLink()
		if reconstruction then
			output:insert((",由%s為%s重構而來。")
				:format((reconstruction == "BS" and "白一平-加沙爾" or "鄭張尚芳"), lang_link))
		else
			output:insert((",使用於%s中。"):format(lang_link))
		end
		
		if see_also_link then
			output:insert("詳情參見" .. require("Module:links").section_link(see_also_link)
				.. "。")
		end
		
		return output:concat("") .. "\n\n如果您發現錯誤,煩請在[[WT:TR|茶室]]發表編輯請求。"
	end
end