<extra> is rendered as presented preceeded with <comma><space>
<extra2> is rendered as presented preceeded with <space>
|lead=: takes one value 'yes'; renders language name same as but also adds Hepburn:<space> ahead of the romanization; TODO: in Module:Lang, turnoff tooltip for transl when |lead=yes  
]=]  
local function nihongo
local lang_module = require ('Module:Lang' .. (:getTitle:match ('/sandbox') or '')); -- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else  
local args = require ('Module:Arguments').getArgs ;  
local english, japanese, romaji, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5]; -- meaningful names
args[4] = extra or args[4]; -- ensure that extra is 'positional' for use by nihongo_renderer  
local lead = 'yes' == args.lead; -- make boolean  
if not (japanese or romaji) then -- not present, return an error message
return nihongo_error ('nihongo');
end
if japanese then
japanese = lead and lang_module._lang_xx_inherit ({['code']='ja', japanese, ['template']='nihongo'}) or lang_module._lang ({'ja', japanese, ['template']='nihongo'}); -- add ja script with/without language prefix
end
if romaji then
romaji = (lead and english and 'Hepburn: ' or '') .. lang_module._transl ({'ja', 'hepburn', romaji}) or nil;
end  
local formatting = { -- <5p4n> and </5p4n>: place holders for font-weight style spans; akin to stripmarkers, replaced before function returns
{'<5p4n>(%s)', {extra}}, -- 1 - (extra)
{'%s<5p4n>', {romaji}}, -- 2 - romaji
{'%s<5p4n> (%s)', {romaji, extra}}, -- 3 - romaji (extra)
{'<5p4n>(%s)', {japanese}}, -- 4 - japanese
{'<5p4n>(%s, %s)', {japanese, extra}}, -- 5 - (japanese, extra)
{'%s<5p4n> (%s)', {romaji, japanese}}, -- 6 - romaji (japanese)
{'%s<5p4n> (%s, %s)', {romaji, japanese, extra}}, -- 7 - romaji (japanese, extra)
{'%s<5p4n>', {english}}, -- 8 - english
{'%s<5p4n> (%s)', {english, extra}}, -- 9 - english (extra)
{'%s<5p4n> (%s)', {english, romaji}}, -- 10 - english (romaji)
{'%s<5p4n> (%s, %s)', {english, romaji, extra}}, -- 11 - english (romaji, extra)
{'%s<5p4n> (%s)', {english, japanese}}, -- 12 - english (japanese)
{'%s<5p4n> (%s, %s)', {english, japanese, extra}}, -- 13 - english (japanese, extra)
{'%s<5p4n> (%s, %s)', {english, japanese, romaji}}, -- 14 - english (japanese, romaji)
{'%s<5p4n> (%s, %s, %s)', {english, japanese, romaji, extra}}, -- 15 - english (japanese, romaji, extra)
}  
local ret_string = nihongo_renderer (args, formatting, extra2)
ret_string = ret_string:gsub ('<5p4n>', '<span>'):gsub ('</5p4n>', '</span>'); -- replace 'secret' tags with proper tags
return ret_string; -- because gsub returns the number of replacements made as second return value
end  
--[=[-------------------------< N I H O N G O 3 >--------------------------------------------------------------  
An experiment to see how to implement using Module:Lang for language and transliteration markup  
Similar to but changes rendered order and does not support |lead=  
<English>, <japanese>, and <romaji> are positional parameters
<English>: rendered as presented; purports to be English translation of <kanji/kana>
<japanese>: Japanese language text using Japanese script; TODO: require?
<romaji>: Hepburn romanization (transliteration); TODO: in Module:Lang/data change tooltip text to 'Hepburn romanization'?
<extra> and <extra2> are positional or named: |extra= and |extra2=; mixing can be problematic
<extra> is rendered as presented preceeded with <comma><space>
<extra2> is rendered as presented preceeded with <space>  
]=]  
local function nihongo3
local lang_module = require ('Module:Lang' .. (:getTitle:match ('/sandbox') or '')); -- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else
local args = require ('Module:Arguments').getArgs ;  
local english, japanese, romaji, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5]; -- meaningful names
args[4] = extra or args[4]; -- ensure that extra is 'positional' for use by nihongo_renderer  
if not (japanese or romaji) then -- not present, return an error message
return nihongo_error ('nihongo3');
end
japanese = japanese and lang_module._lang ({'ja', japanese}) or nil;
romaji = romaji and lang_module._transl ({'ja', 'hepburn', romaji}) or nil;  
local formatting = { -- <5p4n> and </5p4n>: place holders for font-weight style spans; akin to stripmarkers, replaced before function returns
{'<5p4n>(%s)', {extra}}, -- 1 - (extra)
{'%s<5p4n>', {romaji}}, -- 2 - romaji
{'%s<5p4n> (%s)', {romaji, extra}}, -- 3 - romaji (extra)
{'<5p4n>(%s)', {japanese}}, -- 4 - japanese
{'<5p4n>(%s, %s)', {japanese, extra}}, -- 5 - (japanese, extra)
{'%s<5p4n> (%s)', {romaji, japanese}}, -- 6 - romaji (japanese)
{'%s<5p4n> (%s, %s)', {romaji, japanese, extra}}, -- 7 - romaji (japanese, extra)
{'%s<5p4n>', {english}}, -- 8 - english
{'%s<5p4n> (%s)', {english, extra}}, -- 9 - english (extra)
{'%s<5p4n> (%s)', {romaji, english}}, -- 10 - romaji (english)
{'%s<5p4n> (%s, %s)', {romaji, english, extra}}, -- 11 - romaji (english, extra)
{'%s<5p4n> (%s)', {english, japanese}}, -- 12 - english (japanese)
{'%s<5p4n> (%s, %s)', {english, japanese, extra}}, -- 13 - english (japanese, extra)
{'%s<5p4n> (%s, %s)', {romaji, japanese, english}}, -- 14 - romaji (japanese, english)
{'%s<5p4n> (%s, %s, %s)', {romaji, japanese, english, extra}}, -- 15 - romaji (japanese, english, extra)
}  
local ret_string = nihongo_renderer (args, formatting, extra2)
ret_string = ret_string:gsub ('<5p4n>', '<span>'):gsub ('</5p4n>', '</span>'); -- replace 'secret' tags with proper tags
return ret_string; -- because gsub returns the number of replacements made as second return value
end  
--[=[-------------------------< N I H O N G O _ F O O T >------------------------------------------------------  
An experiment to see how to implement using Module:Lang for language and transliteration markup  
<English>, <japanese>, and <romaji> are positional parameters
<English>: rendered as presented; purports to be English translation of <kanji/kana>
<japanese>: Japanese language text using Japanese script; TODO: require?
<romaji>: Hepburn romanization (transliteration); TODO: in Module:Lang/data change tooltip text to 'Hepburn romanization'?
<extra> and <extra2> are positional or named: |extra= and |extra2=; mixing can be problematic
<extra> is rendered as presented preceeded with <comma><space>
<extra2> is rendered as presented preceeded with <space>
<post> is positional or named: |post= is a postscript character preceding the tag (after <English>)
|lead=: takes one value 'yes'; renders language name same as but also adds Hepburn:<space> ahead of the romanization;
TODO: in Module:Lang, turnoff tooltip for transl when |lead=yes
in the live template |lead= also adds the Help:Installing Japanese character sets link; this is not supported in this code (nihongo nor nihongo3 have this support)
|group=: the group attribute in <ref group="..."> and in  
]=]  
local function nihongo_foot
local lang_module = require ('Module:Lang' .. (:getTitle:match ('/sandbox') or '')); -- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else
local args = require ('Module:Arguments').getArgs ;  
local english, japanese, romaji, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5]; -- meaningful names
args[4] = extra or args[4]; -- ensure that extra is 'positional' for use by nihongo_renderer
local post = args[6] or args.post;
local group = args.group;
local lead = 'yes' == args.lead; -- make boolean  
if not (japanese or romaji) then -- not present, return an error message
return nihongo_error ('nihongo foot');
end
if japanese then
japanese = lead and lang_module._lang_xx_inherit ({['code']='ja', japanese}) or lang_module._lang ({'ja', japanese}); -- add ja script with/without language prefix
end
if romaji then