Functions for producing row values for use in infobox templates They are not intended for use in standalone templates
Documentation
Package items
Infobox.japaneseName(frame)
(function)- Japanese name Intended for use in an infobox as a <format> invocation
- Parameters:
- Returns: (HTMLBuilder)
- Usage:
{{#invoke:Infobox|japaneseName}}
Infobox.koreanName()
(function)- Korean name
Infobox.chineseName()
(function)- Chinese name
Infobox.ARCHSERIES_ja_name(frame)
(function)- Variable 'ja_name' for 'archseries' infoboxes
- Parameters:
- Returns: Wikitext (string)
- See also: Template:Infobox archseries
--- Functions for producing row values for use in infobox templates
-- They are not intended for use in standalone templates
--
--
-- @module Infobox
-- @class infobox
-- @author [[User:FishTank]]
-- @release beta
-- @require [[Module:HF]]
-- @require [[Module:Arguments]]
-- @require [[Module:Category handler]]
-- @require [[Module:Ruby]]
-- @require [[Module:Yesno]]
local Infobox = {}
local HF = require('Module:HF')
local getArgs = require('Module:Arguments').getArgs
local CH = require('Module:Category handler').main
local R = require('Module:Ruby')
local yesno = require('Module:Yesno')
local function rubyDetect(s, t, f)
return s:match('<ruby') and (t or '') or (f or '')
end
local function italicize (text)
return ("''" .. text .. "''")
end
--- Japanese name
--
-- Intended for use in an infobox as a <format> invocation
-- @param {Frame} frame
-- @param {table} frame.args
-- @param {string} frame.args.ja_name
-- @param {string} frame.args.romaji
-- @param {string} frame.args.romaji_name
-- @param {string} frame.args.ja_trans_name
-- @param {string} frame.args.trans_name
-- @return {HTMLBuilder}
-- @usage {{#invoke:Infobox|japaneseName}}
function Infobox.japaneseName (frame)
local args = getArgs(frame, { parentOnly = true })
local invoke_args = getArgs(frame, { frameOnly = true } )
local out = mw.html.create( nil )
local properties = {}
if args['ja_name']:match('<ruby') and (yesno(invoke_args['ruby'], true) or true) then
out:tag('span'):attr('lang','ja-Jpan'):attr('title','Kanji'):wikitext(R.split{args['ja_name']}):done()
out:tag('br'):done()
out:tag('small'):wikitext('「')
:tag('span'):attr('lang','ja-Jpan'):attr('title','Kana'):wikitext(R.split{args['ja_name'],'top'}):done()
:wikitext('」'):done()
else
out:tag('span'):attr('lang','ja'):wikitext(args['ja_name']):done()
end
args['romaji'] = args['romaji'] or args['romaji_name']
if args['romaji'] and (yesno(invoke_args['show_romaji'], true) or true) then
out:tag('small'):wikitext(' (')
out:tag('span'):attr('lang','ja-Latn-hepburn'):attr('title','Rōmaji'):wikitext("''" .. args['romaji'] .. "''"):done()
out:wikitext(')'):done()
properties['Romaji name'] = args['romaji']
properties['Name (additional)'] = 'Rōmaji;' .. args['romaji'] .. '@ja'
end
args['ja_trans_name'] = args['ja_trans_name'] or args['trans_name']
if args['ja_trans_name'] and (yesno(invoke_args['show_translation'], false) or false) then
out:tag('hr'):done()
out:tag('span'):wikitext('Translated: '):done()
out:tag('span'):attr('lang','en'):attr('title','Translation from Japanese')
:wikitext( italicize( args['ja_trans_name'] ) )
:done()
properties['Japanese translated name'] = args['ja_trans_name']
properties['Name (additional)'] = 'Translation from Japanese;' .. args['ja_trans_name'] .. '@en'
end
out:allDone()
properties['Japanese name'] = args['ja_name']
properties['Name'] = args['ja_name'] .. '@ja'
if yesno(invoke_args['set_smw'], true) or true then
mw.smw.set(properties)
end
return out
end
--- Korean name
function Infobox.koreanName (frame)
local args = getArgs(frame, { parentOnly = true })
local invoke_args = getArgs(frame, { frameOnly = true } )
local out = mw.html.create( nil )
local properties = {}
if args['ko_name']:match('<ruby') and (yesno(invoke_args['ruby'], true) or true) then
out:tag('span'):attr('lang','ko'):wikitext(R.split{args['ko_name'], ['lang'] = 'ko'}):done()
out:tag('br'):done()
out:tag('small'):wikitext('「')
:tag('span'):attr('lang','ko-Hang'):wikitext(R.split{args['ko_name'],'top', ['lang'] = 'ko'}):done()
:wikitext('」'):done()
else
out:tag('span'):attr('lang','ko'):wikitext(args['ko_name']):done()
end
if args['hanja_name'] then
out:tag('hr'):done()
out:tag('span'):wikitext('Hanja: '):done()
out:tag('span'):attr('lang','ko-Hani'):attr('title','Hanja')
:wikitext( italicize( args['hanja_name'] ) )
:done()
properties['Hanja name'] = args['hanja_name']
properties['Name (additional)'] = 'Hanja;' .. args['hanja_name'] .. '@ko'
end
if args['ko_rr_name'] then
out:tag('hr'):done()
out:tag('span'):wikitext('KRR: '):done()
out:tag('span'):attr('lang','ko-Latn'):attr('title','Korean Revised Romanization')
:wikitext(italicize(args['ko_rr_name']))
:done()
properties['Korean Revised Romanization name'] = args['ko_rr_name']
properties['Name (additional)'] = 'Revised Romanization of Korean;'..args['ko_rr_name'] .. '@ko'
end
if args['ko_trans_name'] and (yesno(invoke_args['show_translation'], false) or false) then
out:tag('hr'):done()
out:tag('span'):wikitext('Translated: '):done()
out:tag('span'):attr('lang','en'):attr('title','Translation from Korean')
:wikitext( italicize( args['ko_trans_name'] ) )
:done()
properties['Korean translated name'] = args['ko_trans_name']
properties['Name (additional)'] = 'Translation from Korean;' .. args['ko_trans_name'] .. '@en'
end
out:allDone()
properties['Korean name'] = args['ko_name']
properties['Name'] = args['ko_name'] .. '@ko'
if yesno(invoke_args['set_smw'], true) or true then
mw.smw.set(properties)
end
return out
end
--- Chinese name
function Infobox.chineseName (frame)
local args = getArgs(frame, { parentOnly = true })
local invoke_args = getArgs(frame, { frameOnly = true } )
local out = mw.html.create( nil )
local properties = {}
if args['zh_name']:match('<ruby') and (yesno(invoke_args['ruby'], true) or true) then
out:tag('span'):attr('lang','zh'):wikitext(R.split{args['zh_name'], ['lang'] = 'zh'}):done()
out:tag('br'):done()
out:tag('small'):wikitext('「')
:tag('span'):attr('lang','zh-Bopo'):wikitext(R.split{args['zh_name'],'top', ['lang'] = 'zh'}):done()
:wikitext('」'):done()
else
out:tag('span'):attr('lang','zh'):wikitext(args['zh_name']):done()
end
if args['pinyin_name'] then
out:tag('hr'):done()
out:tag('span'):wikitext('Pinyin: '):done()
out:tag('span'):attr('lang','zh-Latn-pinyin'):attr('title','Pinyin')
:wikitext(italicize(args['pinyin_name']))
:done()
properties['Chinese Pinyin name'] = args['ko_rr_name']
properties['Name (additional)'] = 'Pinyin;'..args['pinyin_name'] .. '@zh'
end
if args['jyutping_name'] then
out:tag('hr'):done()
out:tag('span'):wikitext('Jyutping: '):done()
out:tag('span'):attr('lang','zh-Latn-jyutping'):attr('title','Jyutping')
:wikitext(italicize(args['jyutping_name']))
:done()
properties['Chinese Jyutping name'] = args['jyutping_name']
properties['Name (additional)'] = 'Jyutping;'..args['jyutping_name'] .. '@zh'
end
if args['zh_trans_name'] and (yesno(invoke_args['show_translation'], false) or false) then
out:tag('hr'):done()
out:tag('span'):wikitext('Translated: '):done()
out:tag('span'):attr('lang','en'):attr('title','Translation from Chinese')
:wikitext( italicize( args['zh_trans_name'] ) )
:done()
properties['Chinese translated name'] = args['zh_trans_name']
properties['Name (additional)'] = 'Translation from Chinese;' .. args['zh_trans_name'] .. '@en'
end
out:allDone()
properties['Chinese name'] = args['zh_name']
properties['Name'] = args['zh_name'] .. '@zh'
if yesno(invoke_args['set_smw'], true) or true then
mw.smw.set(properties)
end
return out
end
--- Variable 'ja_name' for 'archseries' infoboxes
-- @see [[Template:Infobox archseries]]
-- @param {Frame} frame
-- Scribunto frame object
-- @param {table} frame.args
-- Invocation arguments
-- @returns {string}
-- Wikitext
function Infobox.ARCHSERIES_ja_name (frame)
local args = getArgs(frame)
local out = mw.html.create( nil )
local properties = {}
if args['ja_name']:match('<ruby') then
out:tag('span'):attr('lang','ja-Jpan'):attr('title','Kanji'):wikitext(R.split{args['ja_name']}):done()
out:tag('br'):done()
out:tag('small'):wikitext('「')
:tag('span'):attr('lang','ja-Jpan'):attr('title','Kana'):wikitext(R.split{args['ja_name'],'top'}):done()
:wikitext('」'):done()
else
out:tag('span'):attr('lang','ja'):wikitext(args['ja_name']):done()
end
if args['romaji'] then
out:tag('small'):wikitext(' (')
out:tag('span'):attr('lang','ja-Latn-hepburn'):attr('title','Rōmaji'):wikitext("''" .. args['romaji'] .. "''"):done()
out:wikitext(')'):done()
properties['Romaji name'] = args['romaji']
properties['Name (additional)'] = 'Rōmaji;'..args['romaji'] .. '@ja'
end
out:allDone()
properties['Japanese name'] = args['ja_name']
properties['Name'] = args['ja_name'] .. '@ja'
mw.smw.set(properties)
return out
end
function Infobox.ARCHSERIES_ja_name2 (frame)
local args = getArgs(frame)
local out = mw.html.create( nil )
-- local properties = {}
if args['ja_name2']:match('<ruby') then
out:tag('span'):attr('lang','ja-Jpan'):attr('title','Kanji'):wikitext(R.split{args['ja_name2']}):done()
out:tag('br'):done()
out:tag('small'):wikitext('「')
:tag('span'):attr('lang','ja-Jpan'):attr('title','Kana'):wikitext(R.split{args['ja_name2'],'top'}):done()
:wikitext('」'):done()
else
out:tag('span'):attr('lang','ja'):wikitext(args['ja_name']):done()
end
if args['romaji2'] then
out:tag('small'):wikitext(' (')
out:tag('span'):attr('lang','ja-Latn-hepburn'):attr('title','Rōmaji'):wikitext("''" .. args['romaji2'] .. "''"):done()
out:wikitext(')'):done()
properties['Romaji name'] = args['romaji']
properties['Name (additional)'] = 'Rōmaji;'..args['romaji']
end
out:allDone()
-- properties['Japanese name'] = args['ja_name']
-- properties['Name'] = args['ja_name'] .. '@ja'
-- mw.smw.set(properties)
return out
end
function Infobox.ARCHSERIES_ja_manga (frame)
end
function Infobox.ARCHSERIES_ja_anime (frame)
end
function Infobox.ARCHSERIES_zh_name (frame)
end
function Infobox.ARCHSERIES_ko_name (frame)
end
function Infobox.ARCHSERIES_MEMBERS (frame)
end
function Infobox.ARCHSERIES_POSTAMBLE (frame)
end
return Infobox