Module:IPA: difference between revisions

Content deleted Content added
remove support for long-deprecated and no-longer-used `.note`; use `.refs` instead
make overall `separator` be a default for the item-specific `separator` instead of something tacked on in addition to the item-specific separator; improve docs
Tag: Reverted
Line 61:
to {format_IPA_multiple()}, and the considerations described there in the documentation apply here as well. There is a
single parameter `data`, an object with the following fields:
* `lang`: is an objectObject representing the language of the pronunciations, which is used when adding cleanup categories for
pronunciations with invalid phonemes; for determining how many syllables the pronunciations have in them, in order to
add a category such as [[:Category:Italian 2-syllable words]] (for certain languages only); for adding a category
{{cd|<var>lang</var> terms with IPA pronunciation}}; and for determining the proper sort keys for categories. Unlike
for {format_IPA_multiple()}, `lang` may not be {nil}.
* `items`: is a listList of pronunciations, in exactly the same format as for {format_IPA_multiple()}.
* `err`,: ifIf not {nil}, is a string containing an error message to use in place of the link to the language's phonology.
* `separator`: theThe overalldefault separator to use when separating formatted items. Defaults to {", "}. ExceptDoes innot theapply simplestto the
casesfirst item, youwhere shouldthe considerdefault settingseparator thisis toalways anthe empty string. andOverridden usingby the per-item `separator` field in `items`.
`items`.
* `sort_key`: explicitExplicit sort key used for categories.
* `no_count`: Suppress adding a {#-syllable words} category such as [[:Category:Italian 2-syllable words]]. Note that
only certain languages add such categories to begin with, because it depends on knowing how to count syllables in a
Line 83 ⟶ 84:
* `include_langname`: If specified, prefix the result with the language name, followed by a colon.
* `q`: {nil} or a list of left qualifiers (as in {{tl|q}}) to display at the beginning, before the formatted
pronunciationpronunciations and preceding {"IPA:"}.
* `qq`: {nil} or a list of right qualifiers to display after all formatted pronunciations.
* `a`: {nil} or a list of left accent qualifiers (as in {{tl|a}}) to display at the beginning, before the formatted
pronunciationpronunciations and preceding {"IPA:"}.
* `aa`: {nil} or a list of right accent qualifiers to display after all formatted pronunciations.
]==]
function export.format_IPA_full(data)
Line 240 ⟶ 241:
** `pos`: {nil} or a part of speech for this item, if different parts of speech have different pronunciations;
** `separator`: the separator text to insert directly before the formatted pronunciation and all qualifiers, accent
qualifiers and pre-text; ifdefaults used, you should explicitly setto the outer `separator` parameter to an empty string.
* `separator`: theThe overalldefault separator to use when separating formatted items. Defaults to {", "}. ExceptDoes innot theapply simplestto the
casesfirst item, youwhere shouldthe considerdefault settingseparator thisis toalways anthe empty string. andOverridden usingby the per-item `separator` field documented above.in
`items`.
* `no_count`: Suppress adding a {#-syllable words} category such as [[:Category:Italian 2-syllable words]]. Note that
only certain languages add such categories to begin with, because it depends on knowing how to count syllables in a
Line 255 ⟶ 257:
function export.format_IPA_multiple(lang, items, separator, no_count, split_output)
local categories = {}
separator = separator or '", '"
 
if not lang then
Line 272 ⟶ 274:
local bits = {}
 
for _i, item in ipairs(items) do
local bit
 
Line 339 ⟶ 341:
end
 
ifbit = (item.separator thenor (i == 1 and "" or separator)) .. bit
bit = item.separator .. bit
end
 
insert(bits, bit)
Line 386:
end
 
-- The nature of hasInvalidSeparators() is such that we don't have to split a combined '/.../ [...]' spec into
-- into its parts in order to process.
if lang:getCode() == "en" and hasInvalidSeparators(item.pron) then
insert(categories, "IPA for English using .ˈ or .ˌ")
Line 394:
end
 
return process_maybe_split_categories(split_output, categories, concat(bits, separator), lang)
end
 
Line 590:
If not {nil}, and the specified language has data in [[Module:IPA/data]] indicating the allowed phonemes, then the page
will be added to a cleanup category and an error message displayed next to the outputted pronunciation. Note that {lang}
also determines sort key processing in the added cleanup categories. If `split_output` is not given, the return value is a
a concatenation of the formatted pronunciation, error messages and formatted cleanup categories. Otherwise, three values are
are returned: the formatted pronunciation, the cleanup categories and the concatenated error messages. If `split_output` is
is the value {"raw"}, the cleanup categories are returned in list form, where the list elements are a combination of category
category strings and category objects of the form suitable for passing to {format_categories()} in [[Module:utilities]]. If
If `split_output` is any other value besides {nil}, the cleanup categories are returned as a pre-formatted concatenated
string.
]==]
Line 628:
end
 
--[==[
Format a line of one or more enPR pronunciations as {{tl|enPR}} would do it, i.e. with a preceding {"enPR:"} (linked to
[[Appendix:English pronunciation]]) followed by one or more formatted, comma-separated enPR pronunciations. The
pronunciations are formatted by wrapping them in the {{cd|AHD}} and {{cd|enPR}} CSS classes and adding any left and
right regular and accent qualifiers. In addition, the overall result is wrapped in any overall left and right regular
and accent qualifiers. There is a single parameter `data`, an object with the following fields:
* `items` is a list of enPR pronunciations, each of which is an object with the following properties:
** `pron`: the enPR pronunciation;
** `q`: {nil} or a list of left qualifiers (as in {{tl|q}}) to display before the formatted pronunciation;
** `qq`: {nil} or a list of right qualifiers to display after the formatted pronunciation;
** `a`: {nil} or a list of left accent qualifiers (as in {{tl|a}}) to display before the formatted pronunciation;
** `aa`: {nil} or a list of right accent qualifiers to after before the formatted pronunciation.
* `q`: {nil} or a list of left qualifiers (as in {{tl|q}}) to display at the beginning, before the formatted
pronunciations and preceding {"enPR:"}.
* `qq`: {nil} or a list of right qualifiers to display after all formatted pronunciations.
* `a`: {nil} or a list of left accent qualifiers (as in {{tl|a}}) to display at the beginning, before the formatted
pronunciations and preceding {"enPR:"}.
* `aa`: {nil} or a list of right accent qualifiers to display after all formatted pronunciations.
]==]
function export.format_enPR_full(data)
local prefix = "[[Appendix:English pronunciation|enPR]]: "