localexport={}localm_links=require("Module:links")functionexport.show(frame)localargs=frame:getParent().argslocallang=args["lang"];iflang==""thenlang=nilendifnotlangthenlang="en"endlang=require("Module:languages").getByCode(lang)orerror("The language code \""..lang.."\" is not valid.")localtext=""localterms={}-- because args is unmodifiable--make the term empty string if only the alternate text existsforname,parameterinpairs(args)dolocalregex=mw.ustring.match(tostring(name),"^alt%d+$")ifregexthenlocalindex=tonumber((name:gsub("alt","")))ifnotargs[index]thenterms[index]=""endendend--copy all unnamed parameters to termsfori,paraminipairs(args)doterms[i]=paramend--main processlocalcomma=falselocalcount=0fori,parameterinipairs(terms)docount=count+1ifcommathentext=text..", "elsecomma=trueendlocalalt=args["alt"..tostring(i)]localtr=args["tr"..tostring(i)]ifparameter==""thentext=text..altelsetext=text..m_links.full_link({lang=lang,term=parameter,alt=alt,tr=tr})endend--return processifcount>1then--add an "s" to "Homophone" if there is more than one termreturn"Homophones: "..textelseifcount==1then--no "s" if there is only one termreturn"Homophone: "..textend--if there is no term at all, return default text if namespace is Templateifmw.title.getCurrentTitle().nsText=="Template"thenreturn"Homophone: [[term#Scots|term]]"end--if this line is parsed, there are no terms at all and the namespace is not Templateerror("Please provide at least one homophone.")endreturnexport