Module:User:Erutuon/languages/templates

Hello, you have come here looking for the meaning of the word Module:User:Erutuon/languages/templates. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Erutuon/languages/templates, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Erutuon/languages/templates in singular and plural. Everything you need to know about the word Module:User:Erutuon/languages/templates you have here. The definition of the word Module:User:Erutuon/languages/templates will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Erutuon/languages/templates, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This is a private module sandbox of Erutuon, for his own experimentation. Items in this module may be added and removed at Erutuon's discretion; do not rely on this module's stability.


local export = {}

function export.getByCode(frame)
	local args = frame.args
	local langcode = args or error("Language code has not been specified. Please pass parameter 1 to the module invocation.")
	local itemname = args or error("Type of information to look up has not been specified. Please pass parameter 2 to the module invocation.")
	
	local lang = require("Module:User:Erutuon/languages").getByCode(langcode)
	
	if not lang then
		error("The language code '" .. langcode .. "' is not valid.")
	end
	
	
	-- The item that the caller wanted to look up
	
	if itemname == "getOtherNames" then
		local index = args; if index == "" then index = nil end
		index = tonumber(index) or error("Please specify the numeric index of the desired name.")
		return lang:getOtherNames() or ""
	elseif itemname == "getFamily" then
		return lang:getFamily():getCode()
	elseif itemname == "getWikimediaLanguages" then
		local index = args; if index == "" then index = nil end
		index = tonumber(index) or error("Please specify the numeric index of the desired language.")
		local langs = lang:getWikimediaLanguages()
		
		if langs then
			return langs:getCode()
		else
			return ""
		end
	elseif itemname == "getScripts" then
		local index = args; if index == "" then index = nil end
		index = tonumber(index) or error("Please specify the numeric index of the desired script.")
		local scripts = lang:getScriptCodes()
		
		if scripts then
			return scripts
		else
			return ""
		end
	elseif itemname == "getAncestors" then
		local index = args; if index == "" then index = nil end
		index = tonumber(index) or error("Please specify the numeric index of the desired ancestor.")
		local ancestors = lang:getAncestors()
		
		if ancestors then
			return ancestors:getCode()
		else
			return ""
		end
	elseif itemname == "transliterate" then
		local text = args; if text == "" then text = nil end
		local sc = args; if sc == "" then sc = nil end
		local module_override = args; if module_override == "" then module_override = nil end
		sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
		return lang:transliterate(text, sc, module_override) or ""
	elseif itemname == "makeEntryName" then
		local text = args; if text == "" then text = nil end
		return lang:makeEntryName(text) or ""
	elseif itemname == "makeSortKey" then
		local text = args; if text == "" then text = nil end
		return lang:makeSortKey(text) or ""
	elseif lang then
		local ret = lang(lang)
		
		if type(ret) == "string" then
			return ret
		else
			error("The function \"" .. itemname .. "\" did not return a string value.")
		end
	else
		error("Requested invalid item name \"" .. itemname .. "\".")
	end
end

return export