45,646
edits
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 | ||
key_link = "[[IPA for " .. lang:getCanonicalName() .. "|key]]" | |||
end | end | ||
local prefix = "[[Wiktionary:International Phonetic Alphabet|IPA]]<sup>(" .. ( key_link or err_text ) .. ")</sup>: " | local prefix = "[[wikt:Wiktionary:International Phonetic Alphabet|IPA]]<sup>(" .. ( key_link or err_text ) .. ")</sup>: " | ||
IPAs = export.format_IPA_multiple(lang, items, separator, no_count) | IPAs = export.format_IPA_multiple(lang, items, separator, no_count) | ||
return prefix .. IPAs | 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 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.refs or item.note then | |||
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[ | local langcode = lang:getCode() | ||
if m_data.langs_to_generate_syllable_count_categories[langcode] then | |||
local repr = determine_repr(item.pron) | |||
local use_it | |||
if m_data.langs_to_use_phonetic_notation[langcode] then | |||
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 .. '</ | XSAMPA = '<code>' .. XSAMPA .. '</code>', | ||
regenerated_IPA = '<span class="IPA">' .. regenerated_IPA .. '</span>' | regenerated_IPA = '<span class="IPA">' .. regenerated_IPA .. '</span>' | ||
} | } |