Module:Korean transliteration notice: Difference between revisions
Appearance
Content deleted Content added
Nonabelian (talk | contribs) No edit summary Tag: Reverted |
Nonabelian (talk | contribs) Undid revision 1236923406 by Nonabelian (talk) |
||
Line 7: | Line 7: | ||
local n |
local n |
||
-- |
-- define functions |
||
local function cat(category) |
|||
category = string.format('[[Category:%s]]', category) |
|||
-- Places pages in the appropriate category using categoryHandler |
|||
n.category = n.category .. category |
|||
local categories = categoryHandler{ |
|||
main = category, |
|||
talk = category, |
|||
template = category, |
|||
nocat = n.nocat, |
|||
page = n.page |
|||
} |
|||
n.category = n.category .. (categories or '') |
|||
end |
end |
||
-- Handles categorization and setup for Revised Romanization of Korean |
|||
local function RR() |
local function RR() |
||
n.variant = 'Revised Romanization of Korean' |
n.variant = 'Revised Romanization of Korean' |
||
n.transliteration_examples = "''Joseon'', ''Tteokbokki'', ''Pansori''" |
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' end |
if n.bid then n.id = n.id .. 'rr' end |
||
end |
end |
||
-- Handles categorization and setup for McCune-Reischauer romanization of Korean |
|||
local function MR() |
local function MR() |
||
n.variant = 'McCune-Reischauer romanization of Korean' |
n.variant = 'McCune-Reischauer romanization of Korean' |
||
n.extraguide = ' and [[Wikipedia:Naming conventions (Korean)|Korean naming conventions]]' |
n.extraguide = ' and [[Wikipedia:Naming conventions (Korean)|Korean naming conventions]]' |
||
cat('Wikipedia articles that use the McCune-Reischauer romanization of Korean') |
|||
n.flag = 'no' |
n.flag = 'no' |
||
if n.bid then n.id = n.id .. 'mr' end |
if n.bid then n.id = n.id .. 'mr' end |
||
end |
end |
||
-- Handles categorization and setup for Yale romanization of Korean |
|||
local function Yale() |
local function Yale() |
||
n.variant = 'Yale romanization of Korean' |
n.variant = 'Yale romanization of Korean' |
||
n.extraguide = ' and [[Wikipedia:Naming conventions (Korean)|Korean naming conventions]]' |
n.extraguide = ' and [[Wikipedia:Naming conventions (Korean)|Korean naming conventions]]' |
||
cat('Wikipedia articles that use the Yale romanization of Korean') |
|||
n.flag = 'no' |
n.flag = 'no' |
||
if n.bid then n.id = n.id .. 'yale' end |
if n.bid then n.id = n.id .. 'yale' end |
||
end |
end |
||
-- Modifies the text based on the transliteration system selected |
|||
local function modify_text() |
local function modify_text() |
||
n.transliteration = '' |
n.transliteration = '' |
||
Line 70: | Line 58: | ||
end |
end |
||
-- Generates the base text for the notice |
|||
local function base_text(frame) |
local function base_text(frame) |
||
n.subjectspace = require('Module:Pagetype').main() |
n.subjectspace = require('Module:Pagetype').main() |
||
Line 81: | Line 68: | ||
end |
end |
||
-- Styles the notice based on given parameters |
|||
local function style(frame) |
local function style(frame) |
||
local size |
local size |
||
Line 95: | Line 81: | ||
n.expiry = n.expiry or 'indefinite' |
n.expiry = n.expiry or 'indefinite' |
||
if yesno(n.editnotice_cat) then |
if yesno(n.editnotice_cat) then |
||
cat(string.format('Pages with the %s editnotice', n.variant)) |
|||
end |
end |
||
return frame:expandTemplate{title = 'editnotice', args = n} |
return frame:expandTemplate{title = 'editnotice', args = n} |
||
Line 106: | Line 92: | ||
end |
end |
||
-- Gets the base page name for special cases |
|||
local function getBasePageName() |
local function getBasePageName() |
||
local title = mw.title.getCurrentTitle() |
local title = mw.title.getCurrentTitle() |
||
Line 127: | Line 112: | ||
p.getBasePageName = getBasePageName |
p.getBasePageName = getBasePageName |
||
-- Main function for handling the setup and categorization |
|||
local function _main(frame, templatetitle) |
local function _main(frame, templatetitle) |
||
n = mArguments.getArgs(frame, {parentFirst = true}) |
n = mArguments.getArgs(frame, {parentFirst = true}) |
||
Line 139: | Line 123: | ||
base_text(frame) |
base_text(frame) |
||
end |
end |
||
cat('Wikipedia articles that use the ' .. n.variant) |
|||
return style(frame) .. (n.category or '') |
return style(frame) .. (n.category or '') |
||
end |
end |
||
p._main = _main |
p._main = _main |
||
-- Main |
-- Main function |
||
function p.main(frame) |
function p.main(frame) |
||
local fulltitle = frame:getParent():getTitle() |
local fulltitle = frame:getParent():getTitle() |
||
Line 156: | Line 140: | ||
end |
end |
||
end |
end |
||
return |
return _main(frame, templatetitle) |
||
end |
end |
||
Revision as of 07:17, 27 July 2024
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
This module is for generating various Korean transliteration notice templates.
Automatically generates "variant" from the title template that invokes it (e.g., invoking from "Template:Revised Romanization" gives "Revised Romanization" as variant).
All templates using this support the following parameters:
- small, form and including – unnecessary to use in templates as grabbed when passed in from talk pages
- id – the HTML id used in edit notices; "editnotice" is automatically appended
- image – name of file to be used as an icon, without the File: prefix.
- variant – defaults to the template name; the variant of transliteration, which should be a Wikipedia article.
- transliteration examples – gives transliteration examples in parentheses
- compare – comparison with other transliterations of Korean
- text – custom text, set only if required to be different from the default
- doc if set to no, will not load the automatic documentation at Module:Korean transliteration notice/documentation
- editnotice_cat if set to yes, categorizes in edit notice category
- nocat disables documentation if set to true
- size set the size of the image (example:
)|size=60px
Examples
As of July 2024, Template:Revised Romanization uses the following parameters:
{{#invoke:Korean transliteration notice|main | id = rr | image = Hunmin jeong-eum.jpg | transliteration_examples = ''Joseon'', ''Tteokbokki'', ''Pansori'' | compare = [[McCune-Reischauer|MR]], [[Yale romanization of Korean|Yale]] }}
which produces:
![]() | This module uses the Revised Romanization of Korean, which has its own transliteration conventions (e.g., Joseon, Tteokbokki, Pansori) and some terms that are used in it may be different or absent from MR, Yale or other romanizations of Korean. According to the relevant Korean style guide, this should not be changed without broad consensus. Per WP:COMMONNAME, use words commonly established in English over any transliteration if they exist. |
Other Examples:
require('strict')
local p = {}
local categoryHandler = require('Module:Category handler').main
local yesno = require('Module:Yesno')
local mArguments = require('Module:Arguments')
local n
-- define functions
local function cat(category)
category = string.format('[[Category:%s]]', category)
n.category = n.category .. category
end
local 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' end
end
local function MR()
n.variant = 'McCune-Reischauer romanization of Korean'
n.extraguide = ' and [[Wikipedia:Naming conventions (Korean)|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' end
end
local function Yale()
n.variant = 'Yale romanization of Korean'
n.extraguide = ' and [[Wikipedia:Naming conventions (Korean)|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' end
end
local 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' end
end
local 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 [[Romanization of Korean|romanizations of Korean]]. According to the [[MOS:KO|relevant Korean style guide]]%s, this should not be changed without [[Wikipedia:Consensus#Levels of consensus|broad consensus]]. Per [[WP:COMMONNAME]], 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
local 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('[[File:%s|%s]]', 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{title = 'editnotice', args = n}
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)
end
end
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 basePageName
end
p.getBasePageName = getBasePageName
local function _main(frame, templatetitle)
n = mArguments.getArgs(frame, {parentFirst = true})
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 '')
end
p._main = _main
-- Main function
function 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, {parentFirst = true})
n.variant = n.variant or templatetitle -- automatically use title generated from template name
if n.doc ~= 'no' then
return frame:expandTemplate {title = 'Korean transliteration notice/documentation', args = n}
end
end
return _main(frame, templatetitle)
end
return p