Zelda Wiki

Want to contribute to this wiki?
Sign up for an account, and get started!

Come join the Zelda Wiki community Discord server!

READ MORE

Zelda Wiki
Advertisement

local p = {}
local utilsTable = require("Module:UtilsTable")
local CODE_SORT_ORDER = {"enBr", "ja", "zh", "zhS", "zhT", "cs", "da", "nl", "fi", "fr", "frC", "frF", "de", "he", "hu", "it", "ko", "no", "pl", "ptB", "ptP", "ru", "es", "esS", "esL", "sv"}

--Returns the full formatted name of a language from the provided code
function p._CodeToLanguage(frame)
	return p.CodeToLanguage(frame.args["langcode"])
end

function p.CodeToLanguage(code)
	local result = "Unknown"
	
	if code == "enBr" then
		result = "English<sup><span class='explain' title='British' style='color:yellow;'>BR</sup>"	
	elseif code == "ja" then
		result = "Japanese"
	elseif code == "zh" then
		result = "Chinese"
	elseif code == "zhS" then
		result = "Chinese<sup><span class='explain' title='Simplified' style='color:yellow;'>SI</sup>"	
	elseif code == "zhT" then
		result = "Chinese<sup><span class='explain' title='Traditional' style='color:yellow;'>TR</sup>"
	elseif code == "cs" then
		result = "Czech"
	elseif code == "da" then
		result = "Danish"
	elseif code == "nl" then
		result = "Dutch"	
	elseif code == "fi" then
		result = "Finnish"
	elseif code == "fr" then
		result = "French"	
	elseif code == "frC" then
		result = "French<sup><span class='explain' title='Canadian' style='color:yellow;'>CA</sup>"	
	elseif code == "frF" then
		result = "French<sup><span class='explain' title='European' style='color:yellow;'>EU</sup>"	
	elseif code == "de" then
		result = "German"	
	elseif code == "he" then
		result = "Modern Hebrew"	
	elseif code == "hu" then
		result = "Hungarian"	
	elseif code == "it" then
		result = "Italian"	
	elseif code == "ko" then
		result = "Korean"	
	elseif code == "no" then
		result = "Norwegian"	
	elseif code == "pl" then
		result = "Polish"	
	elseif code == "ptB" then
		result = "Portuguese<sup><span class='explain' title='Brazilian' style='color:yellow;'>BR</sup>"	
	elseif code == "ptP" then
		result = "Portuguese<sup><span class='explain' title='European' style='color:yellow;'>EU</sup>"	
	elseif code == "ru" then
		result = "Russian"	
	elseif code == "es" then
		result = "Spanish"	
	elseif code == "esS" then
		result = "Spanish<sup><span class='explain' title='European' style='color:yellow;'>EU</sup>"	
	elseif code == "esL" then
		result = "Spanish<sup><span class='explain' title='Latin American' style='color:yellow;'>LA</sup>"	
	elseif code == "sv" then
		result = "Swedish"	
	end

	return result
end

--Returns a small flag image of the corresponding language code.
function p.CodeToFlag(code)
	local result = "Unknown"
	
	if code == "enBr" then
		result = "[[File:United Kingdom Flag.jpg|United Kingdom of Great Britain and Northern Ireland|20px|link=]]"
	elseif code == "ja" then
		result = "[[File:Japan Flag.png|Japan|20px|link=]]"
	elseif code == "zh" then
		result = "[[File:Traditional Chinese Flags.png|Republic of China, Hong Kong and Macao|20px|link=]]"
	elseif code == "zhS" then
		result = "[[File:China Flag.png|People's Republic of China|20px|link=]]"
	elseif code == "zhT" then
		result = "[[File:Traditional Chinese Flags.png|Republic of China, Hong Kong and Macao|20px|link=]]"
	elseif code == "cs" then
		result = "[[File:Czech Republic Flag.png|Czech Republic|20px|link]]"
	elseif code == "da" then
		result = "[[File:Kingdom of Denmark Flag.png|Kingdom of Denmark|20px|link]]"
	elseif code == "nl" then
		result = "[[File:Netherlands Flag.png|Netherlands|20px|link=]]"
	elseif code == "fi" then
		result = "[[File:Republic of Finland Flag.png|Republic of Finland|20px|link=]]"
	elseif code == "fr" then
		result = "[[File:French Republic Flag.png||20px|link=]]"	
	elseif code == "frC" then
		result =  "[[File:Canada Flag.png|Canada|20px|link=]]"
	elseif code == "frF" then
		result = "[[File:French Republic Flag.png|French Republic|20px|link=]]"
	elseif code == "de" then
		result = "[[File:Germany Flag.png|Federal Republic of Germany|20px|link=]]"
	elseif code == "he" then
		result = "[[File:State of Israel Flag.png|State of Israel|20px|link=]]"
	elseif code == "hu" then
		result = "[[File:Hungary Flag.png|Hungary|20px|link=]]"		
	elseif code == "it" then
		result = "[[File:Italy Flag.png|Italian Republic|20px|link=]]"	
	elseif code == "ko" then
		result = "[[File:Republic of Korea Flag.png|Republic of Korea|20px|link=]]"	
	elseif code == "no" then
		result = "[[File:Kingdom of Norway Flag.png|Kingdom of Norway|20px|link=]]"	
	elseif code == "pl" then
		result = "[[File:Republic of Poland Flag.png|Republic of Poland|20px|link=]]"
	elseif code == "ptB" then
		result = "[[File:Brazil Flag.png|Federative Republic of Brazil|20px|link=]]"	
	elseif code == "ptP" then
		result = "[[File:Portugal Flag.png|Portuguese Republic|20px|link=]]"
	elseif code == "ru" then
		result = "[[File:Russia Flag.png|Russian Federation|20px|link=]]"	
	elseif code == "esS" then
		result = "[[File:Spain Flag.png|Kingdom of Spain|20px|link=]]"
	elseif code == "esL" then
		result = "[[File:CELAC Flag.png|Community of Latin American and Caribbean States|20px|link=]]"
	elseif code == "sv" then
		result = "[[File:Kingdom of Sweden Flag.png|Kingdom of Sweden|20px|link=]]"
	end
	
	return result
end

-- Orders a list of languages in nomenclature table order.
function p.OrderCodes(codes)
	local orderedCodes = {}
	
	for key, value in pairs(CODE_SORT_ORDER) do
		if utilsTable.keyOf(codes, value) then
			table.insert(orderedCodes, value)
		end
	end
	
	return orderedCodes
end

function p.GetCodeSortOrder()
	return CODE_SORT_ORDER
end

return p
Advertisement