မဝ်ဂျူ:IPA/templates: အရာမတၞဟ်ခြာ အကြာ မူတၞဟ်ဂမၠိုင်
Content deleted Content added
No edit summary |
No edit summary ဒစင်: မကလေၚ်ပလေဝ်ဒါန်လဝ် |
||
လာင် ၂- | လာင် ၂- | ||
local m_IPA = require("Module:IPA") |
local m_IPA = require("Module:IPA") |
||
local m_str_utils = require("Module:string utilities") |
|||
local parse_utilities_module = "Module:parse utilities" |
|||
local references_module = "Module:references" |
|||
local |
local rsplit = m_str_utils.split |
||
local syllabic = U(0x0329) |
|||
local function track(page) |
|||
⚫ | |||
return true |
|||
⚫ | |||
local function split_on_comma(term) |
|||
⚫ | |||
return nil |
|||
⚫ | |||
if term:find(",%s") then |
|||
return require(parse_utilities_module).split_on_comma(term) |
|||
else |
|||
return rsplit(term, ",") |
|||
⚫ | |||
end |
|||
-- Used for [[Template:IPA]]. |
-- Used for [[Template:IPA]]. |
||
လာင် ၃၂- | လာင် ၅၀- | ||
local args = require("Module:parameters").process(parent_args, params) |
local args = require("Module:parameters").process(parent_args, params) |
||
local lang = args[compat and "lang" or 1] |
local lang = args[compat and "lang" or 1] |
||
lang = require("Module:languages").getByCode(lang) |
|||
or require("Module:languages").err(lang, compat and "lang" or 1) |
|||
-- [[Special:WhatLinksHere/Template:tracking/IPA/grc]] |
|||
if lang and lang:getCode() == "grc" then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
local items = {} |
local items = {} |
||
လာင် ၄၆- | လာင် ၅၇- | ||
local refs = args["ref"][i] |
local refs = args["ref"][i] |
||
if refs then |
if refs then |
||
refs = require( |
refs = require(references_module).parse_references(refs) |
||
end |
end |
||
local qual = args["qual"][i] |
local qual = args["qual"][i] |
||
if qual then |
|||
-- FIXME: Convert such uses to qN=. |
|||
track("qual") |
|||
end |
|||
if not pron then |
if not pron then |
||
-- FIXME: Eliminate such uses, then make them an error through disallow_holes = true. |
|||
track("empty-pron") |
|||
if refs or qual then |
if refs or qual then |
||
local param = i == 1 and "" or "" .. i |
local param = i == 1 and "" or "" .. i |
||
လာင် ၅၆- | လာင် ၇၃- | ||
end |
end |
||
else |
else |
||
⚫ | |||
⚫ | |||
⚫ | |||
table.insert(items, { |
|||
⚫ | |||
pron = pron, |
|||
⚫ | |||
refs = refs, |
|||
q = args.q[i] and {args.q[i]} or nil, |
|||
table.insert(items, {pron = pron, refs = refs, qualifiers = {qual}}) |
|||
qq = args.qq[i] and {args.qq[i]} or nil, |
|||
⚫ | |||
a = split_on_comma(args.a[i]), |
|||
aa = split_on_comma(args.aa[i]), |
|||
-- FIXME, remove this |
|||
qualifiers = qual and {qual} or nil, |
|||
⚫ | |||
end |
end |
||
end |
end |
||
return m_IPA.format_IPA_full |
return m_IPA.format_IPA_full { |
||
lang = lang, |
|||
items = items, |
|||
sort_key = args.sort, |
|||
no_count = args.nocount, |
|||
q = args.q.default and {args.q.default} or nil, |
|||
qq = args.qq.default and {args.qq.default} or nil, |
|||
a = split_on_comma(args.a.default), |
|||
aa = split_on_comma(args.aa.default), |
|||
⚫ | |||
end |
end |
||
လာင် ၇၆- | လာင် ၁၀၇- | ||
-- Came before 'ref' but too obscure |
-- Came before 'ref' but too obscure |
||
["n"] = {list = true, allow_holes = true, alias_of = "ref"}, |
["n"] = {list = true, allow_holes = true, alias_of = "ref"}, |
||
["q"] = {list = true, allow_holes = true, require_index = true}, |
|||
["qq"] = {list = true, allow_holes = true, require_index = true}, |
|||
["qual"] = {list = true, allow_holes = true}, |
["qual"] = {list = true, allow_holes = true}, |
||
-- FIXME, remove this. |
-- FIXME, remove this. |
||
လာင် ၈၃- | လာင် ၁၁၆- | ||
local args = require("Module:parameters").process(frame.getParent and frame:getParent().args or frame, params) |
local args = require("Module:parameters").process(frame.getParent and frame:getParent().args or frame, params) |
||
-- [[Special:WhatLinksHere/ |
-- [[Special:WhatLinksHere/Wiktionary:Tracking/IPAchar/lang]] |
||
if args.lang then |
if args.lang then |
||
require("Module:debug").track("IPAchar/lang") |
require("Module:debug").track("IPAchar/lang") |
||
လာင် ၉၆- | လာင် ၁၂၉- | ||
refs = require("Module:references").parse_references(refs) |
refs = require("Module:references").parse_references(refs) |
||
end |
end |
||
local |
local q = args.q[i] or args.qual[i] |
||
local qq = args.qq[i] |
|||
if pron or refs or qual then |
if pron or refs or qual then |
||
table.insert(items, {pron = pron, refs = refs, |
table.insert(items, {pron = pron, refs = refs, q = {q}, qq = {qq}}) |
||
end |
end |
||
end |
end |
||
လာင် ၁၇၃- | လာင် ၂၀၇- | ||
local args = require("Module:parameters").process(frame:getParent().args, params) |
local args = require("Module:parameters").process(frame:getParent().args, params) |
||
-- [[Special:WhatLinksHere/ |
-- [[Special:WhatLinksHere/Wiktionary:Tracking/X2IPAchar/lang]] |
||
if args.lang then |
if args.lang then |
||
require("Module:debug").track("X2IPAchar/lang") |
require("Module:debug").track("X2IPAchar/lang") |
မူလိက်မပလေဝ်လဝ် နဒဒှ် ၁၅:၅၅၊ ၂၃ မေ ၂၀၂၄
Documentation for this module may be created at မဝ်ဂျူ:IPA/templates/doc
local export = {}
local m_IPA = require("Module:IPA")
local m_str_utils = require("Module:string utilities")
local parse_utilities_module = "Module:parse utilities"
local references_module = "Module:references"
local rsplit = m_str_utils.split
local function track(page)
require("Module:debug").track("IPA/" .. page)
return true
end
local function split_on_comma(term)
if not term then
return nil
end
if term:find(",%s") then
return require(parse_utilities_module).split_on_comma(term)
else
return rsplit(term, ",")
end
end
-- Used for [[Template:IPA]].
function export.IPA(frame)
local parent_args = frame:getParent().args
if parent_args.qual then
-- FIXME: Convert such uses to q1= (or at least qual1=).
track("bare-qual")
end
local compat = parent_args["lang"]
local offset = compat and 0 or 1
local params = {
[compat and "lang" or 1] = {required = true, type = "language", default = "en"},
[1 + offset] = {list = true, allow_holes = true},
["ref"] = {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
["n"] = {list = true, allow_holes = true, alias_of = "ref"},
["a"] = {list = true, allow_holes = true, separate_no_index = true},
["aa"] = {list = true, allow_holes = true, separate_no_index = true},
["q"] = {list = true, allow_holes = true, separate_no_index = true},
["qq"] = {list = true, allow_holes = true, separate_no_index = true},
["qual"] = {list = true, allow_holes = true},
["nocount"] = {type = "boolean"},
["sort"] = {},
}
local args = require("Module:parameters").process(parent_args, params)
local lang = args[compat and "lang" or 1]
local items = {}
for i = 1, math.max(args[1 + offset].maxindex, args["ref"].maxindex, args["qual"].maxindex) do
local pron = args[1 + offset][i]
local refs = args["ref"][i]
if refs then
refs = require(references_module).parse_references(refs)
end
local qual = args["qual"][i]
if qual then
-- FIXME: Convert such uses to qN=.
track("qual")
end
if not pron then
-- FIXME: Eliminate such uses, then make them an error through disallow_holes = true.
track("empty-pron")
if refs or qual then
local param = i == 1 and "" or "" .. i
error("Specified qual" .. param .. "= or ref" .. param .. "= without corresponding pronunciation")
end
else
require("Module:IPA/tracking").run_tracking(pron, lang)
table.insert(items, {
pron = pron,
refs = refs,
q = args.q[i] and {args.q[i]} or nil,
qq = args.qq[i] and {args.qq[i]} or nil,
a = split_on_comma(args.a[i]),
aa = split_on_comma(args.aa[i]),
-- FIXME, remove this
qualifiers = qual and {qual} or nil,
})
end
end
return m_IPA.format_IPA_full {
lang = lang,
items = items,
sort_key = args.sort,
no_count = args.nocount,
q = args.q.default and {args.q.default} or nil,
qq = args.qq.default and {args.qq.default} or nil,
a = split_on_comma(args.a.default),
aa = split_on_comma(args.aa.default),
}
end
-- Used for [[Template:IPAchar]].
function export.IPAchar(frame)
local params = {
[1] = {list = true, allow_holes = true},
["ref"] = {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
["n"] = {list = true, allow_holes = true, alias_of = "ref"},
["q"] = {list = true, allow_holes = true, require_index = true},
["qq"] = {list = true, allow_holes = true, require_index = true},
["qual"] = {list = true, allow_holes = true},
-- FIXME, remove this.
["lang"] = {}, -- This parameter is not used and does nothing, but is allowed for futureproofing.
}
local args = require("Module:parameters").process(frame.getParent and frame:getParent().args or frame, params)
-- [[Special:WhatLinksHere/Wiktionary:Tracking/IPAchar/lang]]
if args.lang then
require("Module:debug").track("IPAchar/lang")
end
local items = {}
for i = 1, math.max(args[1].maxindex, args["ref"].maxindex, args["qual"].maxindex) do
local pron = args[1][i]
local refs = args["ref"][i]
if refs then
refs = require("Module:references").parse_references(refs)
end
local q = args.q[i] or args.qual[i]
local qq = args.qq[i]
if pron or refs or qual then
table.insert(items, {pron = pron, refs = refs, q = {q}, qq = {qq}})
end
end
-- Format
return m_IPA.format_IPA_multiple(nil, items)
end
function export.XSAMPA(frame)
local params = {
[1] = { required = true },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
return m_IPA.XSAMPA_to_IPA(args[1] or "[Eg'zA:mp5=]")
end
-- Used by [[Template:X2IPA]]
function export.X2IPAtemplate(frame)
local parent_args = frame.getParent and frame:getParent().args or frame
local compat = parent_args["lang"]
local offset = compat and 0 or 1
local params = {
[compat and "lang" or 1] = {required = true, default = "und"},
[1 + offset] = {list = true, allow_holes = true},
["ref"] = {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
["n"] = {list = true, allow_holes = true, alias_of = "ref"},
["qual"] = { list = true, allow_holes = true },
}
local args = require("Module:parameters").process(parent_args, params)
local m_XSAMPA = require("Module:IPA/X-SAMPA")
local pronunciations, refs, qualifiers, lang = args[1 + offset], args["ref"], args["qual"], args[compat and "lang" or 1]
local output = {}
table.insert(output, "{{IPA")
table.insert(output, "|" .. lang)
for i = 1, math.max(pronunciations.maxindex, refs.maxindex, qualifiers.maxindex) do
if pronunciations[i] then
table.insert(output, "|" .. m_XSAMPA.XSAMPA_to_IPA(pronunciations[i]))
end
if refs[i] then
table.insert(output, "|ref" .. i .. "=" .. refs[i])
end
if qualifiers[i] then
table.insert(output, "|qual" .. i .. "=" .. qualifiers[i])
end
end
table.insert(output, "}}")
return table.concat(output)
end
-- Used by [[Template:X2IPAchar]]
function export.X2IPAchar(frame)
local params = {
[1] = { list = true, allow_holes = true },
["ref"] = {list = true, allow_holes = true},
-- Came before 'ref' but too obscure
["n"] = {list = true, allow_holes = true, alias_of = "ref"},
["qual"] = { list = true, allow_holes = true },
-- FIXME, remove this.
["lang"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
-- [[Special:WhatLinksHere/Wiktionary:Tracking/X2IPAchar/lang]]
if args.lang then
require("Module:debug").track("X2IPAchar/lang")
end
local m_XSAMPA = require("Module:IPA/X-SAMPA")
local pronunciations, refs, qualifiers, lang = args[1], args["ref"], args["qual"], args["lang"]
local output = {}
table.insert(output, "{{IPAchar")
for i = 1, math.max(pronunciations.maxindex, refs.maxindex, qualifiers.maxindex) do
if pronunciations[i] then
table.insert(output, "|" .. m_XSAMPA.XSAMPA_to_IPA(pronunciations[i]))
end
if refs[i] then
table.insert(output, "|ref" .. i .. "=" .. refs[i])
end
if qualifiers[i] then
table.insert(output, "|qual" .. i .. "=" .. qualifiers[i])
end
end
if lang then
table.insert(output, "|lang=" .. lang)
end
table.insert(output, "}}")
return table.concat(output)
end
-- Used by [[Template:x2rhymes]]
function export.X2rhymes(frame)
local parent_args = frame.getParent and frame:getParent().args or frame
local compat = parent_args["lang"]
local offset = compat and 0 or 1
local params = {
[compat and "lang" or 1] = {required = true, default = "und"},
[1 + offset] = {required = true, list = true, allow_holes = true},
}
local args = require("Module:parameters").process(parent_args, params)
local m_XSAMPA = require("Module:IPA/X-SAMPA")
pronunciations, lang = args[1 + offset], args[compat and "lang" or 1]
local output = {}
table.insert(output, "{{rhymes")
table.insert(output, "|" .. lang)
for i = 1, pronunciations.maxindex do
if pronunciations[i] then
table.insert(output, "|" .. m_XSAMPA.XSAMPA_to_IPA(pronunciations[i]))
end
end
table.insert(output, "}}")
return table.concat(output)
end
return export