Module:Names

Jump to navigation Jump to search

Purpose

Template used to document the names or titles of pieces of media and subjects found in other languages or regions, as well as the name's meaning or translation, by specifying the language's ISO 639-1 code. This template is to be placed in Nomenclature sections.

Usage

Parameters for using Template:Exp, Template:Exp App, and ref tags are labeled with E. Parameters for romanizations (for languages with a non-Latin script) are labeled with R. Parameters for name meanings are labeled with M. If a language parameter is left blank or omitted, it will be skipped in the table.

This template also supports regional dialects (such as European Spanish and Latin American Spanish); these should only be used if a name or title differs between regions. I.e. if a media only has one regional localization, or if a subject's name or title is identical between regions, use the neutral language parameter.

This template also supports an arbitrary amount of names by putting numbers after the language code and, if applicable, after E, R, or M. These names will get their own rows. For the first row, the number 1 is optional; that is to say, both ja and ja1 work, for example. If both are specified, the unnumbered one takes priority.

{{Names
|en=English
|enM=
|enBr=British English
|enBrM=
|enAu=Australian English
|enAuM=
|ja=Japanese
|jaR=
|jaM=
|zhS=Simplified Chinese
|zhSR=
|zhSM=
|zhT=Traditional Chinese
|zhTR=
|zhTM=
|fr=French
|frM=
|frC=Canadian French
|frCM=
|frF=French of France
|frFM=
|de=German
|deM=
|it=Italian
|itM=
|ko=Korean
|koM=
|pl=Polish
|plM=
|pt=Portuguese
|ptM=
|ptB=Brazilian Portuguese
|ptBM=
|ptP=European Portuguese
|ptPM=
|ru=Russian
|ruM=
|es=Spanish
|esM=
|esS=European Spanish
|esSM=
|esL=Latin American Spanish
|esLM=
|tl=Tagalog
|tlM=
|tr=Turkish
|trM=
}}

Code

Minimal code

{{Names
|ja=
|jaR=
|jaM=
|zhS=
|zhSR=
|zhSM=
|zhT=
|zhTR=
|zhTM=
|fr=
|frM=
|de=
|deM=
|it=
|itM=
|ko=
|koR=
|koM=
|es=
|esM=
}}

All supported languages

{{Names
|en=
|enM=
|enBr=
|enBrM=
|enAu=
|enAuM=
|ja=
|jaR=
|jaM=
|zhS=
|zhSM=
|zhT=
|zhTM=
|fr=
|frM=
|frC=
|frCM=
|frF=
|frFM=
|de=
|deM=
|it=
|itM=
|ko=
|koR=
|koM=
|pl=
|plM=
|pt=
|ptM=
|ptB=
|ptBM=
|ptP=
|ptPM=
|ru=
|ruM=
|es=
|esM=
|esS=
|esSM=
|esL=
|esLM=
|tl=
|tlM=
|tr=
|trM=
}}

All supported languages with all fields

{{Names
|en=
|enE=
|enM=
|enBr=
|enBrE=
|enBrM=
|enAu=
|enAuE=
|enAuM=
|ja=
|jaE=
|jaR=
|jaM=
|zhS=
|zhSE=
|zhSR=
|zhSM=
|zhT=
|zhTE=
|zhTR=
|zhTM=
|fr=
|frE=
|frM=
|frC=
|frCE=
|frCM=
|frF=
|frFE=
|frFM=
|de=
|deE=
|deM=
|it=
|itE=
|itM=
|ko=
|koE=
|koR=
|koM=
|pl=
|plE=
|plM=
|pt=
|ptE=
|ptM=
|ptB=
|ptBE=
|ptBM=
|ptP=
|ptPE=
|ptPM=
|ru=
|ruE=
|ruR=
|ruM=
|es=
|esE=
|esM=
|esS=
|esSE=
|esSM=
|esL=
|esLE=
|esLM=
|tl=
|tlE=
|tlM=
|tr=
|trE=
|trM=
}}

All supported languages with all fields and two names for each

