Module:Languages

From Wikidata
Jump to navigation Jump to search

Documentation for this module may be created at Module:Languages/doc

local tab1 = {}

function tab1.langcodeen(frame)
	local allcodes = mw.loadData("Module:languages/index")

	local args = frame.args
	local v1 = args[1] or error("No language code given")
	local langinfo = allcodes[v1] or error(string.format('Unknown language code "%s"', v1))

	local itemname = args[2] or error("No item name given")
	local item = langinfo[itemname]
 
	if type(item) == "table" then
		return item[tonumber(args[3] or 1)]
	else
		return item
	end
end

function tab1.translatethis( frame )
	local translation = mw.loadData("Module:TranslateThis")
	return translation
end

return tab1