Editing Module:IPAc-en
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 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('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 | |
− | + | table.insert(ret, string.format('[[Category:%s]]', cat)) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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( | ||
− | + | "'''[unsupported input]'''", | |
− | |||
− | |||
− | |||
'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') | ||
− | + | :addClass('IPA nopopups') | |
− | :addClass('IPA nopopups | ||
:wikitext(string.format( | :wikitext(string.format( | ||
− | '[[Help:IPA | + | '[[Help:IPA for English|%s]]', |
table.concat(words) | table.concat(words) | ||
)) | )) | ||
− | + | ||
ret[#ret + 1] = tostring(span) | ret[#ret + 1] = tostring(span) | ||
end | end | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
-- Nowrap and categories | -- Nowrap and categories | ||
ret = makeNowrapSpan(table.concat(ret)) .. renderCategories() | ret = makeNowrapSpan(table.concat(ret)) .. renderCategories() |