{{Names
|en=
|enE=
|enM=
|en2=
|enE2=
|enM2=
|enBr=
|enBrE=
|enBrM=
|enBr2=
|enBrE2=
|enBrM2=
|enAu=
|enAuE=
|enAuM=
|enAu2=
|enAuE2=
|enAuM2=
|ja=
|jaE=
|jaR=
|jaM=
|ja2=
|jaE2=
|jaR2=
|jaM2=
|zhS=
|zhSE=
|zhSR=
|zhSM=
|zhS2=
|zhSE2=
|zhSR2=
|zhSM2=
|zhT=
|zhTE=
|zhTR=
|zhTM=
|zhT2=
|zhTE2=
|zhTR2=
|zhTM2=
|fr=
|frE=
|frM=
|fr2=
|frE2=
|frM2=
|frC=
|frCE=
|frCM=
|frC2=
|frCE2=
|frCM2=
|frF=
|frFE=
|frFM=
|frF2=
|frFE2=
|frFM2=
|de=
|deE=
|deM=
|de2=
|deE2=
|deM2=
|it=
|itE=
|itM=
|it2=
|itE2=
|itM2=
|ko=
|koE=
|koR=
|koM=
|ko2=
|koE2=
|koR2=
|koM2=
|pl=
|plE=
|plM=
|pl2=
|plE2=
|plM2=
|pt=
|ptE=
|ptM=
|pt2=
|ptE2=
|ptM2=
|ptB=
|ptBE=
|ptBM=
|ptB2=
|ptBE2=
|ptBM2=
|ptP=
|ptPE=
|ptPM=
|ptP2=
|ptPE2=
|ptPM2=
|ru=
|ruE=
|ruR=
|ruM=
|ru2=
|ruE2=
|ruR2=
|ruM2=
|es=
|esE=
|esM=
|es2=
|esE2=
|esM2=
|esS=
|esSE=
|esSM=
|esS2=
|esSE2=
|esSM2=
|esL=
|esLE=
|esLM=
|esL2=
|esLE2=
|esLM2=
|tl=
|tlE=
|tlM=
|tl2=
|tlE2=
|tlM2=
|tr=
|trE=
|trM=
|tr2=
|trE2=
|trM2=
}}

Examples

Names in Japanese and other regions

{{Names
|en=Shin Megami Tensei: Nocturne
|enM=
|enBr=Shin Megami Tensei: Lucifer's Call
|enBrM=
|ja=真・女神転生III-NOCTURNE マニアクス
|jaR=Shin Megami Tensei Surī Nokutān Maniakusu
|jaM=Shin Megami Tensei III: Nocturne Maniax
}}
Names in Other Languages
Language Name Meaning
English Shin Megami Tensei: Nocturne
British English Shin Megami Tensei: Lucifer's Call
Japanese 真・女神転生III-NOCTURNE マニアクス Shin Megami Tensei Surī Nokutān Maniakusu Shin Megami Tensei III: Nocturne Maniax

Multiple names for the same language, with explanatory notes

