Пређи на садржај

Модул:ko-headword-hanja

Документацију овог модула можете да направите на страници Модул:ko-headword-hanja/док

local export = {}
local m_head = require('Модул:headword')
local m_lang = require('Модул:languages')

local strings = {
	['e'] = 'eum',
	['eh'] = '[[음훈#Корејски|eumhun]]',
	['dueumBeopchik'] = '[[두음 법칙#Корејски|Јужна Кореја]]',
}

function clone(table)
	local table_new = {}

	for k, v in pairs(table) do
		table_new[k] = v
	end

	return table_new
end

function export.show(frame)
	local params = {
		[1] = { list = true, allow_empty = true },
	}
	local args = require('Модул:parameters').process(frame:getParent().args, params)

	local hunPage, hunText, hunLink, eum, eumDueumBeopchik

	if args[1][#args[1] - 1] == '' then
		eumDueumBeopchik = table.remove(args[1])
		table.remove(args[1])
	end
	eum = table.remove(args[1])
	hunText = table.remove(args[1])
	hunPage = table.remove(args[1])

	if hunText and string.match(hunText, '%[%[.+%]%]') then
		hunLink = hunText
	elseif hunPage then
		hunLink = '[[' .. hunPage .. '|' .. hunText .. ']]'
	elseif hunText then
		hunLink = '[[' .. hunText .. ']]'
	end

	local data = {}

	data.lang = m_lang.getByCode('ko')
	data.translits = {'-'}
	data.pos_category = 'Хан карактери'
	data.categories = {}
	data.inflections = {}
	data.sort_key = eum -- or should this be radical+strokenumber?
	
	if eum then
		table.insert(data.inflections, {
			label = (hunLink and strings.eh or strings.e),
			(hunLink and hunLink .. ' ' or '') .. ('[[' .. eum .. ']]'),
			enable_auto_translit = true,
		})
	else
		error('The pronunciation of this hanja has not been provided.')
	end

	if eumDueumBeopchik then
		table.insert(data.inflections, {
			label = (strings.dueumBeopchik),
			(hunLink and hunLink .. ' ' or '')  .. ('[[' .. eumDueumBeopchik .. ']]'),
			enable_auto_translit = true,
		})
	end

	local fullHeadword = m_head.full_headword(data)

	fullHeadword = mw.ustring.gsub(fullHeadword, "eumhuneum", "eumhun-eum") -- XXX

	return fullHeadword
end

return export