Module:pron qualifier: difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
update docs |
pass data.lang to Module:accent qualifier and track cases with missing .lang |
||
Line 1: | Line 1: | ||
local export = {} |
local export = {} |
||
local function track(page) |
|||
require("Module:debug/track")("pron qualifier/" .. page) |
|||
return true |
|||
end |
|||
--[==[ |
--[==[ |
||
This |
This function is used by any module that wants to add support for left and right regular and accent qualifiers to a |
||
template that specifies a pronunciation or related property. It is currently used by [[Module:rhymes]], |
template that specifies a pronunciation or related property. It is currently used by [[Module:rhymes]], |
||
[[Module:hyphenation]], [[Module:homophones]] and [[Module:es-pronunc]] (for specifying pronunciation, rhymes, |
[[Module:hyphenation]], [[Module:homophones]] and [[Module:es-pronunc]] (for specifying pronunciation, rhymes, |
||
Line 27: | Line 32: | ||
]==] |
]==] |
||
function export.format_qualifiers(data, text, qualifiers_right) |
function export.format_qualifiers(data, text, qualifiers_right) |
||
if not data.lang then |
|||
track("nolang") |
|||
end |
|||
local function format_q(q) |
local function format_q(q) |
||
return require("Module:qualifier").format_qualifier(q) |
return require("Module:qualifier").format_qualifier(q) |
||
end |
end |
||
local function format_a(a) |
local function format_a(a) |
||
return require("Module:accent qualifier").format_qualifiers(a) |
return require("Module:accent qualifier").format_qualifiers(a, data.lang) |
||
end |
end |
||
-- This order puts the accent qualifiers before other qualifiers on both the left and the right. |
-- This order puts the accent qualifiers before other qualifiers on both the left and the right. |
Revision as of 07:42, 19 May 2024
- The following documentation is located at Module:pron qualifier/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
Detailed documentation
export.format_qualifiers
function export.format_qualifiers(data, text, qualifiers_right)
This function is used by any module that wants to add support for left and right regular and accent qualifiers to a template that specifies a pronunciation or related property. It is currently used by Module:rhymes, Module:hyphenation, Module:homophones and Module:es-pronunc (for specifying pronunciation, rhymes, hyphenation, homophones and audio in {{es-pr}}
). It should potentially also be used in {{audio}}
. To reduce memory usage, the caller should check that any qualifiers exist before loading the module.
data
is a structure containing the following fields:
q
: List of left regular qualifiers, each a string.qq
: List of right regular qualifiers, each a string.qualifiers
: List of qualifiers, each a string, for compatibility. Ifqualifiers_right
is given, these are right qualifiers, otherwise left qualifiers. If bothqualifiers
andq
/qq
(depending on the value ofqualifiers_right
) are non-nil
,qualifiers
is ignored.a
: List of left accent qualifiers, each a string. WARNING: The table holding the qualifiers will be destructively modified.aa
: List of right accent qualifiers, each a string. WARNING: The table holding the qualifiers will be destructively modified.lang
: Language object for accent qualifiers.text
is the text to wrap with qualifiers. Accent qualifiers precede (are to the left of) regular qualifiers, both on the left and right sides.qualifiers_right
controls the placement of qualifiers specified using thequalifiers
field; see above.
WARNING: This destructively modifies the left and right accent qualifiers inside of data
.
local export = {}
local function track(page)
require("Module:debug/track")("pron qualifier/" .. page)
return true
end
--[==[
This function is used by any module that wants to add support for left and right regular and accent qualifiers to a
template that specifies a pronunciation or related property. It is currently used by [[Module:rhymes]],
[[Module:hyphenation]], [[Module:homophones]] and [[Module:es-pronunc]] (for specifying pronunciation, rhymes,
hyphenation, homophones and audio in {{tl|es-pr}}). It should potentially also be used in {{tl|audio}}. To reduce memory
usage, the caller should check that any qualifiers exist before loading the module.
`data` is a structure containing the following fields:
* `q`: List of left regular qualifiers, each a string.
* `qq`: List of right regular qualifiers, each a string.
* `qualifiers`: List of qualifiers, each a string, for compatibility. If `qualifiers_right` is given, these are
right qualifiers, otherwise left qualifiers. If both `qualifiers` and `q`/`qq` (depending on the value of
`qualifiers_right`) are non-{nil}, `qualifiers` is ignored.
* `a`: List of left accent qualifiers, each a string. '''WARNING''': The table holding the qualifiers will be
destructively modified.
* `aa`: List of right accent qualifiers, each a string. '''WARNING''': The table holding the qualifiers will be
destructively modified.
* `lang`: Language object for accent qualifiers.
`text` is the text to wrap with qualifiers. Accent qualifiers precede (are to the left of) regular qualifiers, both
on the left and right sides. `qualifiers_right` controls the placement of qualifiers specified using the `qualifiers`
field; see above.
'''WARNING''': This destructively modifies the left and right accent qualifiers inside of `data`.
]==]
function export.format_qualifiers(data, text, qualifiers_right)
if not data.lang then
track("nolang")
end
local function format_q(q)
return require("Module:qualifier").format_qualifier(q)
end
local function format_a(a)
return require("Module:accent qualifier").format_qualifiers(a, data.lang)
end
-- This order puts the accent qualifiers before other qualifiers on both the left and the right.
local leftq = data.q or not qualifiers_right and data.qualifiers
if leftq and leftq[1] then
text = format_q(leftq) .. " " .. text
end
local lefta = data.a
if lefta and lefta[1] then
text = format_a(lefta) .. " " .. text
end
local righta = data.aa
if righta and righta[1] then
text = text .. " " .. format_a(righta)
end
local rightq = data.qq or qualifiers_right and data.qualifiers
if rightq and rightq[1] then
text = text .. " " .. format_q(rightq)
end
return text
end
return export