Module:Korean transliteration notice explained

require('strict') -- Enforce strict variable handling to catch undeclared global variables

-- Import moduleslocal p = local categoryHandler = require('Module:Category handler').main local yesno = require('Module:Yesno') local mArguments = require('Module:Arguments') local n

-- define local functions

-- Function to categorize pageslocal function cat(category) -- Format the category string category = string.format('', category) -- Concatenate the category to n.category using categoryHandler n.category = n.category..(categoryHandler or )end

-- Function to handle Revised Romanization of Koreanlocal function RR n.variant = 'Revised Romanization of Korean' n.transliteration_examples = "Joseon, Tteokbokki, Pansori" cat('Wikipedia articles that use the Revised Romanization of Korean') if n.bid then n.id = n.id .. 'rr' endend

-- Function to handle McCune-Reischauer romanization of Koreanlocal function MR n.variant = 'McCune-Reischauer romanization of Korean' n.extraguide = ' and Korean naming conventions' cat('Wikipedia articles that use the McCune-Reischauer romanization of Korean') n.flag = 'no' if n.bid then n.id = n.id .. 'mr' endend

-- Function to handle Yale romanization of Koreanlocal function Yale n.variant = 'Yale romanization of Korean' n.extraguide = ' and Korean naming conventions' cat('Wikipedia articles that use the Yale romanization of Korean') n.flag = 'no' if n.bid then n.id = n.id .. 'yale' endend

-- Function to modify text based on transliteration system selectedlocal function modify_text n.transliteration = n.extravariant = n.extraguide = local bRR = yesno(n.RR) local bMR = yesno(n.MR) local bYale = yesno(n.Yale)

if bRR then RR return elseif bMR then MR return elseif bYale then Yale return end

if n.transliteration_examples then n.transliteration = ', which has its own transliteration conventions' endend

-- Function to generate the base text for the noticelocal function base_text(frame) n.subjectspace = require('Module:Pagetype').main n.transliteration_examples = n.transliteration_examples and string.format(' (e.g., %s)', n.transliteration_examples) or n.terms = n[1] or n.terms n.terms = n.terms and string.format(' (including %s)', n.terms) or n.compare = n.compare and (n.compare .. ' ') or n.text = string.format([=[This %s '''uses the [[%s]]%s%s%s and some terms that are used in it%s may be different or absent from %sor other romanizations of Korean. According to the relevant Korean style guide%s, this should not be changed without broad consensus. Per, use words commonly established in English over any transliteration if they exist.]=], n.subjectspace, n.variant, n.extravariant, n.transliteration, n.transliteration_examples, n.terms, n.compare, n.extraguide)end

-- Function to style the notice based on given parameterslocal function style(frame) local size if yesno(n.small) then size = '30px' elseif n.size then size = n.size else size = '50px' end if n.image then n.image = string.format('', n.image, size) end if n.form

'editnotice' then if n.bid then n.id = n.id .. 'editnotice' end n.expiry = n.expiry or 'indefinite' if yesno(n.editnotice_cat) then cat(string.format('Pages with the %s editnotice', n.variant)) end return frame:expandTemplate else local message_box = require('Module:Message box').main if not n.image then n.image = 'none' end n['type'] = 'style' return message_box('tmbox', n) endend

-- Function to get the base page name for special cases (used for documentation pages)local function getBasePageName local title = mw.title.getCurrentTitle local basePageName = title.text

-- Handle specific cases if basePageName:find("McCune-Reischauer romanization of Korean") then basePageName = "McCune-Reischauer" elseif basePageName:find("Yale romanization of Korean") then basePageName = "Yale romanization" elseif basePageName:find("Revised Romanization of Korean") then basePageName = "Revised Romanization" else basePageName = basePageName:gsub(" romanization of Korean", "") basePageName = basePageName:gsub(" of Korean", "") end

return basePageNameendp.getBasePageName = getBasePageName

-- Main function for handling the setup and categorizationlocal function _main(frame, templatetitle) n = mArguments.getArgs(frame,) n.variant = n.variant or templatetitle -- automatically use title generated from template name n.category = n.transliteration_examples = n.transliteration_examples or n['transliteration examples'] n.bid = not not n.id

if not n.text then modify_text base_text(frame) end cat('Wikipedia articles that use the ' .. n.variant) return style(frame) .. (n.category or )endp._main = _main

-- Main entry point for the modulefunction p.main(frame) local fulltitle = frame:getParent:getTitle local templatetitle = string.sub(fulltitle, 10) local title = mw.title.getCurrentTitle if mw.title.equals(title, mw.title.makeTitle('Template', title.rootText)) then -- if it is on the main template page, load doc n = mArguments.getArgs(frame,) n.variant = n.variant or templatetitle -- automatically use title generated from template name if n.doc ~= 'no' then return frame:expandTemplate end end return _main(frame, templatetitle)end

return p