Module:IPA: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 21: Line 21:
err_text = '<span class="error">' .. err .. '</span>'
err_text = '<span class="error">' .. err .. '</span>'
else
else
if hasKey[lang:getCode()] then
key_link = "[[IPA for " .. lang:getCanonicalName() .. "|key]]"
IPA_key = "Appendix:" .. lang:getCanonicalName() .. " pronunciation"
else
IPA_key = "wikipedia:" .. lang:getCanonicalName() .. " phonology"
end
key_link = "[[" .. IPA_key .. "|key]]"
end
end


local prefix = "[[Wiktionary:International Phonetic Alphabet|IPA]]<sup>(" .. ( key_link or err_text ) .. ")</sup>:&#32;"
local prefix = "[[wikt:Wiktionary:International Phonetic Alphabet|IPA]]<sup>(" .. ( key_link or err_text ) .. ")</sup>:&#32;"
IPAs = export.format_IPA_multiple(lang, items, separator, no_count)
IPAs = export.format_IPA_multiple(lang, items, separator, no_count)
if lang and (namespace == "" or namespace == "Reconstruction") then
sortKey = sortKey or lang:makeSortKey(mw.title.getCurrentTitle().text)
sortKey = sortKey and ("|" .. sortKey) or ""
category = "[[Category:" .. lang:getCanonicalName() .. " terms with IPA pronunciation" .. sortKey .. "]]"
else
category = ""
end


return prefix .. IPAs .. category
return prefix .. IPAs
end
end


Line 91: Line 77:


function export.format_IPA_multiple(lang, items, separator, no_count)
function export.format_IPA_multiple(lang, items, separator, no_count)
local notes = {}
local categories = {}
local categories = {}
separator = separator or ', '
separator = separator or ', '
Line 108: Line 93:
for _, item in ipairs(items) do
for _, item in ipairs(items) do
local bit = export.format_IPA(lang, item.pron)
local bit = export.format_IPA(lang, item.pron)
if item.pretext then
bit = item.pretext .. bit
end
if item.posttext then
bit = bit .. item.posttext
end
if item.qualifiers and item.qualifiers[1] then
if item.qualifiers and item.qualifiers[1] then
bit = require("Module:qualifier").format_qualifier(item.qualifiers) .. " " .. bit
bit = require("Module:qualifier").format_qualifier(item.qualifiers) .. " " .. bit
end
end
 
if item.note then
if item.refs or item.note then
bit = bit .. mw.getCurrentFrame():extensionTag("ref", item.note)
local refspecs
if item.note then
-- FIXME: eliminate item.note in favor of item.refs. Use tracking to find places
-- that use item.note.
refspecs = {item.note}
else
refspecs = item.refs
end
local refs = {}
if #refspecs > 0 then
for _, refspec in ipairs(refspecs) do
if type(refspec) ~= "table" then
refspec = {text = refspec}
end
local refargs
if refspec.name or refspec.group then
refargs = {name = refspec.name, group = refspec.group}
end
table.insert(refs, mw.getCurrentFrame():extensionTag("ref", refspec.text, refargs))
end
bit = bit .. table.concat(refs)
end
end
end
 
table.insert(bits, bit)
table.insert(bits, bit)
Line 124: Line 138:
if not no_count and mw.title.getCurrentTitle().namespace == 0 then
if not no_count and mw.title.getCurrentTitle().namespace == 0 then
m_syllables = m_syllables or require('Module:syllables')
m_syllables = m_syllables or require('Module:syllables')
if m_data.langs_to_generate_syllable_count_categories[lang:getCode()] and
local langcode = lang:getCode()
(determine_repr(item.pron) == "phonemic" or lang:getCode() == "ru") and
if m_data.langs_to_generate_syllable_count_categories[langcode] then
not find(item.pron, "[ ‿]") then
local repr = determine_repr(item.pron)
local syllable_count = m_syllables.getVowels(item.pron, lang)
local use_it
if syllable_count then
if m_data.langs_to_use_phonetic_notation[langcode] then
table.insert(categories, "[[Category:" .. lang:getCanonicalName() .. " " .. syllable_count .. "-syllable words]]")
use_it = repr == "phonetic"
end
else
use_it = repr == "phonemic"
end
if use_it and not find(item.pron, "[ ‿]") then
local syllable_count = m_syllables.getVowels(item.pron, lang)
if syllable_count then
table.insert(categories, "[[Category:" .. lang:getCanonicalName() .. " " .. syllable_count .. "-syllable words]]")
end
end
end
end
end
end
Line 223: Line 245:
result = gsub(result, "⁽[".. m_symbols.superscripts .. "]+⁾", "")
result = gsub(result, "⁽[".. m_symbols.superscripts .. "]+⁾", "")
result = gsub(result, '[' .. m_symbols.valid .. ']', '')
result = gsub(result, '[' .. m_symbols.valid .. ']', '')
-- VS15
local vs15_class = "[" .. m_symbols.add_vs15 .. "]"
if mw.ustring.find(pron, vs15_class) then
local vs15 = U(0xFE0E)
if mw.ustring.find(result, vs15) then
result = gsub(result, vs15, "")
pron = mw.ustring.gsub(pron, vs15, "")
end
pron = mw.ustring.gsub(pron, "(" .. vs15_class .. ")", "%1" .. vs15)
end
if result ~= '' then
if result ~= '' then
local suggestions = {}
local suggestions = {}
Line 363: Line 397:
or '<span style="color: red;">no</span>',
or '<span style="color: red;">no</span>',
IPA = '<span class="IPA">' .. IPA .. '</span>',
IPA = '<span class="IPA">' .. IPA .. '</span>',
XSAMPA = '<code>' .. XSAMPA .. '</span>',
XSAMPA = '<code>' .. XSAMPA .. '</code>',
regenerated_IPA = '<span class="IPA">' .. regenerated_IPA .. '</span>'
regenerated_IPA = '<span class="IPA">' .. regenerated_IPA .. '</span>'
}
}

Navigation menu