{{Names
|en=Jack Frost
|en2=J. Frost
|enE2={{Exp App|DKLD}}
|ja=ジャクフロスト
|jaE={{Exp App|MT2}}
|jaR=Jaku furosuto
|jaM=Jack Frost
|ja2=ジャックフロスト
|jaR2=Jakku furosuto
|jaM2=Jack Frost
|ja3=ジャック・オ・フロスト
|jaE3={{Exp App|GMT}}
|jaR3=Jakku o furosuto
|jaM3=Jack-o'-Frost
}}
Names in Other Languages
Language Name Meaning
English Jack Frost
J. FrostDemiKids Light Version and Dark Version
Japanese ジャクフロストDigital Devil Story: Megami Tensei II
Jaku furosuto
Jack Frost
ジャックフロスト Jakku furosuto Jack Frost
ジャック・オ・フロストGiten Megami Tensei: Tokyo Revelation
Jakku o furosuto
Jack-o'-Frost

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	local languageList = {	"en", "enBr", "enAu", "ja", "zhS", "zhT", "fr", "frC", "frF", "de", "it", "ko", "pl", "pt", "ptB", "ptP", "ru", "es", "esS", "esL", "tl", "tr" }
	local languages = {
		["en"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "US" } } .. " English",
			ietf = "en",
			ietfRoman = "en"
		},
		["enBr"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "GB" } } .. " British English",
			ietf = "en-GB",
			ietfRoman = "en-GB"
		},
		["enAu"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "AU" } } .. " Australian English",
			ietf = "en-AU",
			ietfRoman = "en-AU"
		},
		["ja"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "JP" } } .. " Japanese",
			ietf = "ja",
			ietfRoman = "ja-Latn-hepburn"
		},
		["zhS"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "CN" } } .. " Simplified Chinese",
			ietf = "zh-Hans",
			ietfRoman = "zh-Latn-pinyin"
		},
		["zhT"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "TW" } } .. '<span style="font-size:smaller"> </span>' .. frame:expandTemplate{ title = "Flag", args = { "HK" } } .. '<span style="font-size:smaller"> </span>' .. frame:expandTemplate{ title = "Flag", args = { "MO" } } .. " Traditional Chinese",
			ietf = "zh-Hant",
			ietfRoman = "zh-Latn-pinyin"
		},
		["fr"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "FR" } } .. " French",
			ietf = "fr",
			ietfRoman = "fr"
		},
		["frC"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "CA" } } .. " Canadian French",
			ietf = "fr-CA",
			ietfRoman = "fr-CA"
		},
		["frF"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "FR" } } .. " Metropolitan French",
			ietf = "fr-FR",
			ietfRoman = "fr-FR"
		},
		["de"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "DE" } } .. " German",
			ietf = "de",
			ietfRoman = "de"
		},
		["it"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "IT" } } .. " Italian",
			ietf = "it",
			ietfRoman = "it"
		},
		["ko"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "KR" } } .. " Korean",
			ietf = "ko",
			ietfRoman = "ko-Latn"
		},
		["pl"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "PL" } } .. " Polish",
			ietf = "pl",
			ietfRoman = "pl"
		},
		["pt"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "PT" } } .. " Portuguese",
			ietf = "pt",
			ietfRoman = "pt"
		},
		["ptB"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "BR" } } .. " Brazilian Portuguese",
			ietf = "pt-BR",
			ietfRoman = "pt-BR"
		},
		["ptP"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "PT" } } .. " European Portuguese",
			ietf = "pt-PT",
			ietfRoman = "pt-PT"
		},
		["ru"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "RU" } } .. " Russian",
			ietf = "ru",
			ietfRoman = "ru-Latn"
		},
		["es"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "ES" } } .. " Spanish",
			ietf = "es",
			ietfRoman = "es"
		},
		["esS"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "ES" } } .. " European Spanish",
			ietf = "es-ES",
			ietfRoman = "es-ES"
		},
		["esL"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "CL" } } .. " Latin American Spanish",
			ietf = "es-419",
			ietfRoman = "es-419"
		},
		["tl"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "PH" } } .. " Tagalog",
			ietf = "tl",
			ietfRoman = "tl"
		},
		["tr"] = {
			label = frame:expandTemplate{ title = "Flag", args = { "TR" } } .. " Turkish",
			ietf = "tr",
			ietfRoman = "tr"
		},
	}
	
	local output = ""
	local function makeRow(lang)
		local nameList = {}
		local romanList = {}
		local noteList = {}
		local meaningList = {}
		local x = 1
		if args[lang] then --Case for if there is no number.
			table.insert(nameList,x,args[lang])
			if args [lang .. "R"] then
				table.insert(romanList,x,args[lang .. "R"])
			end
			if args [lang .. "E"] then
				table.insert(noteList,x,args[lang .. "E"])
			end
			if args [lang .. "M"] then
				table.insert(meaningList,x,args[lang .. "M"])
			end
			x = x + 1
		end
		while args[lang .. x] do
			table.insert(nameList,x,args[lang .. x])
			if args [lang .. "R" .. x] then
				table.insert(romanList,x,args[lang .. "R" .. x])
			end
			if args [lang .. "E" .. x] then
				table.insert(noteList,x,args[lang .. "E" .. x])
			end
			if args [lang .. "M" .. x] then
				table.insert(meaningList,x,args[lang .. "M" .. x])
			end
			x = x + 1
		end
		if #nameList > 0 then
			output = output .. '\n| rowspan="' .. #nameList .. '" | ' .. languages[lang]["label"]
			for i = 1,#nameList do
				local romanization = ""
					if romanList[i] then
					romanization = string.format(" <span lang=\"%s\">''%s''</span>", languages[lang]["ietfRoman"], romanList[i])
				end
				local note = ""
				if noteList[i] then
					note = noteList[i]
				end
				local meaning = ""
				local colspan = 1
				if meaningList[i] then
					meaning = " || " .. meaningList[i]
				else
					colspan = 2
				end
				output = output .. '\n| colspan="' .. colspan .. '" | <span lang="'.. languages[lang]["ietf"] .. '">' .. nameList[i] .. "</span>" .. note .. romanization .. meaning .. "\n|-"
			end
		end
	end
	
	for i, lang in ipairs(languageList) do
		makeRow(lang)
	end
	
	return output
end

return p