ماڈیوٗل:from

وِکیٖلۄغَتھ پؠٹھٕ

"یَمہٕ ماڈیوٗلُک دَستاویز ییٚہِ ماڈیوٗل:from/دَستاویز جاے بَناونہٕ"

local p = {}
local lang_codes = require("Module:lang name")
function p.trim(s)
   return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function p.from_small(params)
	l1 =  p.trim(params.args.l1)
	l2 =  p.trim(params.args.l2)
	w = p.trim(params.args.w)
	tr =  p.trim(params.args.tr)
	t = p.trim(params.args.t)
	if l1 ~= "" and l2 ~= "" then
		if l1 == l2 then
			return "[[" .. w .. "]] پؠٹھٕ"
		else
			anc = lang_codes.get_lang_name(l2)
			inh = lang_codes.plural_lang(l1)
			local cat_name = '[[Category:' .. anc ..' پؠٹھٕ آمٕتؠ '..inh..' لَفٕظ '..']]'
			local text = lang_codes.get_lang_name(l2) .. " "
			if w ~= "" and w ~= nil then
				text = text .. '[[' .. w .. '#' .. anc .. '|' .. w ..']]'
				if tr ~= '' and tr ~= nil then
					text = text .. ' (' .. tr
					if t ~= nil and  p.trim(t) ~= "" then
						text = text .. "، “" .. t .. "”"
					end
					text = text .. ') '
				else
					if t ~= nil and  p.trim(t) ~= "" then
						text = text .. " (“" .. t .. "”)"
					end
				end
			end
			return cat_name .. '\n' .. text
		end
	else
		error("No ancestor term provided")
	end
end
	
function p.from(params)
	l1 =  p.trim(params.args.l1)
	l2 =  p.trim(params.args.l2)
	w = p.trim(params.args.w)
	tr =  p.trim(params.args.tr)
	t = p.trim(params.args.t)
	if l1 ~= "" and l2 ~= "" then
		if l1 == l2 then
			return "[[" .. w .. "]] پؠٹھٕ"
		else
			anc = lang_codes.get_lang_name(l2)
			inh = lang_codes.plural_lang(l1)
			local cat_name = '[[Category:' .. anc ..' پؠٹھٕ آمٕتؠ '..inh..' لَفٕظ '..']]'
			local text = ''
			text = text .. anc .. " پؠٹھٕ آمُت : "
			if w ~= "" and w ~= nil then
				text = text .. '[[' .. w .. '#' .. anc .. '|' .. w ..']]'
				if tr ~= '' and tr ~= nil then
					text = text .. ' (' .. tr
					if t ~= nil and  p.trim(t) ~= "" then
						text = text .. "، “" .. t .. "”"
					end
					text = text .. ') '
				else
					if t ~= nil and  p.trim(t) ~= "" then
						text = text .. " (“" .. t .. "”)"
					end
				end
			end
			return cat_name .. '\n' .. text
		end
	else
		error("No ancestor term provided")
	end
end
return p