Module:zh-glyph

Hello, you have come here looking for the meaning of the word Module:zh-glyph. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:zh-glyph, but we will also tell you about its etymology, its characteristics and you will know how to say Module:zh-glyph in singular and plural. Everything you need to know about the word Module:zh-glyph you have here. The definition of the word Module:zh-glyph will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:zh-glyph, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Backend for {{Han etym}}.


local concat = table.concat
local insert = table.insert
local load_data = mw.loadData
local new_title = mw.title.new
local process_params = require("Module:parameters").process

local data = load_data("Module:zh/data/glyph-data")

local export = {}

function export.main(frame)
	local boolean = {type = "boolean"}
	local args = process_params(frame:getParent().args, {
		 = true,
		 = boolean,
		 = boolean,
	})
	
	local target_page = args or load_data("Module:headword/data").pagename
	local showEras, showScripts, showImgs, hideText = {}, {}, {}, {}
	local success, data_module = pcall(load_data, "Module:zh/data/glyph-data/" .. target_page)

	local char_data = {
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
	}

	local count = 0
	if not args.no_img then
		for _, era in ipairs(data.eras) do
			local count_era = 0
			for _, script in ipairs(era) do
				local img_link = target_page .. "-" .. script .. ".svg"
				local img_file = new_title("Media:" .. img_link)
				if img_file.exists and not img_file.isRedirect then
					count = count + 1
					count_era = count_era + 1
					insert(showScripts, "\n!" .. data.scripts)
					insert(showImgs, "\n| style=\"padding: 8px;\"|]")
				end
			end
			if count_era > 0 then
				insert(showEras, "\n! colspan=\"" .. count_era .. "\"|" .. era)
			end
		end
	end
	if success then
		local img_count = 0
		for _ in ipairs(data_module) do
			img_count = img_count + 1
		end
		success = success and new_title("Media:ACC-" .. data_module .. ".svg").exists
	end
	if success then
		for _, img in ipairs(data_module) do
			insert(char_data*")]], '<div class="gallerybox" style="display:inline-block"' ..
				'><div style="text-align:center">[[File:ACC-' .. img ..
				'.svg|60px|class=mw-invert skin-invert]]<div class="gallerytext"><small>' .. img .. '</small></div></div></div>')
		end
		for i, script in ipairs(data.hide_scripts) do
			if char_data then
				if i ~= 1 then
					insert(hideText, "<hr>")
				end
				insert(hideText, "<div class=\"gallery\"><div><b>" .. data.scripts .. "</b></div>" .. concat(char_data) .. "</div>")
			end
		end
		insert(hideText, '\n|- class="vsHide"\n| width="100%" align="left" colspan="' .. (count == 0 and 1 or count) ..
			'|\n<div class="toccolours mw-collapsible mw-collapsed"><b>References</b>:' ..
			'<div class="mw-collapsible-content">\nMostly from Richard Sears\' ' ..
			"[http://hanziyuan.net/#" ..
			target_page .. " Chinese Etymology site] ([[c:Commons:Ancient Chinese characters/Richard Sears Agreement" ..
			"|authorisation]]),<br>which in turn draws data from various collections of ancient forms of Chinese characters" ..
			", including:\n* ''Shuowen Jiezi'' (small seal), \n* ''Jinwen Bian'' (bronze inscriptions)" ..
			", \n* ''Liushutong'' (Liushutong characters) and \n* ''Yinxu Jiaguwen Bian'' (oracle bone script).</div></div>")
	end
	
	local glyph_forms
	if ( success or count > 0 ) and not args.no_img then
		glyph_forms = "<div style=\"overflow:auto;width:fit-content;max-width:100%\">\n" .. =] .. (success and ' vsSwitcher" data-toggle-category="forms' or "") ..
			[=[" cellpadding=7 style="border-spacing: 1px; border: 1px solid darkgray; text-align:center"
			! class="vsToggleElement" colspan="]=] .. (count == 0 and 1 or count) ..
			=] .. target_page .. =] ..

			(count > 0
				and "\n|-" .. concat(showEras) .. "\n|-" .. concat(showScripts) .. "\n|-" .. concat(showImgs)
				or "") ..

			(success
				and "\n|- class=\"vsHide\"\n| align=\"center\" colspan=\"" .. (count == 0 and 1 or count) ..
					"|" .. concat(hideText, "")
				or "") ..

			"\n|}\n</div>"

	else
		glyph_forms = ""
	end

	local phonText = {}
	local list = load_data("Module:zh-glyph/phonetic/list")
	local phonComp = list or nil

	if phonComp and not args.no_phon then
		insert(phonText,
			'\n' ..
			'<div class="NavFrame" style="border:0px; max-width: 37em; text-align:center;" cellpadding="6">' ..
			'<div class="NavHead" style="font-size:105%; border:1px solid var(--wikt-palette-grey, #9e9e9e); background-color:var(--wikt-palette-indigo, #aaaaee); text-align:center;" cellpadding="3">' ..
			'Characters in the same ]' ..
			' (<span class="Hani">]</span>)' ..
			' <small>(])</small>&nbsp; ' ..
			'</div>' ..
			'<div class="NavContent">' ..
			'\n{| class="wikitable zh-glyph" style="margin-top: 0; width: 100%; display: table;"' ..
			'\n|-\n! align="center"|\n!Old Chinese'
		)

		local phonData = load_data("Module:zh-glyph/phonetic")
		local m_och = require("Module:och-pron").retrieve_pron
		
		for item in phonData:gmatch(".*") do
			insert(phonText, '\n|-\n| align="center" |<span class="Hani">]</span>')
			local IPA = m_och(item, nil, true)
			if IPA then
				insert(phonText, '\n|<small><span class="IPA">' .. IPA .. '</span></small>')
			end
		end
		insert(phonText, '\n|}\n</div></div>')
	end

	return glyph_forms .. concat(phonText)
end

return export