-- This module implements [[Template:IPAc-ro]].localdata=mw.loadData('Module:IPAc-ro/data')localp={}-- Global container for tracking categorieslocalcategories={}-- Trims whitespace from a stringlocalfunctiontrim(s)returns:match('^%s*(.-)%s*$')end-- This implements [[Template:Nowrap]].localfunctionmakeNowrapSpan(s)localspan=mw.html.create('span'):addClass('nowrap'):wikitext(s)returntostring(span)endlocalfunctionmakePronunciationText(id)id=idandstring.lower(trim(id))ifidandid~=''anddata.pronunciation[id]thenreturndata.pronunciation[id].textendendlocalfunctiongetFilepath(file)returnmw.getCurrentFrame():callParserFunction('filepath',file)endlocalfunctionmakeAudioLink(file)categories["Articles including recorded pronunciations"]=truelocalspan=mw.html.create('span')span:addClass('noexcerpt'):wikitext(string.format('[[File:Speakerlink-new.svg|11px|link=%s|Listen]]',getFilepath(file))):tag('sup'):tag('span'):css('color','#00e'):css('font','bold 80% sans-serif'):css('padding','0 .1em'):addClass('IPA'):wikitext(string.format('[[:File:%s|i]]',file))returntostring(span)end-- This adds a tooltip icon to a label. It implements [[Template:H:title]].localfunctionmakeTooltip(label,tooltip)localspan=mw.html.create('span'):attr('title',tooltip):wikitext(label)returntostring(span)endlocalfunctionformatPhonemeGroup(phonemes)if#phonemes>0thenlocalspan=mw.html.create('span'):addClass('IPA nopopups'):wikitext(table.concat(phonemes))returntostring(span)elsereturn''endendlocalfunctionrenderCategories()localret={}forcatinpairs(categories)dotable.insert(ret,string.format('[[Category:%s]]',cat))endtable.sort(ret)returntable.concat(ret)endfunctionp._main(args)localret={}locali=0-- Keeps track of numbered args-- Pronunciationdolocalpron={}whiletruedoi=i+1localpronItem=makePronunciationText(args[i])ifpronItemthenpron[#pron+1]=pronItempron[#pron+1]=' 'elsebreakendendif#pron>0thenret[#ret+1]=string.format('<small>%s</small>',table.concat(pron))endend-- Audio linkdolocalfile=args.audioandtrim(args.audio)iffileandfile~=''thenret[#ret+1]=makeAudioLink(file)endend-- Phonemesdo-- Loop through the numbered args, separating them into phoneme groups-- and separator strings (both called "words" for convenience). We only-- underline the phoneme groups, not the separators.localwords={}words[#words+1]='['-- Opening slashi=i-1-- Set up i again as it was changed in the pronunciation looplocalidrepeatlocalphonemes={}localisWordEnd=falsewhilenotisWordEnddoi=i+1id=args[i]id=idandtrim(id)ifnotidthenisWordEnd=truewords[#words+1]=formatPhonemeGroup(phonemes)elseifid~=''thenlocalt=data.phonemes[id]ifnottthen-- We were passed an invalid id.isWordEnd=truecategories["Ill-formatted IPAc-ro transclusions"]=truewords[#words+1]=formatPhonemeGroup(phonemes)words[#words+1]=makeTooltip("'''[unsupported input]'''",'Unrecognized symbol')elseifnott.labelthen-- The data module contains bad data, so throw an error.error(string.format("no label was found for id '%s'",tostring(id)))elseift.tooltipthen-- We are dealing with a regular phoneme.phonemes[#phonemes+1]=makeTooltip(t.label,t.tooltip)else-- We are dealing with a separator.isWordEnd=truewords[#words+1]=formatPhonemeGroup(phonemes)words[#words+1]=t.labelendendenduntilnotidwords[#words+1]=']'-- Closing slash-- Wrap the words in a link to IPA help.localspan=mw.html.create('span'):addClass('IPA nopopups'):wikitext(string.format('[[Help:IPA/Romanian|%s]]',table.concat(words)))ret[#ret+1]=tostring(span)end-- Nowrap and categoriesret=makeNowrapSpan(table.concat(ret))..renderCategories()-- Reset the categories table in case we are run again.categories={}returnretendfunctionp.main(frame)returnp._main(frame:getParent().args)endreturnp