Module:User:Babr

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Inflection of کِتَاب
singular plural
bare کِتَاب کِتَابهَا
definite object کِتَابرَا کِتَابرَاهَا
ezafe کِتَابِ کِتَابهَاِ
indefinite, definite relative bare کِتَابی کِتَابیهَا
object کِتَابیرَا کِتَابیرَاهَا
Inflection of китоб (kitob)
singular plural
bare китоб (kitob) китобҳо (kitobho)
definite object китобро (kitobro) китоброҳо (kitobroho)
izofa китоби (kitob-i) китобҳои (kitobho-yi)
indefinite, definite relative bare китобе (kitobe) китобеҳо (kitobeho)
object китоберо (kitobero) китобероҳо (kitoberoho)

local export = {}

local frame = mw.getCurrentFrame()
local lang = require("Module:languages").getByCode(frame.args[1])
local iut = require('Module:inflection utilities')
local m_string_utilities = require("Module:string utilities")
local m_links = require("Module:links")
local m_translit = require('Module:fa-translit').tr
local u = require('Module:string/char')

-- diacritics
local ZWNJ = u(0x200c)
local zabar = u(0x064e)
local zer = u(0x0650)
local pesh = u(0x064f)
local sukuun = u(0x0652)

if frame.args[1] ~= "tg" then
	example =  'کِتَاب' 
	izafa = 'ezafe'
	raa = "رَا"
	indef = "ی"
	plural = "هَا"
	izf = zer
		else
	example = 'китоб'
	izafa = 'izofa'
	raa = "ро"
	indef = "е"
	plural = "ҳо"
	izf = "и"
		end

local function get_stylesheet()
	return require("Module:TemplateStyles")("Module:ur-conj/style.css")
end

local gsub = m_string_utilities.gsub
local sub = m_string_utilities.sub
--local pagename = mw.title.getCurrentTitle().text -- might not be needed but just in case

local parent_args = frame:getParent().args

	local params = {
		[1] = {required = true },
		[2] = {},
		[3] = {list = true},
		["alt"] = {},
		["id"] = {},
		["sc"] = {type = "script"},
		["tr"] = {},
		["ts"] = {},
		["lit"] = {},
	}
	
local data = {
 [1] = { 
	name = "bare",
	data = { "", plural , ""}, 
 },
 [2] = { 
	name = "definite object",
	data = { "", plural , ""},	
 },
 [3] = { 
	name = "ezafe",
	data = { "", plural , ""},	
 },
 [4] = {
 	name = "indefinite",
 	data = {
 		{
 			name = "bare",
 			data = { indef },	
 		}, 
 	 	{ 
 	 		name = "object",
 	 		data = { indef .. raa },
 	 	},
 	 	 	},
 	   }  
}

local function make_link(text, tr)
	if lang == "fa" then
	multi_translit = m_translit(text)
	return m_links.full_link({term = text, tr = multi_translit(text), lang = lang}, "term")
	else
	return m_links.full_link({term = text, tr = tr, lang = lang}, "term")
	end end

function export.show(frame)
	local args = frame:getParent().args
	local word = args[1] or mw.title.getCurrentTitle().text
	if frame.args[1] ~= "tg" then
	example =  'کِتَاب' 
	izafa = 'ezafe'
	raa = "رَا"
	indef = "ی"
	plural = "هَا"
	izf = zer
		else
	example = 'китоб'
	izafa = 'izofa'
	raa = "ро"
	indef = "е"
	plural = "ҳо"
	izf = "и"
		end
	if word == 'User:Babr' then 
	word = example
	end
	
	-- 
	if args["broken2"] and not args["broken"] then
		error("A second broken plural was specified, but the first broken plural was not found.")
		end

	local res = {'{| class="wikitable vsSwitcher autocollapsed inflection-table" style="text-align:center; border: 0.5px solid #CCC;"' }
	table.insert(res, '! class="vsToggleElement" colspan=\"8\" | Inflection of <i>' .. make_link(word) .. '</i>' )
	table.insert(res, '|- class="vsHide"')
	table.insert(res, '! style=\"background:#eaecf0\" colspan=\"2\" |' ) 
	if args["broken"] then rows = 2 end
	if not args["nosg"] then
	table.insert(res, '! style=\"background:#eaecf0;\"| singular') 
	if args["broken"] then rows = 2 end end
	if not args["nopl"] then
	table.insert(res, '! style=\"background:#eaecf0;\" | plural' )
	if args["broken"] or args["broken2"] 
	then if args["broken2"] then rows = 3 else rows = 2 end end end
	table.insert(res, '|- class="vsHide"')
	if args["broken"] then
	table.insert(res, '! style=\"background:#eaecf0;\" | sound')
	table.insert(res, '! style=\"background:#eaecf0;\" | broken')
	if args["broken2"] then
	table.insert(res, '! style=\"background:#eaecf0;\" | or broken')
	end 
	table.insert(res, '|- class=\"vsHide\"') end
	table.insert(res, '! style="background:#eaecf0" colspan="2" | bare')
	table.insert(res, '|' .. make_link(word))
	table.insert(res, '|' .. make_link(word .. plural))
	table.insert(res, '|- class=\"vsHide\"') 
	table.insert(res, '! style="background:#eaecf0" colspan="2" | definite object')
	table.insert(res, '|' .. make_link(word .. raa))
	table.insert(res, '|' .. make_link(word .. raa .. plural))
	table.insert(res, '|- class=\"vsHide\"') 
	table.insert(res, '! style="background:#eaecf0" colspan="2" |' .. izafa )
	table.insert(res, '|' .. make_link(word .. izf))
	table.insert(res, '|' .. make_link(word .. plural .. izf))
	table.insert(res, '|- class=\"vsHide\"') 
	table.insert(res, '! style="background:#eaecf0" rowspan="2" | indefinite, definite relative ')
	table.insert(res, '! style="background:#eaecf0" | bare')
	table.insert(res, '|' .. make_link(word .. indef))
	table.insert(res, '|' .. make_link(word .. indef .. plural))
	table.insert(res, '|- class=\"vsHide\"') 
	table.insert(res, '! style="background:#eaecf0" | object')
	table.insert(res, '|' .. make_link(word .. indef .. raa))
	table.insert(res, '|' .. make_link(word .. indef .. raa .. plural))
	table.insert(res, '|}')
	return table.concat(res, "\n") .. get_stylesheet()
	end

return export