Editing Module:IPAc-en

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 5: Line 5:
  
 
-- Global container for tracking categories
 
-- Global container for tracking categories
local categoryHandler = require('Module:Category handler').main
 
 
local categories = {}
 
local categories = {}
  
Line 16: Line 15:
 
local function makeNowrapSpan(s)
 
local function makeNowrapSpan(s)
 
local span = mw.html.create('span')
 
local span = mw.html.create('span')
:addClass('rt-commentedText') -- Works with [[MediaWiki:Gadget-ReferenceTooltips.js]]
 
 
:addClass('nowrap')
 
:addClass('nowrap')
 
:wikitext(s)
 
:wikitext(s)
Line 27: Line 25:
 
return data.pronunciation[id].text
 
return data.pronunciation[id].text
 
end
 
end
 +
end
 +
 +
local function getFilepath(file)
 +
return mw.getCurrentFrame():callParserFunction('filepath', file)
 +
end
 +
 +
local function makeAudioLink(file)
 +
categories["Articles including recorded pronunciations"] = true
 +
local span = 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))
 +
return tostring(span)
 
end
 
end
  
Line 49: Line 70:
  
 
local function renderCategories()
 
local function renderCategories()
local ret = ''
+
local ret = {}
+
for cat in pairs(categories) do
if categoryHandler{ true } then
+
table.insert(ret, string.format('[[Category:%s]]', cat))
ret = {}
 
for cat in pairs(categories) do
 
table.insert(ret, string.format('[[Category:%s]]', cat))
 
end
 
table.sort(ret)
 
ret = table.concat(ret)
 
else
 
ret = ''
 
 
end
 
end
return ret
+
table.sort(ret)
 +
return table.concat(ret)
 
end
 
end
  
Line 86: Line 100:
 
table.concat(pron)
 
table.concat(pron)
 
)
 
)
 +
end
 +
end
 +
 +
-- Audio link
 +
do
 +
local file = args.audio and trim(args.audio)
 +
if file and file ~= '' then
 +
ret[#ret + 1] = makeAudioLink(file)
 
end
 
end
 
end
 
end
Line 116: Line 138:
 
words[#words + 1] = formatPhonemeGroup(phonemes)
 
words[#words + 1] = formatPhonemeGroup(phonemes)
 
words[#words + 1] = makeTooltip(
 
words[#words + 1] = makeTooltip(
string.format(
+
"'''[unsupported input]'''",
"<strong class=\"error\">[invalid input: '%s']</strong>",
 
id
 
),
 
 
'Unrecognized symbol'
 
'Unrecognized symbol'
 
)
 
)
Line 147: Line 166:
 
-- Wrap the words in a link to IPA help.
 
-- Wrap the words in a link to IPA help.
 
local span = mw.html.create('span')
 
local span = mw.html.create('span')
-- Suppress Navigation popups and Page Previews (aka Hovercards)
+
:addClass('IPA nopopups')
:addClass('IPA nopopups noexcerpt')
 
 
:wikitext(string.format(
 
:wikitext(string.format(
'[[Help:IPA/English|%s]]',
+
'[[Help:IPA for English|%s]]',
 
table.concat(words)
 
table.concat(words)
 
))
 
))
+
 
 
ret[#ret + 1] = tostring(span)
 
ret[#ret + 1] = tostring(span)
 
end
 
end
+
 
-- Audio link
 
do
 
local file = args.audio and trim(args.audio)
 
if file and file ~= '' then
 
categories["Pages including recorded pronunciations"] = true
 
ret[#ret + 1] = mw.getCurrentFrame():expandTemplate{
 
title = 'Template:IPA audio link', args = { file, attribution = args.attribution } }
 
end
 
end
 
 
 
-- Nowrap and categories
 
-- Nowrap and categories
 
ret = makeNowrapSpan(table.concat(ret)) .. renderCategories()
 
ret = makeNowrapSpan(table.concat(ret)) .. renderCategories()

Please note that all contributions to All About Ayrshire may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see All About Ayrshire:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: