Anonymous user
Module:IPAc-en: Difference between revisions
no edit summary
Vivaporius (talk | contribs) m (1 revision imported) |
en>Centrist16 No edit summary |
||
Line 2:
local data = mw.loadData('Module:IPAc-en/data')
local currentFrame = mw.getCurrentFrame()
local p = {}
-- Global container for tracking categories
local categoryHandler = require('Module:Category handler').main
local categories = {}
Line 25 ⟶ 27:
return data.pronunciation[id].text
end
end▼
end▼
categories["Articles including recorded pronunciations"] = true▼
:addClass('noexcerpt')▼
))▼
:wikitext(string.format('[[:File:%s|i]]', file))▼
end
Line 70 ⟶ 49:
local function renderCategories()
local ret =
ret = categoryHandler{
for cat in pairs(categories) do▼
[1] = 'yes', -- Add categories in these namespaces
main = 1,
wikipedia = 1,
file = 1,
template = 1,
help = 1,
category = 1,
portal = 1,
book = 1,
draft = 1,
module = 1,
}
ret = {}
▲ end
ret = table.concat(ret)
else
ret = ''
end
▲ return table.concat(ret)
end
Line 100 ⟶ 99:
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
Line 137 ⟶ 128:
categories["Ill-formatted IPAc-en transclusions"] = true
words[#words + 1] = formatPhonemeGroup(phonemes)
-- Call [[Template:Error]]
local errorText = currentFrame:expandTemplate{
title = 'Template:Error',
args = {
string.format("[invalid input: '%s']", id)
}
}
words[#words + 1] = makeTooltip(
'Unrecognized symbol'
)
Line 166 ⟶ 164:
-- Wrap the words in a link to IPA help.
local span = mw.html.create('span')
-- Suppress Navigation popups and Page Previews (aka Hovercards)
▲ :addClass('IPA nopopups noexcerpt')
:wikitext(string.format(
'[[W:Help:IPA
table.concat(words)
))
ret[#ret + 1] = tostring(span)
end
▲ -- Audio link
▲ do
▲ local file = args.audio and trim(args.audio)
if file and file ~= '' then
if args[1] and string.lower(trim(args[1])) == 'uk' then
categories["Articles including recorded pronunciations (UK English)"] = true
elseif args[1] and string.lower(trim(args[1])) == 'us' then
categories["Articles including recorded pronunciations (US English)"] = true
else
title = 'Template:IPA audio link', args = { file } }
▲ end
▲ end
-- Nowrap and categories
ret = makeNowrapSpan(table.concat(ret)) .. renderCategories()
|