Mô đun:zh-glyph/display-phonetic

Từ điển mở Wiktionary
local export = {}
local m_phonetic = mw.loadData("Module:zh-glyph/phonetic")
local m_och = require("Module:och-pron").retrieve_pron

function export.show(frame)
	local phonekeys = {}
	for k in pairs(m_phonetic) do table.insert(phonekeys, k) end
	table.sort(phonekeys)
	local result = { "Bảng dưới đây liệt kê tất cả chuỗi ngữ âm của [[tiếng Hán thượng cổ]] theo [[Wiktionary:Tiếng Trung Quốc/Tham khảo|Zhengzhang (2003)]].\n==Danh sách==" }
	if mw.ustring.match(mw.title.getCurrentTitle().text, "2$") then
		i, j = 529, 1056
		other = "← [[Wiktionary:Tiếng Trung Quốc/Chuỗi ngữ âm|Trang trước]]"
	else
		i, j = 1, 528
		other = "→ [[Wiktionary:Tiếng Trung Quốc/Chuỗi ngữ âm 2|Trang sau]]"
	end
	table.insert(result, "\n'''''<center>" .. other .. "</center>'''''")
	table.insert(result, "\n{| class=\"Hani\" style=\"font-size:150%; border:1px solid #aaa\" cellpadding=\"10\"")
	k = 1
	for _, base in ipairs(phonekeys) do
		if k >= i and k <= j then
			local och = mw.text.split(m_och(base, nil, true) or "", ",")[1]
			table.insert(result, "\n|-\n!width=17% style=\"background-color:#D1E8F0;\"|[[" .. base .. "]]" .. (och ~= "" and "<span class=\"IPA\" style=\"font-size:60%\"> (" .. och .. ")</span>" or "") .. "\n|style=\"background-color:#FAF9E8;\"|")
			for derivation in mw.text.gsplit(m_phonetic[base], "") do
				table.insert(result, " [[" .. derivation .. "]]")
			end
		end
		k = k + 1
	end
	table.insert(result, "\n|}\n'''''<center>" .. other .. "</center>'''''")
	return table.concat(result)
end

return export