localp={}localnsc=require('Module:Navseasoncats')functionp.cbd(frame)localcurrtitle=mw.title.getCurrentTitle()localtestcases=(currtitle.subpageText=='testcases')localavoidself=(currtitle.text~='Navseasoncats with centuries below decade'and--avoid selfcurrtitle.text~='Navseasoncats with centuries below decade/doc'and--avoid selfcurrtitle.text~='Navseasoncats with centuries below decade/sandbox'and--avoid self(currtitle.nsText~='الگو'ortestcases))--avoid nested transclusion errorslocaltestcase=frame:getParent().args[1]iftestcase==nilandavoidself==falsethenreturn''endlocalpagename=testcaseorcurrtitle.baseTextlocalfindvar=nsc.find_var(pagename)--picks up decades/seasons/etc.iffindvar[1]=='error'thenlocalerrorout=''ifavoidselfthenlocalerrors=nsc.errorclass('Function find_var ناتوان در شناسایی دهه برای ردهٔ «'..pagename..'».')errorout=nsc.failedcat(errors,'P')iftestcasesthenstring.gsub(errorout,'(%[%[)(رده)','%1:%2')endendreturnerroroutendlocaldecade=tonumber(string.match(findvar[2],'^(%d+)s'))ifdecade==nilorfindvar[1]~='decade'thenlocalerrorout=''ifavoidselfthenlocalerrors=nsc.errorclass('{{Navseasoncats with centuries below decade}} can\'t recognize the decade for category "'..pagename..'".')errorout=nsc.failedcat(errors,'P')iftestcasesthenstring.gsub(errorout,'(%[%[)(Category)','%1:%2')endendreturnerroroutendlocalfirstpart,lastpart=string.match(pagename,'^(.*)'..findvar[2]..'(.*)$')firstpart=mw.text.trim(firstpartor'')lastpart=mw.text.trim(lastpartor'')localnav1=''iftestcasethenlocalargs={testcase=testcase}nav1=frame:expandTemplate{title='Navseasoncats',args=args}--not sure how else to pass frame & args togetherelsenav1=nsc.navseasoncats(frame)endlocalcentury=math.floor(((decade-1)/100)+1)--from {{CENTURY}}ifstring.match(decade,'00$')thencentury=century+1end--'2000' is technically in the 20th, but the rest of the 2000s is in the 21stlocalcenturycat=mw.text.trim(firstpart..' '..nsc.addord(century)..' century '..lastpart)localexists=mw.title.new(centurycat,'Category').existsifnotexiststhen--check for hyphenated centurycenturycat=mw.text.trim(firstpart..' '..nsc.addord(century)..'-century '..lastpart)exists=mw.title.new(centurycat,'Category').existsendifexiststhenlocalargs={['century-below-decade']=centurycat}localnav2=frame:expandTemplate{title='Navseasoncats',args=args}--not sure how else to pass frame & args togetherreturn'<div style="display:block !important; max-width: calc(100% - 25em);">'.."\n"..nav1..nav2.."\n"..'</div>'elsereturnnav1endendreturnp