-- from here english is used in the mapping but not rendered by renderer so not included in the table
{*, {*}}, -- 8 - english
{'%s', {extra}}, -- 9 - extra
{'%s', {romanized}}, -- 10 - romanized
{'%s, %s', {romanized, extra}}, -- 11 - romanized, extra
{'%s', {native}}, -- 12 - native
{'%s, %s', {native, extra}}, -- 13 - native, extra
{'%s, %s', {native, romanized}}, -- 14 - native romanized
{'%s, %s, %s', {native, romanized, extra}}, -- 15 - native romanized, extra
}  
if english and post then -- rewrite english to include |post=
english = english .. post; -- if english has a value append post else just post
elseif post then
english = post; -- english not set, use post
elseif not english then -- neither are set
english = ''; -- make english an empty string for concatenation
end  
if native or romanized or extra or extra2 then -- no ref tag when of these are set (it would be empty)
local content = renderer (args, formatting, extra2);
content = content:gsub ('<5p4n>', *):gsub ('</5p4n>$', *, 1); -- strip secret <5p4n> and </5p4n> tags added by renderer; spans not used by this template  
if english:match ('\'\'+$') then -- if <english> is italic, bold, or both
local text = english:gsub ('%b<>', *):gsub ('\'\'+', *):gsub ('%[%[', *):gsub ('%]%]', *); -- strip markup
if text:match ('[dfijkltCEFHIJKMNPR-Z\'"%?!%]]$') then -- when <english> ends with one of these characters
english = '<span>' .. english .. '</span>'; -- add kerning
end
end  
return english .. :extensionTag ({name='ref', args={group=group, name=ref_name}, content=content}); -- english with attached reference tag
else
return english; -- nothing to be inside ref tag so just return english
end
end  
--[=[-------------------------< N I H O N G O >----------------------------------------------------------------  
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>
|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
return common (, 'nihongo')
end  
--[=[-------------------------< N I H O N G O 3 >--------------------------------------------------------------  
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
return common_romanized_native_translated (, 'nihongo3')
end  
--[=[-------------------------< N I H O N G O _ K R T >--------------------------------------------------------  
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 nihongo_krt
return common_native_romanized_translated (, 'nihongo krt')
end  
--[=[-------------------------< N I H O N G O _ F O O T >------------------------------------------------------  
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 tag (after <English>)
|lead=: takes one value 'yes'; renders language name same as but also adds Pinyin:<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 Chinese character sets link; this is not supported in this code (hanyu nor hanyu3 have this support)
|group=: the group attribute in <ref group="..."> and in  
]=]  
local function hanyu_foot
return common_foot (, 'hanyu foot')
end  
----------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------  
return {
nihongo = nihongo,
nihongo3 = nihongo3,
nihongokrt = nihongo_krt, -- TODO: rename function name in to use nihongo_krt; delete this line
nihongo_krt = nihongo_krt,
nihongo_foot = nihongo_foot,  
hanyu = hanyu,
hanyu3 = hanyu3,
hanyu_hrt = hanyu_hrt,
hanyu_foot = hanyu_foot,
}