Module:IPAc-en
- Аԥсшәа
- Afrikaans
- अंगिका
- العربية
- الدارجة
- مصرى
- অসমীয়া
- Asturianu
- Azərbaycanca
- تۆرکجه
- Basa Bali
- Bikol Central
- Bajau Sama
- Betawi
- भोजपुरी
- ပအိုဝ်ႏဘာႏသာႏ
- বাংলা
- Bosanski
- Cebuano
- کوردی
- Cymraeg
- ཇོང་ཁ
- Ελληνικά
- English
- فارسی
- Føroyskt
- Galego
- ગુજરાતી
- Hausa
- Hrvatski
- Հայերեն
- Արեւմտահայերէն
- Bahasa Indonesia
- Ilokano
- Íslenska
- 日本語
- Jawa
- Qaraqalpaqsha
- Gĩkũyũ
- 한국어
- Kurdî
- Ladin
- मैथिली
- Māori
- മലയാളം
- Монгол
- ဘာသာမန်
- Bahasa Melayu
- မြန်မာဘာသာ
- नेपाली
- Norsk bokmål
- ଓଡ଼ିଆ
- ਪੰਜਾਬੀ
- Português
- Scots
- Srpskohrvatski / српскохрватски
- တႆး
- Simple English
- Slovenščina
- Anarâškielâ
- Српски / srpski
- Sunda
- தமிழ்
- Тоҷикӣ
- ไทย
- Türkmençe
- Türkçe
- اردو
- Oʻzbekcha / ўзбекча
- Tiếng Việt
- Winaray
- 閩南語 / Bân-lâm-gí
- 粵語
- 中文
Appearance
From Meta, a Wikimedia project coordination wiki
Module documentation
You might want to create a documentation page for this Scribunto module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
-- This module implements [[Template:IPAc-en]]. localdata=mw.loadData('Module:IPAc-en/data') localp={} -- Global container for tracking categories localcategories={} -- Trims whitespace from a string localfunctiontrim(s) returns:match('^%s*(.-)%s*$') end -- This implements [[Template:Nowrap]]. localfunctionmakeNowrapSpan(s) localspan=mw.html.create('span') :addClass('nowrap') :wikitext(s) returntostring(span) end localfunctionmakePronunciationText(id) id=idandstring.lower(trim(id)) ifidandid~=''anddata.pronunciation[id]then returndata.pronunciation[id].text end end localfunctiongetFilepath(file) returnmw.getCurrentFrame():callParserFunction('filepath',file) end localfunctionmakeAudioLink(file) categories["Articles including recorded pronunciations"]=true localspan=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) end localfunctionformatPhonemeGroup(phonemes) if#phonemes>0then localspan=mw.html.create('span') :css('border-bottom','1px dotted') :wikitext(table.concat(phonemes)) returntostring(span) else return'' end end localfunctionrenderCategories() localret={} forcatinpairs(categories)do table.insert(ret,string.format('[[Category:%s]]',cat)) end table.sort(ret) returntable.concat(ret) end functionp._main(args) localret={} locali=0-- Keeps track of numbered args -- Pronunciation do localpron={} whiletruedo i=i+1 localpronItem=makePronunciationText(args[i]) ifpronItemthen pron[#pron+1]=pronItem pron[#pron+1]=' ' else break end end if#pron>0then ret[#ret+1]=string.format( '<small>%s</small>', table.concat(pron) ) end end -- Audio link do localfile=args.audioandtrim(args.audio) iffileandfile~=''then ret[#ret+1]=makeAudioLink(file) end end -- Phonemes do -- 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 slash i=i-1-- Set up i again as it was changed in the pronunciation loop localid repeat localphonemes={} localisWordEnd=false whilenotisWordEnddo i=i+1 id=args[i] id=idandtrim(id) ifnotidthen isWordEnd=true words[#words+1]=formatPhonemeGroup(phonemes) elseifid~=''then localt=data.phonemes[id] ifnottthen -- We were passed an invalid id. isWordEnd=true categories["Ill-formatted IPAc-en transclusions"]=true words[#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=true words[#words+1]=formatPhonemeGroup(phonemes) words[#words+1]=t.label end end end untilnotid words[#words+1]='/'-- Closing slash -- Wrap the words in a link to IPA help. localspan=mw.html.create('span') :addClass('IPA nopopups') :wikitext(string.format( '[[en:Help:IPA/English|%s]]', table.concat(words) )) ret[#ret+1]=tostring(span) end -- Nowrap and categories ret=makeNowrapSpan(table.concat(ret))..renderCategories() -- Reset the categories table in case we are run again. categories={} returnret end functionp.main(frame) returnp._main(frame:getParent().args) end returnp