Module:User:Lunabunn/ko-attest

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


local export = {}
local us = mw.ustring
local ko = require("Module:languages").getByCode("ko")
local tag_text = require("Module:script utilities").tag_text

function export.ko_attest(frame)
	local parent_args = frame:getParent().args
	local args = require("Module:parameters").process(parent_args, {
		 = {type = "language", required = true, default = "und"},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {type = "number"},
		 = {alias_of = "header"},
		 = {default = "first"},
		 = {type = "boolean"},
		 = {type = "boolean"},
		 = {alias_of = "work"},
		 = {},
		 = {},
		 = {type = "boolean"},
		 = {alias_of = "work_hanja"},
		 = {},
		 = {alias_of = "year"},
		 = {},
		 = {},
		 = {},
		 = {},
	})

	local headers = {
		 = "First ]",
		 = "Also ]",
		 = "In the ] script, first ]",
		 = "In the ] script, first ]",
		 = "",
	}
	local header = headers]
	if args then
		header = us.lower(us.sub(header, 1, 1)) .. us.sub(header, 2, -1)
	end
	
	local hapaxes = {
		 = "] ",
		 = "] ",
		 = "] ",
		 = "] "
	}
	local hapax = (args and {hapaxes]} or {""})
	if hapax == nil then
		error("hapax= must be unspecified or between 1 and 4, inclusive")
	end

    local attest
    if args == "-" then
    	attest = ""
    else
    	if args == "" then
    	    require('Module:debug/track')("ko-attest/missing attested form")
    	end
		attest = (header == "" and " " or " as ") .. args:makeWikipediaLink() .. " " .. hapax .. require("Module:links").full_link({
			term = args,
			lang = args,
			gloss = args,
			tr = args,
			alt = args,
		}, "term")
    end
    
	
	local attest_work = ""
	if args or args then
		local front_fragment = ""
		local back_fragment = ""
		
		if args then
			export.fetch_data(frame, work, args)
		end
		
		if args then
			front_fragment = "same source"
		else
			if not args then
				error("work= was supplied, so year= must be supplied")
			end
			
			local work_tr
			if args then
				work_tr = args
			else
				work_tr = ko:transliterate(us.gsub(args, "_", " "))
				work_tr = us.upper(us.sub(work_tr, 1, 1)) .. us.sub(work_tr, 2, -1)
			end
			
			local work = us.gsub(args, "_", "")
			if args then
				work = args .. " / " .. work 
			end
			local work_tagged = tag_text(work, ko)
			
			local delim_left = args and "“" or "''"
			local delim_right = args and "”" or "''"
			
			front_fragment = delim_left .. work_tr .. delim_right .. " (" .. work_tagged .. ")"
			back_fragment = ", " .. args
		end
		
		local position = ""
		local volume = args
		local page = args
		if volume then
			-- prettify
			if volume == "상" then volume = "上"
			elseif volume == "중" then volume = "中"
			elseif volume == "하" then volume = "下"
			end
			volume = tag_text(volume, ko)
			if page then
				position = ", " .. volume .. ":" .. page
			else
				position = ", " .. volume
			end
		elseif page then
			position = ", " .. page
		end
		
		local link = ""
		if args then
			link = "<sup> .. "]</sup>"
		end
		
		attest_work = " in the " .. front_fragment .. position .. link .. back_fragment
	else
		require('Module:debug/track')("ko-attest/missing work")
	end
	
	return header .. attest .. attest_work
end

function export.fetch_data(frame, work, args)
	local dt = mw.loadData("Module:User:Lunabunn/ko-attest/data")
	local data = dt]
	if type(data) == "string" then
		args = data
		data = dt
	end
	if type(data) == "table" then
		args = data or args
		args = data or args
		args = data or args
		args = data or args
		
		if not args then
			local volume = args
			local page = args
			
			local d_v = data
			if volume then
				volume = volume:gsub("^+", "")
				volume = volume:gsub("%s+$", "")
				if not d_v or d_v.map == nil then
					error("Invalid volume")
				else
					volume = d_v.map
					args = (d_v.display and d_v.display) or volume
				end
			elseif d_v == nil then
				volume = "1"
			end
			
			local repl = nil
			if page then
				if not volume then
					error("Cannot specify page in multi-volume work without specifying volume")
				end
				repl = data or data or data
			elseif volume then
				page = "1"
				repl = data or data or data
			else
				volume = select(2, next(d_v.map))
				page = "1"
				repl = data or data or data
			end
			if repl then
				args = frame:preprocess(repl:gsub("$1", volume):gsub("$2", page))
			end
		end
	end
end

return export