A modult a Modul:0IPA/templates/doc lapon tudod dokumentálni
local export = {}
local m_IPA = require("Module:0IPA")
local U = mw.ustring.char
local syllabic = U(0x0329)
-- Used for ].
function export.IPA(frame)
local parent_args = frame.getParent and frame:getParent().args or frame
local compat = parent_args
local offset = compat and 0 or 1
local params = {
= {required = true, default = "en"},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
= {list = true, allow_holes = true, alias_of = "ref"},
= {list = true, allow_holes = true},
= {type = "boolean"},
= {},
}
local args = require("Module:0parameters").process(parent_args, params)
local lang = args
lang = require("Module:0languages").getByCode(lang)
or require("Module:0languages").err(lang, compat and "lang" or 1)
-- ]
if lang and lang:getCode() == "grc" then
require("Module:0debug").track("IPA/grc")
end
local items = {}
for i = 1, math.max(args.maxindex, args.maxindex, args.maxindex) do
local pron = args
local refs = args
if refs then
refs = require("Module:0references").parse_references(refs)
end
local qual = args
if not pron then
if refs or qual then
local param = i == 1 and "" or "" .. i
error("Specified qual" .. param .. "= or ref" .. param .. "= without corresponding pronunciation")
end
else
if lang then
require("Module:0IPA/tracking").run_tracking(pron, lang)
end
if pron or refs or qual then
table.insert(items, {pron = pron, refs = refs, qualifiers = {qual}})
end
end
end
return m_IPA.format_IPA_full(lang, items, nil, nil, args.sort, args.nocount)
end
-- Used for ].
function export.IPAchar(frame)
local params = {
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
= {list = true, allow_holes = true, alias_of = "ref"},
= {list = true, allow_holes = true},
-- FIXME, remove this.
= {}, -- This parameter is not used and does nothing, but is allowed for futureproofing.
}
local args = require("Module:0parameters").process(frame.getParent and frame:getParent().args or frame, params)
-- ]
if args.lang then
require("Module:0debug").track("IPAchar/lang")
end
local items = {}
for i = 1, math.max(args.maxindex, args.maxindex, args.maxindex) do
local pron = args
local refs = args
if refs then
refs = require("Module:0references").parse_references(refs)
end
local qual = args
if pron or refs or qual then
table.insert(items, {pron = pron, refs = refs, qualifiers = {qual}})
end
end
-- Format
return m_IPA.format_IPA_multiple(nil, items)
end
function export.XSAMPA(frame)
local params = {
= { required = true },
}
local args = require("Module:0parameters").process(frame:getParent().args, params)
return m_IPA.XSAMPA_to_IPA(args or "")
end
-- Used by ]
function export.X2IPAtemplate(frame)
local parent_args = frame.getParent and frame:getParent().args or frame
local compat = parent_args
local offset = compat and 0 or 1
local params = {
= {required = true, default = "und"},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
= {list = true, allow_holes = true, alias_of = "ref"},
= { list = true, allow_holes = true },
}
local args = require("Module:0parameters").process(parent_args, params)
local m_XSAMPA = require("Module:0IPA/X-SAMPA")
local pronunciations, refs, qualifiers, lang = args, args, args, args
local output = {}
table.insert(output, "{{IPA")
table.insert(output, "|" .. lang)
for i = 1, math.max(pronunciations.maxindex, refs.maxindex, qualifiers.maxindex) do
if pronunciations then
table.insert(output, "|" .. m_XSAMPA.XSAMPA_to_IPA(pronunciations))
end
if refs then
table.insert(output, "|ref" .. i .. "=" .. refs)
end
if qualifiers then
table.insert(output, "|qual" .. i .. "=" .. qualifiers)
end
end
table.insert(output, "}}")
return table.concat(output)
end
-- Used by ]
function export.X2IPAchar(frame)
local params = {
= { list = true, allow_holes = true },
= {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
= {list = true, allow_holes = true, alias_of = "ref"},
= { list = true, allow_holes = true },
-- FIXME, remove this.
= {},
}
local args = require("Module:0parameters").process(frame:getParent().args, params)
-- ]
if args.lang then
require("Module:0debug").track("X2IPAchar/lang")
end
local m_XSAMPA = require("Module:0IPA/X-SAMPA")
local pronunciations, refs, qualifiers, lang = args, args, args, args
local output = {}
table.insert(output, "{{IPAchar")
for i = 1, math.max(pronunciations.maxindex, refs.maxindex, qualifiers.maxindex) do
if pronunciations then
table.insert(output, "|" .. m_XSAMPA.XSAMPA_to_IPA(pronunciations))
end
if refs then
table.insert(output, "|ref" .. i .. "=" .. refs)
end
if qualifiers then
table.insert(output, "|qual" .. i .. "=" .. qualifiers)
end
end
if lang then
table.insert(output, "|lang=" .. lang)
end
table.insert(output, "}}")
return table.concat(output)
end
-- Used by ]
function export.X2rhymes(frame)
local parent_args = frame.getParent and frame:getParent().args or frame
local compat = parent_args
local offset = compat and 0 or 1
local params = {
= {required = true, default = "und"},
= {required = true, list = true, allow_holes = true},
}
local args = require("Module:0parameters").process(parent_args, params)
local m_XSAMPA = require("Module:0IPA/X-SAMPA")
pronunciations, lang = args, args
local output = {}
table.insert(output, "{{rhymes")
table.insert(output, "|" .. lang)
for i = 1, pronunciations.maxindex do
if pronunciations then
table.insert(output, "|" .. m_XSAMPA.XSAMPA_to_IPA(pronunciations))
end
end
table.insert(output, "}}")
return table.concat(output)
end
return export