Module:User:Benwing2/ko-etym

local export = {}

local m_lang = require("Module:languages")

-- This module implements (currently only ).

local refs = { {{"1", "hh"}, "Hunmin jeongeum haerye (訓民正音解例 / 훈민정음해례), 1446", "okm"}, {{"2", "he"}, "Hunmin jeongeum eonhae (訓民正音諺解本 / 훈민정음언해본), 1446", "okm"}, {{"3", "ss", "석보"}, "Seokbo sangjeol (釋譜詳節 / 석보상절), 1447", "okm"}, {{"4", "yb", "용가"}, "Yongbi eocheonga (龍飛御天歌 / 용비어천가), 1447", "okm"}, {{"5", "wc"}, "Worin cheongangjigok (月印千江之曲 / 월인천강지곡), 1449", "okm"}, {{"6", "sy"}, "Seonjong yeonggajip eonhae (禪宗永嘉集諺解 / 선종영가집언해), 1456", "okm"}, {{"7", "ws", "wi", "월석"}, "Worin seokbo (月印釋譜 / 월인석보), 1459", "okm"}, {{"8", "ne"}, "Neung-eomgyeong eonhae (楞嚴經諺解 / 능엄경언해), 1461", "okm"}, {{"9", "mb"}, "Myobeopyeonhwagyeong eonhae (妙法蓮華經諺解 / 묘법연화경언해), 1463", "okm"}, {{"10", "wg"}, "Wongakgyeong eonhae (圓覺經諺解 / 원각경언해), 1465", "okm"}, {{"11", "be"}, "Beobeo eonhae (法語諺解 / 법어언해), 1466", "okm"}, {{"12", "nh"}, "Eoje naehun, (御製內訓 / 어제내훈), 1475 ", "okm"}, {{"13", "gg"}, "Gugeupbang eonhae (救急方諺解 / 구급방언해), 1466", "okm"}, {{"14", "bdb"}, "Bullyu dugongbu si eonhae (分類杜工部詩諺解 / 분류두공부시언해), 1481", "okm"}, {{"15", "nm"}, "Nammyeongjip eonhae (南明集諺解 / 남명집언해), 1482", "okm"}, {{"16", "br"}, "Baengnyeon chohae (百聯抄解 / 백련초해), mid-15th century", "okm"}, {{"17", "bs"}, "Beonyeok sohak (飜譯小學 / 번역소학), 1517", "okm"}, {{"18", "bn"}, "Beonyeok nogeoldae (飜譯老乞大 / 번역노걸대), 1517", "okm"}, {{"19", "ir"}, "Iryun haengsildo (二倫行實圖 / 이륜행실도), 1518 (Oksan Seowon ed.)", "okm"}, {{"20", "hm"}, "Hunmong jahoe (訓蒙字會 / 훈몽자회), 1527", "okm"}, {{"21", "gh"}, "Guhwang chwaryo (救荒撮要 / 구황촬요), 1554", "okm"}, {{"22", "sj"}, "Sinjeung yuhap (新增類合 / 신증유합), 1576", "okm"}, {{"23", "se"}, "Sohak eonhae (小學諺解 / 소학언해), 1586", "okm"}, {{"24", "gci"}, "Gyechuk ilgi (癸丑日記 / 계축일기), c. 1600 ", "ko-ear"}, {{"25", "etj"}, "Eonhae taesan jibyo (諺解胎産集要 / 언해태산집요), 1608", "ko-ear"}, {{"26", "edj"}, "Eonhae duchang jibyo (諺解痘瘡集要 / 언해두창집요), 1608", "ko-ear"}, {{"27", "sge", "sgs"}, "Seon-ga gwigam eonhae (禪家龜鑑諺解 / 선가귀감언해), 1610 (Songgwangsa ed.)", "ko-ear"}, {{"28", "mg"}, "Magyeong heonjip (磨鏡軒集 / 마경헌집), 1635", "ko-ear"}, {{"29", "erh"}, "Eorokhae (語錄解 / 어록해), 1652", "ko-ear"}, {{"30", "sgg"}, "Sin-gan guhwang chwaryo (新刊救荒撮要 / 신간구황촬요), 1660", "ko-ear"}, {{"31", "pts"}, "Bak Tongsa eonhae (朴通事諺解 / 박통사언해), 1677", "ko-ear"}, {{"32", "yhy", "유해역"}, "Yeogeo yuhae (譯語類解 / 역어유해), 1690", "ko-ear"}, {{"33", "js"}, "Jeongsok eonhae (正俗諺解 / 정속언해, 1518 (李源周敎授本 / 이원주 교수본)", "okm"},	{{"34", "ys"}, "Sinjeonjachwi yeomchobang eonhae (新傳煮取焰硝方諺解 / 신전자취염초방언해), 1635", "ko-ear"},	{{"35", "sg"}, "Samgang haengsildo (三綱行實圖 / 삼강행실도), 1511", "okm"},	{{"36", "boi"}, "Bunmun onyeok ihaebang (分門瘟疫易解方 / 분문온역이해방), 1542", "okm"},	{{"37", "yyb"}, "Yeogeo yuhaebo (譯語類解補 / 역어유해보), 1775", "ko-ear"},	{{"38", "ggg"}, "Geumganggyeong samgahae (金剛經三家解 / 금강경삼가해), 1482", "okm"},	{{"39", "du"}, "Dongui bogam (東醫寶鑑 / 동의보감), 1613", "ko-ear"},	{{"40", "bo"}, "Byeogon sinbang (辟瘟新方 / 벽온신방), 1653", "ko-ear"},	{{"41", "yhmb", "myb"}, "Mong-eo yuhae bopyeon (蒙語類解補編 / 몽어유해보편), 1790", "ko-ear"},	{{"42", "dssh"}, "Dongguk sinsok samgang haengsildo (東國新續三綱行實圖 / 동국신속삼강행실도), 1617", "ko-ear"},	{{"43", "ge"}, "Gyeongminpyeon eonhae (警民編諺解 / 경민편언해), 1658", "ko-ear"},	{{"44", "ggb"}, "Gugeupganibang eonhae (救急簡易方諺解 / 구급간이방언해), 1489", "okm"}, {{"45", "ag"}, "Akhak gwebeom (樂學軌範 / 악학궤범), 1493", "okm"}, {{"46", "bj"}, "Bangeon jipseok (方言集釋 / 방언집석), 1778", "ko-ear"}, {{"47", "msg"}, "Myeongseonggyeong eonhae (明聖經諺解 / 명성경언해), 1883", "ko-ear"}, {{"48", "gy"}, "Jīlín lèishì (鷄林類事 / 계림유사), 1103", "okm"}, {{"49", "ghw"}, "Gukhan hoehwa (國韓會話 / 국한회화), 1895", "ko-ear"}, {{"50", "mc"}, "Magyeong chojip eonhae (馬經抄集諺解 / 마경초집언해), 1623~1649", "ko-ear"}, {{"51", "nob"}, "Nobakjimnam (老朴輯覽 / 노박집람), 1517", "okm"}, {{"52", "cm"}, "Cheopaemongeo (捷解蒙語 / 첩해몽어), 1790", "ko-ear"}, {{"53", "bb"}, "Beonyeok baktongsa (飜譯朴通事 / 번역박통사), before 1517", "okm"}, {{"54", "sus"}, "Samun seonghwi (三韻聲彙 / 삼운성휘), 1751", "ko-ear"}, {{"55", "dy"}, "Dongmun yuhae (同文類解 / 동문유해), 1748", "ko-ear"}, {{"56", "ng"}, "Nogyega (盧溪歌 / 노계가), 1636", "ko-ear"}, {{"57", "jg"}, "Joya gimun (朝野記聞 / 조야기문), 1684", "ko-ear"}, {{"58", "ye"}, "Yeosaseo eonhae (女四書諺解 / 여사서언해), 1736", "ko-ear"}, {{"59", "jh"}, "Joya hoetong (朝野會通 / 조야회통), 18th century", "ko-ear"}, {{"60", "ij"}, "Imhwa jeongyeon (林花鄭延 / 임화정연), 18th century", "ko-ear"}, {{"61", "jgw"}, "Joseon gwannyeogeo  (朝鮮館驛語 / 조선관역어), 1403~1424", "okm"}, {{"62", "sc"}, "Seokbong cheonjamun (石峰千字文 / 석봉천자문), 1583", "okm"}, {{"63", "ns"}, "Namsarok (南槎錄 / 남사록), 1601", "ko-ear"}, {{"64", "tj"}, "Tamnaji (眈羅志 / 탐라지), 1653", "ko-ear"}, {{"65", "me"}, "Maengja eonhae (孟子諺解 / 맹자언해), 1590", "okm"}, {{"66", "gre"}, "Garye eonhae (家禮諺解 / 가례언해), 1632", "ko-ear"}, {{"67", "tsg"}, "Taesang gameungpyeondoseor eonhae (太上感應篇圖說諺解 / 태상감응편도설언해), 1852", "ko-ear"}, }

