Module:IPA: Difference between revisions

Jump to navigation Jump to search
1,196 bytes removed ,  18 November 2025
no edit summary
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 34: Line 34:


local namespace = mw.title.getCurrentTitle().namespace
local namespace = mw.title.getCurrentTitle().namespace
local is_content_page = namespace == 0 or namespace == 118
local is_content_page = namespace == 0 or namespace == 120


local function process_maybe_split_categories(split_output, categories, prontext, lang, errtext)
local function process_maybe_split_categories(split_output, categories, prontext, lang, errtext)
Line 118: Line 118:
prefix_text = '<span class="error">' .. err .. '</span>'
prefix_text = '<span class="error">' .. err .. '</span>'
else
else
if hasKey[lang:getCode()] then
prefix_text = "IPA for " .. langname
prefix_text = "IPA for " .. langname
else
prefix_text = langname
end
prefix_text = "[[" .. prefix_text .. "|key]]"
prefix_text = "[[" .. prefix_text .. "|key]]"
end
end
Line 129: Line 125:


local IPAs, categories = export.format_IPA_multiple(lang, items, separator, no_count, "raw")
local IPAs, categories = export.format_IPA_multiple(lang, items, separator, no_count, "raw")
if is_content_page then
insert(categories, {
cat = langname .. " terms with IPA pronunciation",
sort_key = sort_key
})
end


local prontext = prefix .. IPAs
local prontext = prefix .. IPAs
Line 282: Line 271:
if namespace == 10 then -- Template
if namespace == 10 then -- Template
insert(items, {pron = "/aɪ piː ˈeɪ/"})
insert(items, {pron = "/aɪ piː ˈeɪ/"})
else
insert(categories, "Pronunciation templates without a pronunciation")
end
end
end
end
Line 416: Line 403:
-- Strip any reconstruction asterisk and representation marks.
-- Strip any reconstruction asterisk and representation marks.
pron = sub(pron, #opening + 1 + (reconstructed and 1 or 0), -#closing - 1)
pron = sub(pron, #opening + 1 + (reconstructed and 1 or 0), -#closing - 1)
 
if not repr then
insert(categories, "IPA pronunciations with invalid representation marks")
-- insert(err, "invalid representation marks")
-- Removed because it's annoying when previewing pronunciation pages.
end
if repr ~= "orthographic" and lang and lang:getCode() == "en" and hasInvalidSeparators(pron) then
if repr ~= "orthographic" and lang and lang:getCode() == "en" and hasInvalidSeparators(pron) then
insert(categories, "English IPA pronunciations with invalid separators")
insert(categories, "English IPA pronunciations with invalid separators")
end
if pron == "" then
insert(categories, "IPA pronunciations with no pronunciation present")
end
end


Line 438: Line 416:
end
end
insert(result, nonstandard)
insert(result, nonstandard)
insert(categories,
{cat = "IPA pronunciations with obsolete or nonstandard characters", sort_key = nonstandard}
)
end
end


Line 514: Line 489:
result = ugsub(result, pattern, " ")
result = ugsub(result, pattern, " ")
end
end
if not match(result, "^ *$") then
local category = "IPA pronunciations with invalid IPA characters"
if not is_content_page then
category = category .. "/non_mainspace"
end
insert(categories, category)
insert(err, "invalid IPA characters (" .. result .. ")")
end
end
if found_HTML then
insert(categories, "IPA pronunciations with paired HTML tags")
end
end


Line 557: Line 520:
insert(phonemes, "<span style=\"color: var(--wikt-palette-red,red)\">" .. phoneme .. "</span>")
insert(phonemes, "<span style=\"color: var(--wikt-palette-red,red)\">" .. phoneme .. "</span>")
rest = usub(rest, 2)
rest = usub(rest, 2)
insert(categories, "IPA pronunciations with invalid phonemes/" .. lang:getCode())
end
end
end
end

Navigation menu