Bu modul uchun Modul:zh-see/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}
local sub = mw.ustring.sub
local match = mw.ustring.match

local function link(text, make_link)
	return '<span lang="zh" class="Hani">' .. (make_link and ('[[' .. text .. '#Xitoycha|' .. text .. ']]') or text) .. '</span>'
end

function export.show(frame)
	local non_lemma_type = {
		['s'] = 'soddalashtirilgan', ['simp'] = 'soddalashtirilgan', ['simplified'] = 'soddalashtirilgan',
		['a'] = 'qadimgi', ['ancient'] = 'qadimgi',
		['o'] = 'eskirgan', ['obsolete'] = 'eskirgan',
		['v'] = 'kuraylik', ['var'] = 'kuraylik', ['variant'] = 'kuraylik',
		['all'] = 'soddalashtirilgan, eski yoki kuraylik',
	}
	
	local args = frame:getParent().args
	local title = args[1]
	local content = mw.title.new(title):getContent()
	local simp = args["simp"] or false
	local non_lemma_cat = non_lemma_type[args[2] or 's'] or 'soddalashtirilgan'
	local non_lemma_cat_article = non_lemma_cat == 'soddalashtirilgan' and 'degan' or (non_lemma_cat == 'kuraylik' and 'a' or 'an')
	local curr_title = mw.title.getCurrentTitle().subpageText
	local note = (mw.title.new(title) or {}).exists and "" or '[[Turkum:Yaratilmagan shakllari bilan Xitoy shartlari]]'
	
	local box =
		'{| class="wikitable' .. (non_lemma_cat == 'soddalashtirilgan' and ' mw-collapsible mw-collapsed' or '') ..
			'" style="border:1px solid #797979; margin-left: 1px; text-align:left; width:' .. (40 + mw.ustring.len(title) * 3) .. '%"' ..
		
			'\n|-\n| style="background-color: #eeeeee; padding-left: 0.5em" | \'\'\'Talaffuz va ifodalarini \'\'\'' .. link(curr_title) .. 
			'\'\'\' – qarang ' .. link(title, true) .. (args[3] and (' ("' .. args[3] .. '")') or '') .. '.\'\'\'' ..
			
			'<br>(Bu muddat, ' .. link(curr_title) .. ', boʻlib ' .. non_lemma_cat_article .. ' \'\'' .. non_lemma_cat .. '\'\' shakli ' .. link(title) .. '' ..
			
			(simp and
				('<small>:&nbsp; ' .. link(sub(simp, 1, 1), true) .. ' → ' .. link(sub(simp, 2, 2), true) .. '</small>')
			or
				'') .. '.)' .. 
			
			(non_lemma_cat ~= 'soddalashtirilgan' and '' or [=[

|-
| style="background-color: #F5DEB3; font-size: smaller" | <b>Eslatma:</b>
<div class="mw-collapsible-content">
* [[w:Simplified Chinese characters|Soddalashtirilgan Xitoycha]] asosan Xitoy Xalq Respublikasi va Singapur ishlatiladi.
* [[:w:Traditional Chinese characters|Anʼanaviy Xitoycha]] asosan Gongkong, Xitoy Taypeyi va Tayvan ishlatiladi.</div></div>]=]) ..

			'\n|}' .. note
	
	local code = content and mw.ustring.match(content, '{{zh%-pron[^}]+}}') or false
	
	local function find_pron(variety)
		return sub(match(code, variety .. '=[^|}]+') or '', mw.ustring.len(variety) + 2, -1)
	end
	
	local categories = (code and mw.getCurrentFrame():expandTemplate{
		title = "Template:zh-pron",
		args = {
			['m'] = find_pron('m'),
			['c'] = find_pron('c'),
			['h'] = find_pron('h'),
			['md'] = find_pron('md'),
			['mn'] = find_pron('mn'),
			['w'] = find_pron('w'),
			['cat'] = find_pron('cat'),
			['only_cat'] = 'yes',
			}
		} or '')
	
	return box .. categories
end

return export