Modul:families/templates

Vikilug‘atdan olingan

Bu modul uchun Modul:families/templates/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}

function export.exists(frame)
	local args = frame.args
	local fam = args[1] or error("Oila kodi belgilangan olinmagan. Moduli nolish uchun parametrni 1 oʻtishi qiling.")
	
	fam = require("Module:families").getByCode(fam)
	
	if fam then
		return "1"
	else
		return ""
	end
end

function export.getByCode(frame)
	local args = frame.args
	local fam = args[1] or error("Oila kodi (parametr 1) belgilangan olinmagan.")
	local itemname = args[2] or error("Funktsiya qoʻngʻiroq qilish (parametr 2) belgilangan olinmagan.")
	
	fam = require("Module:families").getByCode(fam) or error("Oila kodi '" .. fam .. "' haqiqiy emas.")
	
	-- Mehmon qarash boʻldim, deb xabar
	if itemname == "getCanonicalName" then
		return fam:getCanonicalName()
	elseif itemname == "getOtherNames" then
		local index = args[3]; if index == "" then index = nil end
		index = tonumber(index or error("Roʻyxati (parametr 3) istalgan element soni indeksi koʻrsatilgan olinmagan."))
		return fam:getOtherNames()[index] or ""
	elseif itemname == "getFamily" then
		return fam:getFamily():getCode()
	elseif itemname == "getCategoryName" then
		return fam:getCategoryName()
	else
		error("Talab qilingan bemor xabar nomi \"" .. itemname .. "\".")
	end
end

function export.getByCanonicalName(frame)
	local args = frame.args
	local famname = args[1] or error("Oila nomi koʻrsatilgan olinmagan. Moduli nolish uchun parametrni 1 o'tishi qiling.")
	
	local fam = require("Module:families").getByCanonicalName(famname)
	
	if fam then
		return fam:getCode()
	else
		return ""
	end
end

return export