सामग्री पर जाएँ

मॉड्यूल:User:Jberkel/usex/templates

विक्षनरी से

"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:User:Jberkel/usex/templates/doc पर बनाया जा सकता है"

local m_usex = require("Module:User:Jberkel/usex")

local export = {}

function export.usex_t(frame)
	local params = {
		[1] = {required = true},
		[2] = {},
		[3] = {},
		
		["inline"] = {type = "boolean"},
		["noenum"] = {type = "boolean"},
		["ref"] = {},
		["lit"] = {},
		["sc"] = {},
		["t"] = {alias_of = 3},
		["translation"] = {alias_of = 3},
		["tr"] = {},
		["transliteration"] = {alias_of = "tr"},
		["qualifier"] = { list = true }
	}
	
	local quote = (frame.args["quote"] or "") ~= ""
	local compat = (frame.args["compat"] or "") ~= ""
	
	if compat then
		params["lang"] = {required = true}
		params["t"].alias_of = 2
		params["translation"].alias_of = 2
		table.remove(params, 1)
	end
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local lang = args[compat and "lang" or 1] or "und"
	local sc = args["sc"]
	
	lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
	sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
	
	local usex = args[compat and 1 or 2]
	local translation = args[compat and 2 or 3]
	local transliteration = args["tr"]
	local noenum = args["noenum"]
	local inline = args["inline"]
	local ref = args["ref"]
	local lit = args["lit"]
	local qualifier = args["qualifier"]
	
	return m_usex.format_usex(lang, sc, usex, translation, transliteration, noenum, inline, ref, quote, lit, qualifier)
end

return export