local ref_table = {}

for _, ref in ipairs(refs) do	local keys, text, langcode = unpack(ref) for _, key in ipairs(keys) do		ref_table[key] = {text, langcode} end end

-- Implementation of. -- The shorthand parameter for first attestations will be deprecated soon in favor of creating actual entries or citation pages for Middle Korean. -- See discussion at Beer parlour/2019/September. function export.ko_etym_native(frame) local params = { [1] = {},		["also"] = {type = "boolean"}, [2] = {alias_of = "form"}, ["form"] = {}, [3] = {alias_of = "yale"}, ["yale"] = {}, [4] = {alias_of = "year"}, ["year"] = {}, ["dot"] = {default = "."}, ["nodot"] = {type = "boolean"}, ["nocat"] = {type = "boolean"}, }	local parargs = frame:getParent.args if parargs["dot"] == "" then require("Module:debug").track("ko-etym/ko-etym-native/empty-dot") end local args = require("Module:parameters").process(parargs, params)

local parts = {} local categories = {}

if not args[1] then table.insert(parts, "Of native Korean origin") else local text, langcode if ref_table[args[1]] then text, langcode = unpack(ref_table[args[1]]) text = text:gsub("(.-)", function(langtextcode, langtext)				local lang = m_lang.getByCode(langtextcode, true)				return require("Module:script utilities").tag_text(langtext, lang)			end) else if not args.year then error("1='" .. args[1] .. "' is not a known reference work, so year= must be supplied") end text = args[1] .. ", " .. args.year if args.year:find("^[0-9]+$") then if tonumber(args.year) < 1600 then langcode = "okm" else langcode = "ko-ear" end else langcode = "okm" end end if args.also then table.insert(parts, "Also") else table.insert(parts, "First") end table.insert(parts, " attested in the ") if langcode == "okm" then table.insert(categories, "Korean etymologies with first attestations that need to be moved to Middle Korean entries") end table.insert(parts, text)

if args.form then table.insert(parts, ", as ") if langcode ~= "ko-ear" then table.insert(parts, require("Module:etymology").format_inherited(m_lang.getByCode("ko"), {lang = m_lang.getByCode(langcode, true, "allow etym"), term = args.form, tr = "-", }))			else -- A Korean term can't inherit from Early Modern Korean, which is an etymology variant -- of Korean. table.insert(parts, require("Module:etymology languages").getByCode(langcode):makeCategoryLink					.. " " .. require("Module:links").full_link({lang = m_lang.getByCode("ko"), term = args.form, tr = "-"})) end if args.yale then table.insert(parts, " (Yale: ")				table.insert(parts, args.yale)				table.insert(parts, ")") end end end

if not args.nodot then table.insert(parts, args.dot) end

if not args.nocat then table.insert(categories, "Native Korean words") end

return table.concat(parts) .. require("Module:utilities").format_categories(categories, m_lang.getByCode("ko")) end

return export