ماڈیوٗل:جِنٕس زٲژ
"یَمہٕ ماڈیوٗلُک دَستاویز ییٚہِ ماڈیوٗل:جِنٕس زٲژ/دَستاویز جاے بَناونہٕ"
local math_mod = require( "Module:Math" )
local p = {}
local useCategory = {
["Q43445"] = " ", -- animal gender (male), no category
["Q44148"] = " ", -- animal gender (female), no category
["Q48270"] = " ", -- genderqueer, no category at the moment
["Q189125"] = " ", -- transgender, no category at the moment
["Q1052281"] = " " , -- transwoman, no category at the moment
["Q1097630"] = " ", -- intersexual, no category at the moment
["Q2449503"] = " " , -- transman, no category at the moment
["Q6581072"] = "[[Category:زٕنؠ]]",
["Q6581097"] = "[[Category:مَرٕد]]",
["Q18116794"] = " ", -- genderfluid, no category at the moment
["Q27679684"] = " ", -- transfeminine, no category at the moment
["Q96000630"] = " " -- X-gender, no category at the moment
}
local function selectSingleClaim(claims)
if not claims then
return nil
end
local selectedClaim = nil
for idx,claim in pairs(claims) do
if claim.rank == 'preferred' then
return claim
end
if claim.rank == 'normal' then
if not selectedClaim then
selectedClaim = claim
end
end
end
return selectedClaim
end
-- Return gender for article
function p.gendercategory(frame)
if not mw.wikibase then
return ""
end
local article = mw.wikibase.getEntityObject()
if not article then
local nsp = mw.title.getCurrentTitle().namespace
if nsp == 0 then -- only categorize articles
return "[[Category: مَضموٗن یِمَن نہٕ وِکی ڈیٹا اِندراجَن سٲتؠ جوڈ چھُ ]]"
end
return ""
end
local claims = article.claims
if not claims then
return "[[Category:مَضموٗن یِم وِکی ڈیٹا سِٹیٹمینٹ وَرٲے چھِ ]]"
end
local p21 = selectSingleClaim(claims.P21)
if not p21 then
local p31 = claims.P31
if p31 then
local instance = p31[1].mainsnak.datavalue.value["numeric-id"]
if instance == 5 then
return "[[Category:مَضموٗن یِمَن نہٕ وِکی ڈیٹا پؠٹھ جِنٕس سِٹیٹمینٹ چھُ ]]"
end
end
return ""
end
if p21.mainsnak.datavalue == nil then
return "[[Category:نامعلوٗم جِنٕس]]"
else
local genderid = p21.mainsnak.datavalue.value["numeric-id"]
local gender = "Q" ..genderid
local gendercat = useCategory[gender] or "[[Category:نامعلوٗم جِنٕس]]"
return gendercat
end
end
function p.statistics()
local men = mw.site.stats.pagesInCategory("مَرٕد", "pages")
local women = mw.site.stats.pagesInCategory("زٕنؠ", "pages")
local all = men+women
local menPct = men*100/all
local womenPct = women*100/all
return "اِنسانَن مُتلِق مَضموٗن :<br/>" ..
"- زٕنؠ " .. mw.language.getContentLanguage():formatNum(women) .. " (" .. math_mod._precision_format(womenPct,2) .. " %)<br/>" ..
"- مَرٕد " .. mw.language.getContentLanguage():formatNum(men) .. " (" .. math_mod._precision_format(menPct,2) .. " %)"
end
return p