Module:Translations

local m_links = require("Module:links") local m_data = mw.loadData("Module:translations/data")

local export = {}

-- The main entry point. -- This is the only function that can be invoked from a template. function export.show(frame) local params = { [1] = {required = true, default = "und"}, [2] = {},		[3] = {list = true}, ["alt"] = {}, ["id"] = {}, ["sc"] = {}, ["tr"] = {}, ["ts"] = {}, ["lit"] = {}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local terminfo = { lang = require("Module:languages").getByCode(args[1]) or require("Module:languages").err(args[1], 1), sc = (args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. args["sc"] .. "\" is not valid.")) or nil), term = args[2] or (mw.title.getCurrentTitle.nsText == "Template" and "term") or nil, alt = args["alt"], id = args["id"], genders = args[3], tr = args["tr"], ts = args["ts"], lit = args["lit"], interwiki = frame.args["interwiki"], }	return export.show_terminfo(terminfo) end

function export.show_terminfo(terminfo, no_check_redundant_translit) -- Translations must be for mainspace languages if terminfo.lang:getType ~= "regular" then error("Translations must be for attested and approved main-namespace languages.") end -- Don't show the interwiki link if there is nothing to link to. if terminfo.term then -- Track translations for particular languages if m_data.tracked[terminfo.lang:getCode] then require("Module:debug/track")("translations/" .. terminfo.lang:getCode) end local wmlangs = {} if m_data.interwiki_langs[terminfo.lang:getCode] then wmlangs = {require("Module:wikimedia languages").getByCode(m_data.interwiki_langs[terminfo.lang:getCode])} else wmlangs = terminfo.lang:getWikimediaLanguages end -- Don't show the interwiki link if the language is not recognised by Wikimedia -- or if the term contains links (for SOP translations) if terminfo.term:find("(" .. wmlangs[1]:getCode .. ") "		end	else		-- Track what entries currently don't provide a term		require("Module:debug/track")("translations/no term")		require("Module:debug/track")("translations/no term/" .. terminfo.lang:getCode)	end	if terminfo.lang and m_data.need_super[terminfo.lang:getCode] and terminfo.tr then		terminfo.tr = mw.ustring.gsub(terminfo.tr, '([1-9]%-?[1-9]?)','%1')	end	return m_links.full_link(terminfo, "translation", true, no_check_redundant_translit) end

return export