Wikiwordbōc
angwiktionary
https://ang.wiktionary.org/wiki/H%C4%93afodtramet
MediaWiki 1.47.0-wmf.21
case-sensitive
Media
Syndrig
Mōtung
Brūcend
Brūcendmōtung
Wikiwordbōc
Wikiwordbōcmōtung
Ymele
Ymelmōtung
MediaWiki
MediaWikimōtung
Bysen
Bysenmōtung
Help
Helpmōtung
Flocc
Floccmōtung
Ætēaca
Ætēacmōtung
TimedText
TimedText talk
Module
Module talk
Event
Event talk
dēaþ
0
6423
54913
54870
2026-09-28T23:26:06Z
Deadend0914
7211
/* Wordstǣr */
54913
wikitext
text/x-wiki
=={{sprǣc|ang}}==
===Āwendednessa===
* deað
* dǣþ
===Rihtstefn===
* /dæːɑθ/
===Wordstǣr===
Of {{inh|ang|gmw-pro|*dauþu}}, of {{inh|ang|gem-pro|*dauþuz}}, of {{inh|ang|ine-pro|*dʰautus}}.
====Sweostorword====
*Denisc: {{Wendung|da|død}}
*[[Fresisc]]: {{Wendung|fy|dea}} ''wr''
*Īslendisc: {{Wendung|is|dauði}} ''wr''
*Niðerlendisc: {{Wendung|nl|dood}} ''wr''
*Norþwegisc: {{Wendung|no|død}} ''wr''
*[[Seaxisc]]: {{Wendung|nds|Dood}} ''wr''
*Swēonisc: {{Wendung|sv|död}} ''gm''
*Þēodisc: {{Wendung|de|Tod}} ''wr''
===Werlīc Nama===
# Þæs līfes ende.
#: '''''Dēaþ''' nis nān belimp on līfe. '''Dēaðes''' man ne gebītt. Gif man ēcnesse understent nā tō endelēasre tīdlengðe, ac tō tīdlēasnesse, þonne leofaþ sē on ēcnesse þe leofaþ on andweardnesse. Ūre līf is endelēas ealswā ūre gesihtfeld gemǣrelēas biþ.''
====Nīwenglisc Andgiet====
# [[death]]
====Declīnung====
{{ang-decl-noun-a-m|dēaþ}}
====Gesetnyssum====
[[ær]]-dēaþ - early death, death before one's time, premature death <br>
dēaþ-[[bēam]] "wr" - death tree <br>
dēaþ-[[bedd]] "nw" - death bed, grave, bed of death, <br>
dēaþ-[[cwalu]] "wf" - plague death, violent death, <br>
dēaþ-[[dæg]] "wr" - death day, day of death, <br>
dēaþ-denu "wf" - valley of death, <br>
fær-dēaþ, dēaþ-ræs "wr" - sudden death, <br>
dēaþ-scūa "wr", dēaþ-scufa "wr" - death shadow, shadow of death, <br>
dēaþ-[[scyld]] "wf" - crime worthy of death <br>
dēaþ-stede "wr" - place of death <br>
dēaþ-[[wang]] "wr" - death plain, <br>
dēaþ-wīc "nw" - death's place, dwelling of the dead, <br>
dēaþ-[[wyrd]] "wf" - death fate, fate of death <br>
[[ende]]-dēað -death as the end of life <br>
[[gúð]]-dēað - battle death, death in battle <br>
[[mere]]-dēaþ - sea death, death at sea, <br>
[[swylt]]-dēaþ - death (die-death) <br>
[[wæl]]-dēaþ - death in battle, <br>
[[wundor]]-dēaþ - wondrous death <br>
====Wendunga====
*Frencisc: {{Wendung|fr|mort}} ''wf''
*Grēcisc: {{Wendung|el|θάνατος}} [ˈθa.na.to̞s] ''wr'', {{Wendung|el|θανατάς}} [θa.na.ˈtas] ''wr'',
{{Wendung|el|πεθαμός}} [pe̞.θa.ˈmo̞s] ''wr'', {{Wendung|el|αποθαμός}} [a.po̞.θa.ˈmo̞s] {{m}}, {{Wendung|el|χάρος}} [ˈxa.ro̞s] ''wr''
*Hebrēisc: {{Wendung|he|מוות}} (mavet) ''wf''
*Italisc: {{Wendung|it|morte}} ''wf''
*Lǣden: {{Wendung|la|mors}} ''wf'', {{Wendung|la|exitium}} ''nā'', {{Wendung|la|quietus}} ''wr''
*Persisc: {{Wendung|fa|مرگ}}
*Scyttisc Gǣlisc: {{Wendung|gd|bàs}} ''wr''
[[Flocc:Englisc nama]]
[[Flocc: Englisc werlīc nama]]
331usa2sduy3gc6c978pto7lg5vxi3g
54915
54913
2026-09-28T23:27:33Z
Deadend0914
7211
/* Werlīc Nama */
54915
wikitext
text/x-wiki
=={{sprǣc|ang}}==
===Āwendednessa===
* deað
* dǣþ
===Rihtstefn===
* /dæːɑθ/
===Wordstǣr===
Of {{inh|ang|gmw-pro|*dauþu}}, of {{inh|ang|gem-pro|*dauþuz}}, of {{inh|ang|ine-pro|*dʰautus}}.
====Sweostorword====
*Denisc: {{Wendung|da|død}}
*[[Fresisc]]: {{Wendung|fy|dea}} ''wr''
*Īslendisc: {{Wendung|is|dauði}} ''wr''
*Niðerlendisc: {{Wendung|nl|dood}} ''wr''
*Norþwegisc: {{Wendung|no|død}} ''wr''
*[[Seaxisc]]: {{Wendung|nds|Dood}} ''wr''
*Swēonisc: {{Wendung|sv|död}} ''gm''
*Þēodisc: {{Wendung|de|Tod}} ''wr''
===Werlīc Nama===
{{ang-noun|m|head=dēaþ}}
# Þæs līfes ende.
#: '''''Dēaþ''' nis nān belimp on līfe. '''Dēaðes''' man ne gebītt. Gif man ēcnesse understent nā tō endelēasre tīdlengðe, ac tō tīdlēasnesse, þonne leofaþ sē on ēcnesse þe leofaþ on andweardnesse. Ūre līf is endelēas ealswā ūre gesihtfeld gemǣrelēas biþ.''
====Nīwenglisc Andgiet====
# [[death]]
====Declīnung====
{{ang-decl-noun-a-m|dēaþ}}
====Gesetnyssum====
[[ær]]-dēaþ - early death, death before one's time, premature death <br>
dēaþ-[[bēam]] "wr" - death tree <br>
dēaþ-[[bedd]] "nw" - death bed, grave, bed of death, <br>
dēaþ-[[cwalu]] "wf" - plague death, violent death, <br>
dēaþ-[[dæg]] "wr" - death day, day of death, <br>
dēaþ-denu "wf" - valley of death, <br>
fær-dēaþ, dēaþ-ræs "wr" - sudden death, <br>
dēaþ-scūa "wr", dēaþ-scufa "wr" - death shadow, shadow of death, <br>
dēaþ-[[scyld]] "wf" - crime worthy of death <br>
dēaþ-stede "wr" - place of death <br>
dēaþ-[[wang]] "wr" - death plain, <br>
dēaþ-wīc "nw" - death's place, dwelling of the dead, <br>
dēaþ-[[wyrd]] "wf" - death fate, fate of death <br>
[[ende]]-dēað -death as the end of life <br>
[[gúð]]-dēað - battle death, death in battle <br>
[[mere]]-dēaþ - sea death, death at sea, <br>
[[swylt]]-dēaþ - death (die-death) <br>
[[wæl]]-dēaþ - death in battle, <br>
[[wundor]]-dēaþ - wondrous death <br>
====Wendunga====
*Frencisc: {{Wendung|fr|mort}} ''wf''
*Grēcisc: {{Wendung|el|θάνατος}} [ˈθa.na.to̞s] ''wr'', {{Wendung|el|θανατάς}} [θa.na.ˈtas] ''wr'',
{{Wendung|el|πεθαμός}} [pe̞.θa.ˈmo̞s] ''wr'', {{Wendung|el|αποθαμός}} [a.po̞.θa.ˈmo̞s] {{m}}, {{Wendung|el|χάρος}} [ˈxa.ro̞s] ''wr''
*Hebrēisc: {{Wendung|he|מוות}} (mavet) ''wf''
*Italisc: {{Wendung|it|morte}} ''wf''
*Lǣden: {{Wendung|la|mors}} ''wf'', {{Wendung|la|exitium}} ''nā'', {{Wendung|la|quietus}} ''wr''
*Persisc: {{Wendung|fa|مرگ}}
*Scyttisc Gǣlisc: {{Wendung|gd|bàs}} ''wr''
[[Flocc:Englisc nama]]
[[Flocc: Englisc werlīc nama]]
ki8g2f2ew9fh0ivmafarwma1ptv7rct
Bysen:sprǣc
10
7569
54903
54789
2026-09-28T23:19:15Z
Deadend0914
7211
54903
wikitext
text/x-wiki
<includeonly>{{#invoke:sprǣcnaman|sprǣc|{{{1|}}}|{{{2|}}}}}</includeonly><noinclude>{{Documentation}}</noinclude>
t9y15oamh5dmc9itcudi2sonll1w1e2
Module:languages
828
7868
54897
54721
2026-09-28T22:28:57Z
Deadend0914
7211
Replaced content with "local m_bases = require("Module:bases") local m_params = require("Module:parameters") local languagesData = mw.loadData("Module:languages/data") local p = {} p.specialCodes = { ["zh-Hans"] = "zh", ["zh-Hant"] = "zh", ["yue-Hant"] = "yue", ["wuu-Hant"] = "wuu", ["ko-Hani"] = "ko", ["vi-Hani"] = "vi", ["vi-Hans"] = "vi", ["vi-Hant"] = "vi", ["nan-Hani"] = "nan", ["nan-Hans"] = "nan", ["nan-Hant"] = "nan", } --- Return the name of the language m..."
54897
Scribunto
text/plain
local m_bases = require("Module:bases")
local m_params = require("Module:parameters")
local languagesData = mw.loadData("Module:languages/data")
local p = {}
p.specialCodes = {
["zh-Hans"] = "zh",
["zh-Hant"] = "zh",
["yue-Hant"] = "yue",
["wuu-Hant"] = "wuu",
["ko-Hani"] = "ko",
["vi-Hani"] = "vi",
["vi-Hans"] = "vi",
["vi-Hant"] = "vi",
["nan-Hani"] = "nan",
["nan-Hans"] = "nan",
["nan-Hant"] = "nan",
}
--- Return the name of the language matching the given language code.
--- @param code string A language code.
--- @param allowSpecial? boolean If true, codes marked as group or special also will be considered.
--- @return string|nil # The matching language name, nil otherwise.
function p.getName(code, allowSpecial)
if not code or not languagesData[code] or not allowSpecial and (languagesData[code].isSpecial or languagesData[code].isGroup) then
return nil
end
return languagesData[code].name
end
--- Return the sort key for the given language code.
--- @param code string A language code.
--- @param allowSpecial? boolean If true, codes marked as group or special will also be considered.
--- @return string|nil # The sort key for the language, nil if the code is invalid.
function p.getSortKey(code, allowSpecial)
if not code or not languagesData[code] or not allowSpecial and (languagesData[code].isSpecial or languagesData[code].isGroup) then
return nil
end
return languagesData[code].sortKey or languagesData[code].name
end
--- Return the name of the given language. Available to templates.
--- @param frame frame
--- Parameters:
--- parent.args[1] (string): Language code.
--- @return string # The name of the language or an empty string if the code is invalid.
function p.languageName(frame)
local args = m_params.process(frame:getParent().args, {
[1] = {},
})
return p.getName(args[1]) or ""
end
--- Return the sort key for the given language code. Available to templates.
--- @param frame frame
--- Parameters:
--- args[1] (string, optional): Language code.
--- @return string|nil # The sort key for the language, nil if the code is invalid.
function p.languageSortKey(frame)
local args = m_params.process(frame:getParent().args, {
[1] = {},
})
return p.getSortKey(args[1]) or ""
end
--- Return the name of the given language with its first letter capitalized.
--- This function is used by the template {{L}}.
--- @param frame frame
--- Parameters:
--- parent.args[1] (string, optional): A language code.
--- @return string # The capitalized name of the language, an error message if none matched.
function p.languageNameForList(frame)
local args = m_params.process(frame:getParent().args, {
[1] = {}
})
local code = args[1]
if not code then
return '<span style="color: red">Sprǣce word missende</span>' ..
m_bases.fait_categorie_contenu("Wikiwordbēc:Sprǣce word missende")
end
local languageName = p.getName(code, true)
if not languageName then
return mw.ustring.format('<span style="color: red">Sprǣce word ungecnāwen : %s*</span>', code) ..
m_bases.fait_categorie_contenu("Wikiwordbēc:Sprǣce word ne sett")
end
return m_bases.ucfirst(languageName)
end
--- Return the Wikimedia language code for the given internal language code if it exists.
--- @param code string A language code.
--- @return string|nil # The corresponding Wikimedia language code, or nil if none matched.
function p.getWikimediaCode(code)
if not code or not languagesData[code] then
return nil
end
return languagesData[code].wikimediaCode
end
--- Return the Wikimedia language code for the given internal language code if it exists.
--- @param frame frame
--- Parameters:
--- parent.args[1] (string, optional): A language code.
--- @return string # The corresponding Wikimedia language code, or an empty string if none matched.
function p.wikimediaCode(frame)
local args = m_params.process(frame:getParent().args, {
[1] = {},
})
local code = args[1]
return p.getWikimediaCode(code) or code
end
--- Check whether a page in the “Duru” namespace exists for the given language code.
--- @param code string A language code.
--- @return boolean # True if a “Duru” page exists, false otherwise.
function p.hasPortal(code)
return languagesData[code] ~= nil and languagesData[code].hasPortal
end
--- Check whether a Wiktionary exists for the given language code.
--- @param code string Le code de langue.
--- @return boolean # True if a Wiktionary exists, false otherwise.
function p.hasWiktionary(code)
return languagesData[code] ~= nil and languagesData[code].wiktionaryExists
end
--- Return the code corresponding to the given language name.
--- @param languageName string A language name.
--- @param allowSpecial? boolean If true, codes marked as group or special also will be considered.
--- @return string | nil # The language’s code, or nil if none matched.
function p.getLanguageCode(languageName, allowSpecial)
for code, languageData in pairs(languagesData) do
if languageName == languageData.name and (allowSpecial or (not languageData.isGroup and not languageData.isSpecial)) then
return languageData.aliasOf or code
end
end
return nil
end
--- Return the code corresponding to the given language name.
--- If there are more than one, keep the shortest one.
--- The function also takes code aliases into account (e.g. "anglo-saxon" for "vieil anglais").
--- Special case: if there exists a code that strictly equals a language name,
--- it will be returned even if a shorter code exists (e.g. "vieil écossais" vs "vieux scots"),
--- unless there exists a code with 3 characters or less (e.g. "créole guadeloupéen" vs "gcf"),
--- except if the language name is "normand".
--- @param frame frame
--- Parameters:
--- parent.args[1] (string, optional): A language name. Defaults to the current page’s title.
--- parent.args["codes spéciaux"] (boolean, optional): If true, codes marked as group or special also will be considered.
--- @return string # The language’s code, or an empty string if none matched.
function p.languageCode(frame)
local args = m_params.process(frame:getParent().args, {
[1] = { default = mw.title.getCurrentTitle().text },
["codes spéciaux"] = { type = m_params.BOOLEAN, default = false },
})
return p.getLanguageCode(args[1], args["codes spéciaux"]) or ""
end
return p
oklj2oo5qnghkwu4c3o80a448skfcip
54899
54897
2026-09-28T22:40:08Z
Deadend0914
7211
54899
Scribunto
text/plain
--[==[ intro:
This module implements fetching of language-specific information and processing text in a given language.
===Types of languages===
There are two types of languages: full languages and etymology-only languages. The essential difference is that only
full languages appear in L2 headings in vocabulary entries, and hence categories like [[:Category:French nouns]] exist
only for full languages. Etymology-only languages have either a full language or another etymology-only language as
their parent (in the parent-child inheritance sense), and for etymology-only languages with another etymology-only
language as their parent, a full language can always be derived by following the parent links upwards. For example,
"Canadian French", code `fr-CA`, is an etymology-only language whose parent is the full language "French", code `fr`.
An example of an etymology-only language with another etymology-only parent is "Northumbrian Old English", code
`ang-nor`, which has "Anglian Old English", code `ang-ang` as its parent; this is an etymology-only language whose
parent is "Old English", code `ang`, which is a full language. (This is because Northumbrian Old English is considered
a variety of Anglian Old English.) Sometimes the parent is the "Undetermined" language, code `und`; this is the case,
for example, for "substrate" languages such as "Pre-Greek", code `qsb-grc`, and "the BMAC substrate", code `qsb-bma`.
It is important to distinguish language ''parents'' from language ''ancestors''. The parent-child relationship is one
of containment, i.e. if X is a child of Y, X is considered a variety of Y. On the other hand, the ancestor-descendant
relationship is one of descent in time. For example, "Classical Latin", code `la-cla`, and "Late Latin", code `la-lat`,
are both etymology-only languages with "Latin", code `la`, as their parents, because both of the former are varieties
of Latin. However, Late Latin does *NOT* have Classical Latin as its parent because Late Latin is *not* a variety of
Classical Latin; rather, it is a descendant. There is in fact a separate `ancestors` field that is used to express the
ancestor-descendant relationship, and Late Latin's ancestor is given as Classical Latin. It is also important to note
that sometimes an etymology-only language is actually the conceptual ancestor of its parent language. This happens,
for example, with "Old Italian" (code `roa-oit`), which is an etymology-only variant of full language "Italian" (code
`it`), and with "Old Latin" (code `itc-ola`), which is an etymology-only variant of Latin. In both cases, the full
language has the etymology-only variant listed as an ancestor. This allows a Latin term to inherit from Old Latin
using the {{tl|inh}} template (where in this template, "inheritance" refers to ancestral inheritance, i.e. inheritance
in time, rather than in the parent-child sense); likewise for Italian and Old Italian.
Full languages come in three subtypes:
* {regular}: This indicates a full language that is attested according to [[WT:CFI]] and therefore permitted in the
main namespace. There may also be reconstructed terms for the language, which are placed in the
{Reconstruction} namespace and must be prefixed with * to indicate a reconstruction. Most full languages
are natural (not constructed) languages, but a few constructed languages (e.g. Esperanto and Volapük,
among others) are also allowed in the mainspace and considered regular languages.
* {reconstructed}: This language is not attested according to [[WT:CFI]], and therefore is allowed only in the
{Reconstruction} namespace. All terms in this language are reconstructed, and must be prefixed with
*. Languages such as Proto-Indo-European and Proto-Germanic are in this category.
* {appendix-constructed}: This language is attested but does not meet the additional requirements set out for
constructed languages ([[WT:CFI#Constructed languages]]). Its entries must therefore be in
the Appendix namespace, but they are not reconstructed and therefore should not have *
prefixed in links. Most constructed languages are of this subtype.
Both full languages and etymology-only languages have a {Language} object associated with them, which is fetched using
the {getByCode} function in [[Module:languages]] to convert a language code to a {Language} object. Depending on the
options supplied to this function, etymology-only languages may or may not be accepted, and family codes may be
accepted (returning a {Family} object as described in [[Module:families]]). There are also separate {getByCanonicalName}
functions in [[Module:languages]] and [[Module:etymology languages]] to convert a language's canonical name to a
{Language} object (depending on whether the canonical name refers to a full or etymology-only language).
===Textual representations===
Textual strings belonging to a given language come in several different ''text variants'':
# The ''input text'' is what the user supplies in wikitext, in the parameters to {{tl|m}}, {{tl|l}}, {{tl|ux}},
{{tl|t}}, {{tl|lang}} and the like.
# The ''corrected input text'' is the input text with some corrections and/or normalizations applied, such as
bad-character replacements for certain languages, like replacing `l` or `1` to [[palochka]] in some languages written
in Cyrillic. (FIXME: This currently goes under the name ''display text'' but that will be repurposed below. Also,
[[User:Surjection]] suggests renaming this to ''normalized input text'', but "normalized" is used in a different sense
in [[Module:usex]].)
# The ''display text'' is the text in the form as it will be displayed to the user. This is what appears in headwords,
in usexes, in displayed internal links, etc. This can include accent marks that are removed to form the stripped
display text (see below), as well as embedded bracketed links that are variously processed further. The display text
is generated from the corrected input text by applying language-specific transformations; for most languages, there
will be no such transformations. The general reason for having a difference between input and display text is to allow
for extra information in the input text that is not displayed to the user but is sent to the transliteration module.
Note that having different display and input text is only supported currently through special-casing but will be
generalized. Examples of transformations are: (1) Removing the {{cd|^}} that is used in certain East Asian (and
possibly other unicameral) languages to indicate capitalization of the transliteration (which is currently
special-cased); (2) for Korean, removing or otherwise processing hyphens (which is currently special-cased); (3) for
Arabic, removing a ''sukūn'' diacritic placed over a ''tāʔ marbūṭa'' (like this: ةْ) to indicate that the
''tāʔ marbūṭa'' is pronounced and transliterated as /t/ instead of being silent [NOTE, NOT IMPLEMENTED YET]; (4) for
Thai and Khmer, converting space-separated words to bracketed words and resolving respelling substitutions such as
`[กรีน/กฺรีน]`, which indicate how to transliterate given words [NOTE, NOT IMPLEMENTED YET except in language-specific
templates like {{tl|th-usex}}].
## The ''right-resolved display text'' is the result of removing brackets around one-part embedded links and resolving
two-part embedded links into their right-hand components (i.e. converting two-part links into the displayed form).
The process of right-resolution is what happens when you call {{cd|remove_links()}} in [[Module:links]] on some text.
When applied to the display text, it produces exactly what the user sees, without any link markup.
# The ''stripped display text'' is the result of applying diacritic-stripping to the display text.
## The ''left-resolved stripped display text'' [NEED BETTER NAME] is the result of applying left-resolution to the
stripped display text, i.e. similar to right-resolution but resolving two-part embedded links into their left-hand
components (i.e. the linked-to page). If the display text refers to a single page, the resulting of applying
diacritic stripping and left-resolution produces the ''logical pagename''.
# The ''physical pagename text'' is the result of converting the stripped display text into physical page links. If the
stripped display text contains embedded links, the left side of those links is converted into physical page links;
otherwise, the entire text is considered a pagename and converted in the same fashion. The conversion does three
things: (1) converts characters not allowed in pagenames into their "unsupported title" representation, e.g.
{{cd|Unsupported titles/`gt`}} in place of the logical name {{cd|>}}; (2) handles certain special-cased
unsupported-title logical pagenames, such as {{cd|Unsupported titles/Space}} in place of {{cd|[space]}} and
{{cd|Unsupported titles/Ancient Greek dish}} in place of a very long Greek name for a gourmet dish as found in
Aristophanes; (3) converts "mammoth" pagenames such as [[a]] into their appropriate split component, e.g.
[[a/languages A to L]].
# The ''source translit text'' is the text as supplied to the language-specific {{cd|transliterate()}} method. The form
of the source translit text may need to be language-specific, e.g Thai and Khmer will need the corrected input text,
whereas other languages may need to work off the display text. [FIXME: It's still unclear to me how embedded bracketed
links are handled in the existing code.] In general, embedded links need to be right-resolved (see above), but when
this happens is unclear to me [FIXME]. Some languages have a chop-up-and-paste-together scheme that sends parts of the
text through the transliterate mechanism, and for others (those listed with "cont" in {{cd|substitution}} in
[[Module:languages/data]]) they receive the full input text, but preprocessed in certain ways. (The wisdom of this is
still unclear to me.)
# The ''transliterated text'' (or ''transliteration'') is the result of transliterating the source translit text. Unlike
for all the other text variants except the transcribed text, it is always in the Latin script.
# The ''transcribed text'' (or ''transcription'') is the result of transcribing the source translit text, where
"transcription" here means a close approximation to the phonetic form of the language in languages (e.g. Akkadian,
Sumerian, Ancient Egyptian, maybe Tibetan) that have a wide difference between the written letters and spoken form.
Unlike for all the other text variants other than the transliterated text, it is always in the Latin script.
Currently, the transcribed text is always supplied manually be the user; there is no such thing as a
{{cd|transcribe()}} method on language objects.
# The ''sort key'' is the text used in sort keys for determining the placing of pages in categories they belong to. The
sort key is generated from the pagename or a specified ''sort base'' by lowercasing, doing language-specific
transformations and then uppercasing the result. If the sort base is supplied and is generated from input text, it
needs to be converted to display text, have embedded links removed through right-resolution and have
diacritic-stripping applied.
# There are other text variants that occur in usexes (specifically, there are normalized variants of several of the
above text variants), but we can skip them for now.
The following methods exist on {Language} objects to convert between different text variants:
# {correctInputText} (currently called {makeDisplayText}): This converts input text to corrected input text.
# {stripDiacritics}: This converts to stripped display text. [FIXME: This needs some rethinking. In particular,
{stripDiacritics} is sometimes called on input text, corrected input text or display text (in various paths inside of
[[Module:links]], and, in the case of input text, usually from other modules). We need to make sure we don't try to
convert input text to display text twice, but at the same time we need to support calling it directly on input text
since so many modules do this. This means we need to add a parameter indicating whether the passed-in text is input,
corrected input, or display text; if the former two, we call {correctInputText} ourselves.]
# {logicalToPhysical}: This converts logical pagenames to physical pagenames.
# {transliterate}: This appears to convert input text with embedded brackets removed into a transliteration.
[FIXME: This needs some rethinking. In particular, it calls {processDisplayText} on its input, which won't work
for Thai and Khmer, so we may need language-specific flags indicating whether to pass the input text directly to the
language transliterate method. In addition, I'm not sure how embedded links are handled in the existing translit code;
a lot of callers remove the links themselves before calling {transliterate()}, which I assume is wrong.]
# {makeSortKey}: This converts display text (?) to a sort key. [FIXME: Clarify this.]
]==]
local export = {}
local debug_track_module = "Module:debug/track"
local etymology_languages_data_module = "Module:etymology languages/data"
local families_module = "Module:families"
local headword_page_module = "Module:headword/page"
local json_module = "Module:JSON"
local language_like_module = "Module:language-like"
local languages_data_module = "Module:languages/data"
local languages_data_patterns_module = "Module:languages/data/patterns"
local links_data_module = "Module:links/data"
local load_module = "Module:load"
local scripts_module = "Module:scripts"
local scripts_data_module = "Module:scripts/data"
local string_encode_entities_module = "Module:string/encode entities"
local string_pattern_escape_module = "Module:string/patternEscape"
local string_replacement_escape_module = "Module:string/replacementEscape"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local wikimedia_languages_module = "Module:wikimedia languages"
local mw = mw
local string = string
local table = table
local char = string.char
local concat = table.concat
local find = string.find
local floor = math.floor
local get_by_code -- Defined below.
local get_data_module_name -- Defined below.
local get_extra_data_module_name -- Defined below.
local getmetatable = getmetatable
local gmatch = string.gmatch
local gsub = string.gsub
local insert = table.insert
local ipairs = ipairs
local is_known_language_tag = mw.language.isKnownLanguageTag
local make_object -- Defined below.
local match = string.match
local next = next
local pairs = pairs
local remove = table.remove
local require = require
local select = select
local setmetatable = setmetatable
local sub = string.sub
local type = type
local unstrip = mw.text.unstrip
-- Loaded as needed by findBestScript.
local Hans_chars
local Hant_chars
local function check_object(...)
check_object = require(utilities_module).check_object
return check_object(...)
end
local function debug_track(...)
debug_track = require(debug_track_module)
return debug_track(...)
end
local function decode_entities(...)
decode_entities = require(string_utilities_module).decode_entities
return decode_entities(...)
end
local function decode_uri(...)
decode_uri = require(string_utilities_module).decode_uri
return decode_uri(...)
end
local function deep_copy(...)
deep_copy = require(table_module).deepCopy
return deep_copy(...)
end
local function encode_entities(...)
encode_entities = require(string_encode_entities_module)
return encode_entities(...)
end
local function get_L2_sort_key(...)
get_L2_sort_key = require(headword_page_module).get_L2_sort_key
return get_L2_sort_key(...)
end
local function get_script(...)
get_script = require(scripts_module).getByCode
return get_script(...)
end
local function find_best_script_without_lang(...)
find_best_script_without_lang = require(scripts_module).findBestScriptWithoutLang
return find_best_script_without_lang(...)
end
local function get_family(...)
get_family = require(families_module).getByCode
return get_family(...)
end
local function get_plaintext(...)
get_plaintext = require(utilities_module).get_plaintext
return get_plaintext(...)
end
local function get_wikimedia_lang(...)
get_wikimedia_lang = require(wikimedia_languages_module).getByCode
return get_wikimedia_lang(...)
end
local function keys_to_list(...)
keys_to_list = require(table_module).keysToList
return keys_to_list(...)
end
local function list_to_set(...)
list_to_set = require(table_module).listToSet
return list_to_set(...)
end
local function load_data(...)
load_data = require(load_module).load_data
return load_data(...)
end
local function make_family_object(...)
make_family_object = require(families_module).makeObject
return make_family_object(...)
end
local function pattern_escape(...)
pattern_escape = require(string_pattern_escape_module)
return pattern_escape(...)
end
local function replacement_escape(...)
replacement_escape = require(string_replacement_escape_module)
return replacement_escape(...)
end
local function safe_require(...)
safe_require = require(load_module).safe_require
return safe_require(...)
end
local function shallow_copy(...)
shallow_copy = require(table_module).shallowCopy
return shallow_copy(...)
end
local function split(...)
split = require(string_utilities_module).split
return split(...)
end
local function to_json(...)
to_json = require(json_module).toJSON
return to_json(...)
end
local function u(...)
u = require(string_utilities_module).char
return u(...)
end
local function ugsub(...)
ugsub = require(string_utilities_module).gsub
return ugsub(...)
end
local function ulen(...)
ulen = require(string_utilities_module).len
return ulen(...)
end
local function ulower(...)
ulower = require(string_utilities_module).lower
return ulower(...)
end
local function umatch(...)
umatch = require(string_utilities_module).match
return umatch(...)
end
local function uupper(...)
uupper = require(string_utilities_module).upper
return uupper(...)
end
local function track(page)
debug_track("languages/" .. page)
return true
end
local function normalize_code(code)
return load_data(languages_data_module).aliases[code] or code
end
local function check_inputs(self, check, default, ...)
local n = select("#", ...)
if n == 0 then
return false
end
local ret = check(self, (...))
if ret ~= nil then
return ret
elseif n > 1 then
local inputs = {...}
for i = 2, n do
ret = check(self, inputs[i])
if ret ~= nil then
return ret
end
end
end
return default
end
local function make_link(self, target, display)
local prefix, main
if self:getFamilyCode() == "qfa-sub" then
prefix, main = display:match("^(the )(.*)")
if not prefix then
prefix, main = display:match("^(a )(.*)")
end
end
return (prefix or "") .. "[[" .. target .. "|" .. (main or display) .. "]]"
end
-- Convert risky characters to HTML entities, which minimizes interference once returned (e.g. for "sms:a", "<!-- -->" etc.).
local function escape_risky_characters(text)
-- Spacing characters in isolation generally need to be escaped in order to be properly processed by the MediaWiki
-- software.
if umatch(text, "^%s*$") then
return encode_entities(text, text)
end
return encode_entities(text, "!#%&*+/:;<=>?@[\\]_{|}")
end
-- Temporarily convert various formatting characters to PUA to prevent them from being disrupted by the substitution process.
local function doTempSubstitutions(text, subbedChars, keepCarets, noTrim)
-- Clone so that we don't insert any extra patterns into the table in package.loaded. For some reason, using require
-- seems to keep memory use down; probably because the table is always cloned.
local patterns = shallow_copy(require(languages_data_patterns_module))
if keepCarets then
insert(patterns, "((\\+)%^)")
insert(patterns, "((%^))")
end
-- Ensure any whitespace at the beginning and end is temp substituted, to prevent it from being accidentally
-- trimmed. We only want to trim any final spaces added during the substitution process (e.g. by a module), which
-- means we only do this during the first round of temp substitutions.
if not noTrim then
insert(patterns, "^([\128-\191\244]*(%s+))")
insert(patterns, "((%s+)[\128-\191\244]*)$")
end
-- Pre-substitution, of "[[" and "]]", which makes pattern matching more accurate.
text = gsub(text, "%f[%[]%[%[", "\1"):gsub("%f[%]]%]%]", "\2")
local i = #subbedChars
for _, pattern in ipairs(patterns) do
-- Patterns ending in \0 stand are for things like "[[" or "]]"), so the inserted PUA are treated as breaks
-- between terms by modules that scrape info from pages.
local term_divider
pattern = gsub(pattern, "%z$", function(divider)
term_divider = divider == "\0"
return ""
end)
text = gsub(text, pattern, function(...)
local m = {...}
local m1New = m[1]
for k = 2, #m do
local n = i + k - 1
subbedChars[n] = m[k]
local byte2 = floor(n / 4096) % 64 + (term_divider and 128 or 136)
local byte3 = floor(n / 64) % 64 + 128
local byte4 = n % 64 + 128
m1New = gsub(m1New, pattern_escape(m[k]), "\244" .. char(byte2) .. char(byte3) .. char(byte4), 1)
end
i = i + #m - 1
return m1New
end)
end
text = gsub(text, "\1", "%[%["):gsub("\2", "%]%]")
return text, subbedChars
end
-- Reinsert any formatting that was temporarily substituted.
local function undoTempSubstitutions(text, subbedChars)
for i = 1, #subbedChars do
local byte2 = floor(i / 4096) % 64 + 128
local byte3 = floor(i / 64) % 64 + 128
local byte4 = i % 64 + 128
text = gsub(text, "\244[" .. char(byte2) .. char(byte2+8) .. "]" .. char(byte3) .. char(byte4),
replacement_escape(subbedChars[i]))
end
text = gsub(text, "\1", "%[%["):gsub("\2", "%]%]")
return text
end
-- Check if the raw text is an unsupported title, and if so return that. Otherwise, remove HTML entities. We do the
-- pre-conversion to avoid loading the unsupported title list unnecessarily.
local function checkNoEntities(text)
local textNoEnc = decode_entities(text)
if textNoEnc ~= text and load_data(links_data_module).unsupported_titles[text] then
return text
else
return textNoEnc
end
end
-- If no script object is provided (or if it's invalid or None), get one.
local function checkScript(text, self, sc)
if not check_object("script", true, sc) or sc:getCode() == "None" then
return self:findBestScript(text)
end
return sc
end
local function normalize(text, sc)
text = sc:fixDiscouragedSequences(text)
return sc:toFixedNFD(text)
end
--[=[
Subfunction of iterateSectionSubstitutions(). Process an individual chunk of text according to the specifications in
`substitution_data`. The input parameters are all as in the documentation of iterateSectionSubstitutions() except for
`recursed`, which is set to true if we called ourselves recursively to process a script-specific setting or
script-wide fallback. Returns two values: the processed text and the actual substitution data used to do the
substitutions (same as the `actual_substitution_data` return value to iterateSectionSubstitutions()).
]=]
local function doSubstitutions(self, text, sc, substitution_data, data_field, function_name, recursed)
-- BE CAREFUL in this function because the value at any level can be `false`, which causes no processing to be done
-- and blocks any further fallback processing.
local actual_substitution_data = substitution_data
-- If there are language-specific substitutes given in the data module, use those.
if type(substitution_data) == "table" then
-- If a script is specified, run this function with the script-specific data before continuing.
local sc_code = sc:getCode()
local has_substitution_data = false
if substitution_data[sc_code] ~= nil then
has_substitution_data = true
if substitution_data[sc_code] then
text, actual_substitution_data = doSubstitutions(self, text, sc, substitution_data[sc_code], data_field,
function_name, true)
end
-- Hant, Hans and Hani are usually treated the same, so add a special case to avoid having to specify each one
-- separately.
elseif sc_code:match("^Han") and substitution_data.Hani ~= nil then
has_substitution_data = true
if substitution_data.Hani then
text, actual_substitution_data = doSubstitutions(self, text, sc, substitution_data.Hani, data_field,
function_name, true)
end
-- Substitution data with key 1 in the outer table may be given as a fallback.
elseif substitution_data[1] ~= nil then
has_substitution_data = true
if substitution_data[1] then
text, actual_substitution_data = doSubstitutions(self, text, sc, substitution_data[1], data_field,
function_name, true)
end
end
-- Iterate over all strings in the "from" subtable, and gsub with the corresponding string in "to". We work with
-- the NFD decomposed forms, as this simplifies many substitutions.
if substitution_data.from then
has_substitution_data = true
for i, from in ipairs(substitution_data.from) do
-- Normalize each loop, to ensure multi-stage substitutions work correctly.
text = sc:toFixedNFD(text)
text = ugsub(text, sc:toFixedNFD(from), substitution_data.to[i] or "")
end
end
if substitution_data.remove_diacritics then
has_substitution_data = true
text = sc:toFixedNFD(text)
-- Convert exceptions to PUA.
local remove_exceptions, substitutes = substitution_data.remove_exceptions
if remove_exceptions then
substitutes = {}
local i = 0
for _, exception in ipairs(remove_exceptions) do
exception = sc:toFixedNFD(exception)
text = ugsub(text, exception, function(m)
i = i + 1
local subst = u(0x80000 + i)
substitutes[subst] = m
return subst
end)
end
end
-- Strip diacritics.
text = ugsub(text, "[" .. substitution_data.remove_diacritics .. "]", "")
-- Convert exceptions back.
if remove_exceptions then
text = text:gsub("\242[\128-\191]*", substitutes)
end
end
if not has_substitution_data and sc._data[data_field] then
-- If language-specific sort key (etc.) is nil, fall back to script-wide sort key (etc.).
text, actual_substitution_data = doSubstitutions(self, text, sc, sc._data[data_field], data_field,
function_name, true)
end
elseif type(substitution_data) == "string" then
-- If there is a dedicated function module, use that.
local module = safe_require("Module:" .. substitution_data)
if module then
-- TODO: translit functions should take objects, not codes.
-- TODO: translit functions should be called with form NFD.
if function_name == "tr" then
if not module[function_name] then
error(("Internal error: Module [[%s]] has no function named 'tr'"):format(substitution_data))
end
text = module[function_name](text, self._code, sc:getCode())
elseif function_name == "stripDiacritics" then
-- FIXME, get rid of this arm after renaming makeEntryName -> stripDiacritics.
if module[function_name] then
text = module[function_name](sc:toFixedNFD(text), self, sc)
elseif module.makeEntryName then
text = module.makeEntryName(sc:toFixedNFD(text), self, sc)
else
error(("Internal error: Module [[%s]] has no function named 'stripDiacritics' or 'makeEntryName'"
):format(substitution_data))
end
else
if not module[function_name] then
error(("Internal error: Module [[%s]] has no function named '%s'"):format(
substitution_data, function_name))
end
text = module[function_name](sc:toFixedNFD(text), self, sc)
end
else
error("Substitution data '" .. substitution_data .. "' does not match an existing module.")
end
elseif substitution_data == nil and sc._data[data_field] then
-- If language-specific sort key (etc.) is nil, fall back to script-wide sort key (etc.).
text, actual_substitution_data = doSubstitutions(self, text, sc, sc._data[data_field], data_field,
function_name, true)
end
-- Don't normalize to NFC if this is the inner loop or if a module returned nil.
if recursed or not text then
return text, actual_substitution_data
end
-- Fix any discouraged sequences created during the substitution process, and normalize into the final form.
return sc:toFixedNFC(sc:fixDiscouragedSequences(text)), actual_substitution_data
end
--[=[
Split the text into sections, based on the presence of temporarily substituted formatting characters, then iterate over
each section to apply substitutions (e.g. transliteration or diacritic stripping). This avoids putting PUA (Private Use
Area) characters through language-specific modules, which may be unequipped for them. This function is passed the
following values:
* `self` (the Language object);
* `text` (the text to process);
* `sc` (the script of the text, which must be specified; callers should call checkScript() as needed to autodetect the
script of the text if not given explicitly by the user);
* `subbedChars` (an array of the same length as the text, indicating which characters have been substituted and by
what, or {nil} if no substitutions are to happen);
* `keepCarets` (DOCUMENT ME);
* `substitution_data` (the data indicating which substitutions to apply, taken directly from `data_field` in the
language's data structure in a submodule of [[Module:languages/data]]);
* `data_field` (the field from which `substitution_data` was fetched, such as {"sort_key"} or {"strip_diacritics"});
* `function_name` (the name of the function to call to do the substitution, in case `substitution_data` specifies a
module to do the substitution);
* `notrim` (don't trim whitespace at the edges of `text`; set when computing the sort key, because whitespace at the
beginning of a sort key is significant and causes the resulting page to be sorted at the beginning of the category
it's in).
Return three values:
# the processed text;
# the value of `subbedChars` that was passed in, possibly modified with additional character substitutions; will be
{nil} if {nil} was passed in;
# the actual substitution data that was used to apply substitutions to `text`; this may be different from the value
of `substitution_data` passed in if that value recursively specified script-specific substitutions or if no
substitution data could be found in the language-specific data (e.g. {nil} was passed in or a structure was passed
in that had no setting for the script given in `sc`), but a script-wide fallback value was set; currently it is
only used by {makeSortKey()}.
]=]
local function iterateSectionSubstitutions(self, text, sc, subbedChars, keepCarets, substitution_data, data_field,
function_name, notrim)
local sections
-- See [[Module:languages/data]].
if not find(text, "\244") or load_data(languages_data_module).substitution[self._code] == "cont" then
sections = {text}
else
sections = split(text, "\244[\128-\143][\128-\191]*", true)
end
local actual_substitution_data
for _, section in ipairs(sections) do
-- Don't bother processing empty strings or whitespace (which may also not be handled well by dedicated
-- modules).
if gsub(section, "%s+", "") ~= "" then
local sub, this_actual_substitution_data = doSubstitutions(self, section, sc, substitution_data, data_field,
function_name)
actual_substitution_data = this_actual_substitution_data
-- Second round of temporary substitutions, in case any formatting was added by the main substitution
-- process. However, don't do this if the section contains formatting already (as it would have had to have
-- been escaped to reach this stage, and therefore should be given as raw text).
if sub and subbedChars then
local noSub
for _, pattern in ipairs(require(languages_data_patterns_module)) do
if match(section, pattern .. "%z?") then
noSub = true
end
end
if not noSub then
sub, subbedChars = doTempSubstitutions(sub, subbedChars, keepCarets, true)
end
end
if not sub then
text = sub
break
end
text = sub and gsub(text, pattern_escape(section), replacement_escape(sub), 1) or text
end
end
if not notrim then
-- Trim, unless there are only spacing characters, while ignoring any final formatting characters.
-- Do not trim sort keys because spaces at the beginning are significant.
text = text and text:gsub("^([\128-\191\244]*)%s+(%S)", "%1%2"):gsub("(%S)%s+([\128-\191\244]*)$", "%1%2") or
nil
end
return text, subbedChars, actual_substitution_data
end
-- Process carets (and any escapes). Default to simple removal, if no pattern/replacement is given.
local function processCarets(text, pattern, repl)
local rep
repeat
text, rep = gsub(text, "\\\\(\\*^)", "\3%1")
until rep == 0
return (text:gsub("\\^", "\4")
:gsub(pattern or "%^", repl or "")
:gsub("\3", "\\")
:gsub("\4", "^"))
end
-- Remove carets if they are used to capitalize parts of transliterations (unless they have been escaped).
local function removeCarets(text, sc)
if not sc:hasCapitalization() and sc:isTransliterated() and text:find("^", 1, true) then
return processCarets(text)
else
return text
end
end
local Language = {}
--[==[
Return the language code of the language. Example: {fr"} for French.
]==]
function Language:getCode()
return self._code
end
--[==[
Return the canonical name of the language. This is the name used to represent that language on Wiktionary, and is
guaranteed to be unique to that language alone. Example: {"French"} for French.
]==]
function Language:getCanonicalName()
local name = self._name
if name == nil then
name = self._data[1]
self._name = name
end
return name
end
--[==[
Return the display form of the language. The display form of a language, family or script is the form it takes when
appearing as the <code><var>source</var></code> in categories such as <code>English terms derived from
<var>source</var></code> or <code>English given names from <var>source</var></code>, and is also the displayed text
in `##makeCategoryLink()` links. For full and etymology-only languages, this is the same as the canonical name, but
for families, it reads <code>"<var>name</var> languages"</code> (e.g. {"Indo-Iranian languages"}), and for scripts,
it reads <code>"<var>name</var> script"</code> (e.g. {"Arabic script"}).
]==]
function Language:getDisplayForm()
local form = self._displayForm
if form == nil then
form = self:getCanonicalName()
-- Add article and " substrate" to substrates that lack them.
if self:getFamilyCode() == "qfa-sub" then
if not (sub(form, 1, 4) == "the " or sub(form, 1, 2) == "a ") then
form = "a " .. form
end
if not match(form, " [Ss]ubstrate") then
form = form .. " substrate"
end
end
self._displayForm = form
end
return form
end
--[==[
Return the value which should be used in the HTML `lang=` attribute for tagged text in the language.
]==]
function Language:getHTMLAttribute(sc, region)
local code = self._code
if not find(code, "-", 1, true) then
return code .. "-" .. sc:getCode() .. (region and "-" .. region or "")
end
local parent = self:getParent()
region = region or match(code, "%f[%u][%u-]+%f[%U]")
if parent then
return parent:getHTMLAttribute(sc, region)
end
-- TODO: ISO family codes can also be used.
return "mis-" .. sc:getCode() .. (region and "-" .. region or "")
end
--[==[
Return a list of the aliases that the language is known by, excluding the canonical name. Aliases are synonyms for the
language in question. The names are not guaranteed to be unique, in that sometimes more than one language is known by
the same name. Example: { {"High German", "New High German", "Deutsch"}} for {{lnl|de}}.
]==]
function Language:getAliases()
self:loadInExtraData()
return require(language_like_module).getAliases(self)
end
--[==[
Return a list of the known subvarieties of a given language, excluding subvarieties that have been given explicit
etymology-only language codes. The names are not guaranteed to be unique, in that sometimes a given name refers to a
subvariety of more than one language. Example: { {"Southern Aymara", "Central Aymara"}} for {{lnl|ay}}. Note that the
returned value can have nested tables in it, when a subvariety goes by more than one name. Example:
{ {"North Azerbaijani", "South Azerbaijani", {"Afshar", "Afshari", "Afshar Azerbaijani", "Afchar"}, {"Qashqa'i", "Qashqai", "Kashkay"}, "Sonqor"}}
for {{lnl|az}}. Here, for example, Afshar, Afshari, Afshar Azerbaijani and Afchar all refer to the same subvariety,
whose preferred name is Afshar (the one listed first). To avoid a return value with nested tables in it, specify a
non-{nil} value for the `flatten` parameter; in that case, the return value would be
{ {"North Azerbaijani", "South Azerbaijani", "Afshar", "Afshari", "Afshar Azerbaijani", "Afchar", "Qashqa'i", "Qashqai", "Kashkay", "Sonqor"}}.
]==]
function Language:getVarieties(flatten)
self:loadInExtraData()
return require(language_like_module).getVarieties(self, flatten)
end
--[==[
Return a table of the "other names" that the language is known by, which are listed in the `other_names` field in the
language's extra-data module. It should be noted that the `other_names` field itself is deprecated, and entries listed
there should eventually be moved to either `aliases` or `varieties`, or removed if they refer to larger entities which
the language in question is actually a part of.
]==]
function Language:getOtherNames() -- To be eventually removed, once there are no more uses of the `other_names` field.
self:loadInExtraData()
return require(language_like_module).getOtherNames(self)
end
--[==[
Return a combined table of the canonical name, aliases, varieties and other names of a given language.
]==]
function Language:getAllNames()
self:loadInExtraData()
return require(language_like_module).getAllNames(self)
end
--[==[
Return a table of types as a set (with the types as keys). The possible types are
* {language}: This is a language, either full or etymology-only.
* {full}: This is a "full" (not etymology-only) language, i.e. the union of {regular}, {reconstructed} and
{appendix-constructed}. Note that the types {full} and {etymology-only} also exist for families, so if you want to
check specifically for a full language and you have an object that might be a family, you should use
{hasType("language", "full")} and not simply {hasType("full")}.
* {etymology-only}: This is an etymology-only (not full) language, whose parent is another etymology-only language or a
full language. Note that the types {full} and {etymology-only} also exist for families, so if you want to check
specifically for an etymology-only language and you have an object that might be a family, you should use
{hasType("language", "etymology-only")} and not simply {hasType("etymology-only")}.
* {regular}: This indicates a full language that is attested according to [[WT:CFI]] and therefore permitted in the main
namespace. There may also be reconstructed terms for the language, which are placed in the {Reconstruction}
namespace and must be prefixed with `*` to indicate a reconstruction. Most full languages are natural
(not constructed) languages, but a few constructed languages (e.g. Esperanto and Volapük, among others) are also
allowed in the mainspace and considered regular languages.
* {reconstructed}: This language is not attested according to [[WT:CFI]], and therefore is allowed only in the
{Reconstruction} namespace. All terms in this language are reconstructed, and must be prefixed with `*`. Languages
such as Proto-Indo-European and Proto-Germanic are in this category. '''Exception:''' Reconstructed languages can
have entries in the mainspace using the ''anti-asterisk'' feature. This requires that both the headword for the
mainspace term (as specified using {{para|head}}) and links to the term are prefixed with the anti-asterisk
indicator `!!`.
* {appendix-constructed}: This language is attested but does not meet the additional requirements set out for
constructed languages ([[WT:CFI#Constructed languages]]). Its entries must therefore be in the Appendix namespace,
but they are not reconstructed and therefore should not have * prefixed in links.
]==]
function Language:getTypes()
local types = self._types
if types == nil then
types = {language = true}
if self:getFullCode() == self._code then
types.full = true
else
types["etymology-only"] = true
end
for t in gmatch(self._data.type, "[^,]+") do
types[t] = true
end
self._types = types
end
return types
end
--[==[
Given a list of types as strings, return {true} if the language has all of them.
]==]
function Language:hasType(...)
Language.hasType = require(language_like_module).hasType
return self:hasType(...)
end
--[==[
Return a list containing `WikimediaLanguage` objects (see [[Module:wikimedia languages]]), which represent languages
and their codes as they are used in Wikimedia projects for interwiki linking and such. More than one object may be
returned, as a single Wiktionary language may correspond to multiple Wikimedia languages. For example, Wiktionary's
single code `sh` (Serbo-Croatian) maps to four Wikimedia codes: `sh` (Serbo-Croatian), `bs` (Bosnian), `hr` (Croatian)
and `sr` (Serbian). The code for the Wikimedia language is retrieved from the `wikimedia_codes` property in the data
modules. If that property is not present, the code of the current language is used. If none of the available codes is
actually a valid Wikimedia code, an empty list is returned.
]==]
function Language:getWikimediaLanguages()
local wm_langs = self._wikimediaLanguageObjects
if wm_langs == nil then
local codes = self:getWikimediaLanguageCodes()
wm_langs = {}
for i = 1, #codes do
wm_langs[i] = get_wikimedia_lang(codes[i])
end
self._wikimediaLanguageObjects = wm_langs
end
return wm_langs
end
function Language:getWikimediaLanguageCodes()
local wm_langs = self._wikimediaLanguageCodes
if wm_langs == nil then
wm_langs = self._data.wikimedia_codes
if wm_langs then
wm_langs = split(wm_langs, ",", true, true)
else
local code = self._code
if is_known_language_tag(code) then
wm_langs = {code}
else
-- Inherit, but only if no codes are specified in the data *and*
-- the language code isn't a valid Wikimedia language code.
local parent = self:getParent()
wm_langs = parent and parent:getWikimediaLanguageCodes() or {}
end
end
self._wikimediaLanguageCodes = wm_langs
end
return wm_langs
end
--[==[
Return the name of the Wikipedia article for the language. `project` specifies the language and project to retrieve
the article from, defaulting to {"enwiki"} for the English Wikipedia. Normally if specified it should be the project
code for a specific-language Wikipedia e.g. "zhwiki" for the Chinese Wikipedia, but it can be any project, including
non-Wikipedia ones. If the project is the English Wikipedia and the property {wikipedia_article} is present in the data
module it will be used first. In all other cases, a sitelink will be generated from {:getWikidataItem} (if set). The
resulting value (or lack of value) is cached so that subsequent calls are fast. If no value could be determined, and
`noCategoryFallback` is {false}, `##Language:getCategoryName` is used as fallback; otherwise, {nil} is returned. Note
that if `noCategoryFallback` is {nil} or omitted, it defaults to {false} if the project is the English Wikipedia,
otherwise to {true}. In other words, under normal circumstances, if the English Wikipedia article couldn't be retrieved,
the return value will fall back to a link to the language's category, but this won't normally happen for any other
project.
]==]
function Language:getWikipediaArticle(noCategoryFallback, project)
Language.getWikipediaArticle = require(language_like_module).getWikipediaArticle
return self:getWikipediaArticle(noCategoryFallback, project)
end
function Language:makeWikipediaLink()
return make_link(self, "w:" .. self:getWikipediaArticle(), self:getCanonicalName())
end
--[==[
Return the name of the Wikimedia Commons category page for the language.
]==]
function Language:getCommonsCategory()
Language.getCommonsCategory = require(language_like_module).getCommonsCategory
return self:getCommonsCategory()
end
--[==[
Return the Wikidata item ID for the language or {nil}. This corresponds to the the second field in the data modules.
]==]
function Language:getWikidataItem()
Language.getWikidataItem = require(language_like_module).getWikidataItem
return self:getWikidataItem()
end
--[==[
Return a list of `Script` objects for all scripts that the language is written in. See [[Module:scripts]].
]==]
function Language:getScripts()
local scripts = self._scriptObjects
if scripts == nil then
local codes = self:getScriptCodes()
if codes[1] == "All" then
scripts = load_data(scripts_data_module)
else
scripts = {}
for i = 1, #codes do
scripts[i] = get_script(codes[i])
end
end
self._scriptObjects = scripts
end
return scripts
end
--[==[
Return the list of script codes in the language's data file.
]==]
function Language:getScriptCodes()
local scripts = self._scriptCodes
if scripts == nil then
scripts = self._data[4]
if scripts then
local codes, n = {}, 0
for code in gmatch(scripts, "[^,]+") do
n = n + 1
-- Special handling of "Hants", which represents "Hani", "Hant" and "Hans" collectively.
if code == "Hants" then
codes[n] = "Hani"
codes[n + 1] = "Hant"
codes[n + 2] = "Hans"
n = n + 2
else
codes[n] = code
end
end
scripts = codes
else
scripts = {"None"}
end
self._scriptCodes = scripts
end
return scripts
end
--[==[
Given some text, iterate through the scripts of a given language trying to find the script that best matches the text.
Return a {Script} object representing the script. If no match is found at all, it returns the {None} script object.
]==]
function Language:findBestScript(text, forceDetect)
if not text or text == "" or text == "-" then
return get_script("None")
end
-- Differs from table returned by getScriptCodes, as Hants is not normalized into its constituents.
local codes = self._bestScriptCodes
if codes == nil then
codes = self._data[4]
codes = codes and split(codes, ",", true, true) or {"None"}
self._bestScriptCodes = codes
end
local first_sc = codes[1]
if first_sc == "All" then
return find_best_script_without_lang(text)
end
local codes_len = #codes
if not (forceDetect or first_sc == "Hants" or codes_len > 1) then
first_sc = get_script(first_sc)
local charset = first_sc.characters
return charset and umatch(text, "[" .. charset .. "]") and first_sc or get_script("None")
end
-- Remove all formatting characters.
text = get_plaintext(text)
-- Remove all spaces and any ASCII punctuation. Some non-ASCII punctuation is script-specific, so can't be removed.
text = ugsub(text, "[%s!\"#%%&'()*,%-./:;?@[\\%]_{}]+", "")
if #text == 0 then
return get_script("None")
end
-- Try to match every script against the text,
-- and return the one with the most matching characters.
local bestcount, bestscript, length = 0
for i = 1, codes_len do
local sc = codes[i]
-- Special case for "Hants", which is a special code that represents whichever of "Hant" or "Hans" best matches,
-- or "Hani" if they match equally. This avoids having to list all three. In addition, "Hants" will be treated
-- as the best match if there is at least one matching character, under the assumption that a Han script is
-- desirable in terms that contain a mix of Han and other scripts (not counting those which use Jpan or Kore).
if sc == "Hants" then
local Hani = get_script("Hani")
if not Hant_chars then
Hant_chars = load_data("Module:zh/data/ts")
Hans_chars = load_data("Module:zh/data/st")
end
local t, s, found = 0, 0
-- This is faster than using mw.ustring.gmatch directly.
for ch in gmatch((ugsub(text, "[" .. Hani.characters .. "]", "\255%0")), "\255(.[\128-\191]*)") do
found = true
if Hant_chars[ch] then
t = t + 1
if Hans_chars[ch] then
s = s + 1
end
elseif Hans_chars[ch] then
s = s + 1
else
t, s = t + 1, s + 1
end
end
if found then
if t == s then
return Hani
end
return get_script(t > s and "Hant" or "Hans")
end
else
sc = get_script(sc)
if not length then
length = ulen(text)
end
-- Count characters by removing everything in the script's charset and comparing to the original length.
local charset = sc.characters
local count = charset and length - ulen((ugsub(text, "[" .. charset .. "]+", ""))) or 0
if count >= length then
return sc
elseif count > bestcount then
bestcount = count
bestscript = sc
end
end
end
-- Return best matching script, or otherwise None.
return bestscript or get_script("None")
end
--[==[
Return a `Family` object for the language family that the language belongs to. See [[Module:families]].
]==]
function Language:getFamily()
local family = self._familyObject
if family == nil then
family = self:getFamilyCode()
-- If the value is nil, it's cached as false.
family = family and get_family(family) or false
self._familyObject = family
end
return family or nil
end
--[==[
Return the family code in the language's data file.
]==]
function Language:getFamilyCode()
local family = self._familyCode
if family == nil then
-- If the value is nil, it's cached as false.
family = self._data[3] or false
self._familyCode = family
end
return family or nil
end
function Language:getFamilyName()
local family = self._familyName
if family == nil then
family = self:getFamily()
-- If the value is nil, it's cached as false.
family = family and family:getCanonicalName() or false
self._familyName = family
end
return family or nil
end
do
local function check_family(self, family)
if type(family) == "table" then
family = family:getCode()
end
if self:getFamilyCode() == family then
return true
end
local self_family = self:getFamily()
if self_family:inFamily(family) then
return true
-- If the family isn't a real family (e.g. creoles) check any ancestors.
elseif self_family:inFamily("qfa-not") then
local ancestors = self:getAncestors()
for _, ancestor in ipairs(ancestors) do
if ancestor:inFamily(family) then
return true
end
end
end
end
--[==[
Check whether the language belongs to `family` (which can be a family code or object). A list of objects can be given in
place of `family`; in that case, return true if the language belongs to any of the specified families. Note that some
languages (in particular, certain creoles) can have multiple immediate ancestors potentially belonging to different
families; in that case, return true if the language belongs to any of the specified families.
]==]
function Language:inFamily(...)
if self:getFamilyCode() == nil then
return false
end
return check_inputs(self, check_family, false, ...)
end
end
function Language:getParent()
local parent = self._parentObject
if parent == nil then
parent = self:getParentCode()
-- If the value is nil, it's cached as false.
parent = parent and get_by_code(parent, nil, true, true) or false
self._parentObject = parent
end
return parent or nil
end
function Language:getParentCode()
local parent = self._parentCode
if parent == nil then
-- If the value is nil, it's cached as false.
parent = self._data.parent or false
self._parentCode = parent
end
return parent or nil
end
function Language:getParentName()
local parent = self._parentName
if parent == nil then
parent = self:getParent()
-- If the value is nil, it's cached as false.
parent = parent and parent:getCanonicalName() or false
self._parentName = parent
end
return parent or nil
end
function Language:getParentChain()
local chain = self._parentChain
if chain == nil then
chain = {}
local parent, n = self:getParent(), 0
while parent do
n = n + 1
chain[n] = parent
parent = parent:getParent()
end
self._parentChain = chain
end
return chain
end
--[==[
Return a list of the pseudo-families (if any) that a language belongs to. The returned value is a list of Family
objects. Pseudo-families are groupings of languages that are not clades but share some geographic, ethnic or other
characteristic (e.g. [[:Category:Papuan languages]], [[:Category:Jewish languages]]).
]==]
function Language:getPseudoFamilies()
self:loadInExtraData()
return require(language_like_module).getPseudoFamilies(self)
end
do
local function check_lang(self, lang)
for _, parent in ipairs(self:getParentChain()) do
if (type(lang) == "string" and lang or lang:getCode()) == parent:getCode() then
return true
end
end
end
function Language:hasParent(...)
return check_inputs(self, check_lang, false, ...)
end
end
--[==[
If the language is etymology-only, iterate through parents until a full language or family is found, and the
corresponding object is returned. If the language is a full language, return that language.
]==]
function Language:getFull()
local full = self._fullObject
if full == nil then
full = self:getFullCode()
full = full == self._code and self or get_by_code(full)
self._fullObject = full
end
return full
end
--[==[
If the language is an etymology-only language, iterate through parents until a full language or family is found, and
the corresponding code is returned. If the language is a full language, return that language's code.
]==]
function Language:getFullCode()
return self._fullCode or self._code
end
--[==[
If the language is an etymology-only language, iterate through parents until a full language or family is found, and the
corresponding canonical name is returned. If the language is a full language, return that language's canonical name.
]==]
function Language:getFullName()
local full = self._fullName
if full == nil then
full = self:getFull():getCanonicalName()
self._fullName = full
end
return full
end
--[==[
Return a list of {Language} objects for all languages that this language is directly descended from. Generally this is
only a single language, but creoles, pidgins and mixed languages can have multiple ancestors.
]==]
function Language:getAncestors()
local ancestors = self._ancestorObjects
if ancestors == nil then
ancestors = {}
local ancestor_codes = self:getAncestorCodes()
if #ancestor_codes > 0 then
for _, ancestor in ipairs(ancestor_codes) do
insert(ancestors, get_by_code(ancestor, nil, true))
end
else
local fam = self:getFamily()
local protoLang = fam and fam:getProtoLanguage() or nil
-- For the cases where the current language is the proto-language
-- of its family, or an etymology-only language that is ancestral to that
-- proto-language, we need to step up a level higher right from the
-- start.
if protoLang and (
protoLang:getCode() == self._code or
(self:hasType("etymology-only") and protoLang:hasAncestor(self))
) then
fam = fam:getFamily()
protoLang = fam and fam:getProtoLanguage() or nil
end
while not protoLang and not (not fam or fam:getCode() == "qfa-not") do
fam = fam:getFamily()
protoLang = fam and fam:getProtoLanguage() or nil
end
insert(ancestors, protoLang)
end
self._ancestorObjects = ancestors
end
return ancestors
end
do
-- Avoid a language being its own ancestor via class inheritance. We only need to check for this if the language has
-- inherited an ancestor table from its parent, because we never want to drop ancestors that have been explicitly
-- set in the data. Recursively iterate over ancestors until we either find self or run out. If self is found,
-- return true.
local function check_ancestor(self, lang)
local codes = lang:getAncestorCodes()
if not codes then
return nil
end
for i = 1, #codes do
local code = codes[i]
if code == self._code then
return true
end
local anc = get_by_code(code, nil, true)
if check_ancestor(self, anc) then
return true
end
end
end
--[==[
Return a list of `Language` codes for all languages that this language is directly descended from. Generally this is
only a single language, but creoles, pidgins and mixed languages can have multiple ancestors.
]==]
function Language:getAncestorCodes()
if self._ancestorCodes then
return self._ancestorCodes
end
local data = self._data
local codes = data.ancestors
if codes == nil then
codes = {}
self._ancestorCodes = codes
return codes
end
codes = split(codes, ",", true, true)
self._ancestorCodes = codes
-- If there are no codes or the ancestors weren't inherited data, there's nothing left to check.
if #codes == 0 or self:getData(false, "raw").ancestors ~= nil then
return codes
end
local i = 1
while i <= #codes do
if check_ancestor(self, self) then
remove(codes, i)
else
i = i + 1
end
end
return codes
end
end
--[==[
Given a list of language objects or codes, return true if at least one of them is an ancestor. This includes any
etymology-only children of that ancestor. If the language's ancestor(s) are etymology-only languages, it will also
return true for those language parent(s) (e.g. if Vulgar Latin is the ancestor, it will also return true for its parent,
Latin). However, a parent is excluded from this if the ancestor is also ancestral to that parent (e.g. if Classical
Persian is the ancestor, Persian would return {false}, because Classical Persian is also ancestral to Persian).
]==]
function Language:hasAncestor(...)
local function iterateOverAncestorTree(node, func, parent_check)
local ancestors = node:getAncestors()
local ancestorsParents = {}
for _, ancestor in ipairs(ancestors) do
-- When checking the parents of the other language, and the ancestor is also a parent, skip to the next
-- ancestor, so that we exclude any etymology-only children of that parent that are not directly related
-- (see below).
local ret = (parent_check or not node:hasParent(ancestor)) and
func(ancestor) or iterateOverAncestorTree(ancestor, func, parent_check)
if ret then
return ret
end
end
-- Check the parents of any ancestors. We don't do this if checking the parents of the other language, so that
-- we exclude any etymology-only children of those parents that are not directly related (e.g. if the ancestor
-- is Vulgar Latin and we are checking New Latin, we want it to return false because they are on different
-- ancestral branches. As such, if we're already checking the parent of New Latin (Latin) we don't want to
-- compare it to the parent of the ancestor (Latin), as this would be a false positive; it should be one or the
-- other).
if not parent_check then
return nil
end
for _, ancestor in ipairs(ancestors) do
local ancestorParents = ancestor:getParentChain()
for _, ancestorParent in ipairs(ancestorParents) do
if ancestorParent:getCode() == self._code or ancestorParent:hasAncestor(ancestor) then
break
else
insert(ancestorsParents, ancestorParent)
end
end
end
for _, ancestorParent in ipairs(ancestorsParents) do
local ret = func(ancestorParent)
if ret then
return ret
end
end
end
local function do_iteration(otherlang, parent_check)
-- otherlang can't be self
if (type(otherlang) == "string" and otherlang or otherlang:getCode()) == self._code then
return false
end
repeat
if iterateOverAncestorTree(
self,
function(ancestor)
return ancestor:getCode() == (type(otherlang) == "string" and otherlang or otherlang:getCode())
end,
parent_check
) then
return true
elseif type(otherlang) == "string" then
otherlang = get_by_code(otherlang, nil, true)
end
otherlang = otherlang:getParent()
parent_check = false
until not otherlang
end
local parent_check = true
for _, otherlang in ipairs{...} do
local ret = do_iteration(otherlang, parent_check)
if ret then
return true
end
end
return false
end
do
local function construct_node(lang, memo)
local branch, ancestors = {lang = lang:getCode()}
memo[lang:getCode()] = branch
for _, ancestor in ipairs(lang:getAncestors()) do
if ancestors == nil then
ancestors = {}
end
insert(ancestors, memo[ancestor:getCode()] or construct_node(ancestor, memo))
end
branch.ancestors = ancestors
return branch
end
function Language:getAncestorChain()
local chain = self._ancestorChain
if chain == nil then
chain = construct_node(self, {})
self._ancestorChain = chain
end
return chain
end
end
function Language:getAncestorChainOld()
local chain = self._ancestorChain
if chain == nil then
chain = {}
local step = self
while true do
local ancestors = step:getAncestors()
step = #ancestors == 1 and ancestors[1] or nil
if not step then
break
end
insert(chain, step)
end
self._ancestorChain = chain
end
return chain
end
local function fetch_descendants(self, fmt)
local descendants, family = {}, self:getFamily()
-- Iterate over all three datasets.
for _, data in ipairs{
require("Module:languages/code to canonical name"),
require("Module:etymology languages/code to canonical name"),
require("Module:families/code to canonical name"),
} do
for code in pairs(data) do
local lang = get_by_code(code, nil, true, true)
if not lang then
error(("Internal error: code '%s' can't be fetched"):format(code))
end
-- Test for a descendant. Earlier tests weed out most candidates, while the more intensive tests are only used sparingly.
if (
code ~= self._code and -- Not self.
lang:inFamily(family) and -- In the same family.
(
family:getProtoLanguageCode() == self._code or -- Self is the protolanguage.
self:hasDescendant(lang) or -- Full hasDescendant check.
(lang:getFullCode() == self._code and not self:hasAncestor(lang)) -- Etymology-only child which isn't an ancestor.
)
) then
if fmt == "object" then
insert(descendants, lang)
elseif fmt == "code" then
insert(descendants, code)
elseif fmt == "name" then
insert(descendants, lang:getCanonicalName())
end
end
end
end
return descendants
end
function Language:getDescendants()
local descendants = self._descendantObjects
if descendants == nil then
descendants = fetch_descendants(self, "object")
self._descendantObjects = descendants
end
return descendants
end
function Language:getDescendantCodes()
local descendants = self._descendantCodes
if descendants == nil then
descendants = fetch_descendants(self, "code")
self._descendantCodes = descendants
end
return descendants
end
function Language:getDescendantNames()
local descendants = self._descendantNames
if descendants == nil then
descendants = fetch_descendants(self, "name")
self._descendantNames = descendants
end
return descendants
end
do
local function check_lang(self, lang)
if type(lang) == "string" then
lang = get_by_code(lang, nil, true)
end
if lang:hasAncestor(self) then
return true
end
end
function Language:hasDescendant(...)
return check_inputs(self, check_lang, false, ...)
end
end
local function fetch_children(self, fmt)
local m_etym_data = require(etymology_languages_data_module)
local self_code, children = self._code, {}
for code, lang in pairs(m_etym_data) do
local _lang = lang
repeat
local parent = _lang.parent
if parent == self_code then
if fmt == "object" then
insert(children, get_by_code(code, nil, true))
elseif fmt == "code" then
insert(children, code)
elseif fmt == "name" then
insert(children, lang[1])
end
break
end
_lang = m_etym_data[parent]
until not _lang
end
return children
end
function Language:getChildren()
local children = self._childObjects
if children == nil then
children = fetch_children(self, "object")
self._childObjects = children
end
return children
end
function Language:getChildrenCodes()
local children = self._childCodes
if children == nil then
children = fetch_children(self, "code")
self._childCodes = children
end
return children
end
function Language:getChildrenNames()
local children = self._childNames
if children == nil then
children = fetch_children(self, "name")
self._childNames = children
end
return children
end
function Language:hasChild(...)
local lang = ...
if not lang then
return false
elseif type(lang) == "string" then
lang = get_by_code(lang, nil, true)
end
if lang:hasParent(self) then
return true
end
return self:hasChild(select(2, ...))
end
--[==[
Return the name of the main category of that language. Example: {French language"} for French, whose category is at
[[:Category:French language]]. Unless optional argument `nocap` is given, the language name at the beginning of the
returned value will be capitalized. This capitalization is correct for category names, but not if the language name is
lowercase and the returned value of this function is used in the middle of a sentence.
]==]
function Language:getCategoryName(nocap)
local name = self._categoryName
if name == nil then
name = self:getCanonicalName()
-- If a substrate, omit any leading article.
if self:getFamilyCode() == "qfa-sub" then
name = name:gsub("^the ", ""):gsub("^a ", "")
end
-- Only add " language" if a full language.
if self:hasType("full") then
-- Unless the canonical name already ends with "language", "lect" or their derivatives, add " language".
if not (match(name, "[Ll]anguage$") or match(name, "[Ll]ect$")) then
name = name .. " language"
end
end
self._categoryName = name
end
if nocap then
return name
end
return mw.getContentLanguage():ucfirst(name)
end
--[==[
Create a link to the category; the link text is the canonical name.
]==]
function Language:makeCategoryLink()
return make_link(self, ":Category:" .. self:getCategoryName(), self:getDisplayForm())
end
function Language:getStandardCharacters(sc)
local standard_chars = self._data.standard_chars
if type(standard_chars) ~= "table" then
return standard_chars
elseif sc and type(sc) ~= "string" then
check_object("script", nil, sc)
sc = sc:getCode()
end
if (not sc) or sc == "None" then
local scripts = {}
for _, script in pairs(standard_chars) do
insert(scripts, script)
end
return concat(scripts)
end
if standard_chars[sc] then
return standard_chars[sc] .. (standard_chars[1] or "")
end
end
--[==[
Strip diacritics from display text `text` (in a language-specific fashion), which is in the script `sc`. If `sc` is
omitted or {nil}, the script is autodetected. This also strips certain punctuation characters from the end and (in the
case of Spanish upside-down question mark and exclamation points) from the beginning; strips any whitespace at the
end of the text or between the text and final stripped punctuation characters; and applies some language-specific
Unicode normalizations to replace discouraged characters with their prescribed alternatives. Return the stripped text.
]==]
function Language:stripDiacritics(text, sc)
if (not text) or text == "" then
return text
end
sc = checkScript(text, self, sc)
text = normalize(text, sc)
-- FIXME, rename makeEntryName to stripDiacritics and get rid of second and third return values
-- everywhere
local _
text, _, _ = iterateSectionSubstitutions(self, text, sc, nil, nil,
self._data.strip_diacritics or self._data.entry_name, "strip_diacritics", "stripDiacritics")
text = umatch(text, "^[¿¡]?(.-[^%s%p].-)%s*[؟?!;՛՜ ՞ ՟?!︖︕।॥။၊་།]?$") or text
return text
end
--[==[
Convert a ''logical'' pagename (the pagename as it appears to the user, after diacritics and punctuation have been
stripped) to a ''physical'' pagename (the pagename as it appears in the MediaWiki database). Reasons for a difference
between the two are (a) unsupported titles such as `[ ]` (with square brackets in them), `#` (pound/hash sign) and
`¯\_(ツ)_/¯` (with underscores), as well as overly long titles of various sorts; (b) "mammoth" pages that are split into
parts (e.g. `a`, which is split into physical pagenames `a/languages A to L` and `a/languages M to Z`). For almost all
purposes, you should work with logical and not physical pagenames. But there are certain use cases that require physical
pagenames, such as checking the existence of a page or retrieving a page's contents.
`pagename` is the logical pagename to be converted. `is_reconstructed_or_appendix` indicates whether the page is in the
`Reconstruction` or `Appendix` namespaces. If it is omitted or has the value {nil}, the pagename is checked for an
initial asterisk, and if found, the page is assumed to be a `Reconstruction` page. Setting a value of `false` or `true`
to `is_reconstructed_or_appendix` disables this check and allows for mainspace pagenames that begin with an asterisk.
]==]
function Language:logicalToPhysical(pagename, is_reconstructed_or_appendix)
-- FIXME: This probably shouldn't happen but it happens when makeEntryName() receives nil.
if pagename == nil then
track("nil-passed-to-logicalToPhysical")
return nil
end
local initial_asterisk
if is_reconstructed_or_appendix == nil then
local pagename_minus_initial_asterisk
initial_asterisk, pagename_minus_initial_asterisk = pagename:match("^(%*)(.*)$")
if pagename_minus_initial_asterisk then
is_reconstructed_or_appendix = true
pagename = pagename_minus_initial_asterisk
elseif self:hasType("appendix-constructed") then
is_reconstructed_or_appendix = true
end
end
if not is_reconstructed_or_appendix then
-- Check if the pagename is a listed unsupported title.
local unsupportedTitles = load_data(links_data_module).unsupported_titles
if unsupportedTitles[pagename] then
return "Unsupported titles/" .. unsupportedTitles[pagename]
end
end
-- Set `unsupported` as true if certain conditions are met.
local unsupported
-- Check if there's an unsupported character. \239\191\189 is the replacement character U+FFFD, which can't be typed
-- directly here due to an abuse filter. Unix-style dot-slash notation is also unsupported, as it is used for
-- relative paths in links, as are 3 or more consecutive tildes. Note: match is faster with magic
-- characters/charsets; find is faster with plaintext.
if (
match(pagename, "[#<>%[%]_{|}]") or
find(pagename, "\239\191\189") or
match(pagename, "%f[^%z/]%.%.?%f[%z/]") or
find(pagename, "~~~")
) then
unsupported = true
-- If it looks like an interwiki link.
elseif find(pagename, ":") then
local prefix = gsub(pagename, "^:*(.-):.*", ulower)
if (
load_data("Module:data/namespaces")[prefix] or
load_data("Module:data/interwikis")[prefix]
) then
unsupported = true
end
end
-- Escape unsupported characters so they can be used in titles. ` is used as a delimiter for this, so a raw use of
-- it in an unsupported title is also escaped here to prevent interference; this is only done with unsupported
-- titles, though, so inclusion won't in itself mean a title is treated as unsupported (which is why it's excluded
-- from the earlier test).
if unsupported then
-- FIXME: This conversion needs to be different for reconstructed pages with unsupported characters. There
-- aren't any currently, but if there ever are, we need to fix this e.g. to put them in something like
-- Reconstruction:Proto-Indo-European/Unsupported titles/`lowbar``num`.
local unsupported_characters = load_data(links_data_module).unsupported_characters
pagename = pagename:gsub("[#<>%[%]_`{|}\239]\191?\189?", unsupported_characters)
:gsub("%f[^%z/]%.%.?%f[%z/]", function(m)
return (gsub(m, "%.", "`period`"))
end)
:gsub("~~~+", function(m)
return (gsub(m, "~", "`tilde`"))
end)
pagename = "Unsupported titles/" .. pagename
elseif not is_reconstructed_or_appendix then
-- Check if this is a mammoth page. If so, which subpage should we link to?
local m_links_data = load_data(links_data_module)
local mammoth_page_type = m_links_data.mammoth_pages[pagename]
if mammoth_page_type then
local canonical_name = self:getFullName()
if canonical_name ~= "Translingual" and canonical_name ~= "English" then
local this_subpage
local L2_sort_key = get_L2_sort_key(canonical_name)
for _, subpage_spec in ipairs(m_links_data.mammoth_page_subpage_types[mammoth_page_type]) do
-- unpack() fails utterly on data loaded using mw.loadData() even if offsets are given
local subpage, pattern = subpage_spec[1], subpage_spec[2]
if pattern == true or L2_sort_key:match(pattern) then
this_subpage = subpage
break
end
end
if not this_subpage then
error(("Internal error: Bad data in mammoth_page_subpage_pages in [[Module:links/data]] for mammoth page %s, type %s; last entry didn't have 'true' in it"):format(
pagename, mammoth_page_type))
end
pagename = pagename .. "/" .. this_subpage
end
end
end
return (initial_asterisk or "") .. pagename
end
--[==[
Strip the diacritics from a display pagename and convert the resulting logical pagename into a physical pagename.
This allows you, for example, to retrieve the contents of the page or check its existence. WARNING: This is deprecated
and will be going away. It is a simple composition of `##Language:stripDiacritics` and `##Language:logicalToPhysical`;
most callers only want the former, and if you need both, call them both yourself.
`text` and `sc` are as in `##Language:stripDiacritics`, and `is_reconstructed_or_appendix` is as in
`##Language:logicalToPhysical`.
]==]
function Language:makeEntryName(text, sc, is_reconstructed_or_appendix)
track("makeEntryName called")
return self:logicalToPhysical(self:stripDiacritics(text, sc), is_reconstructed_or_appendix)
end
--[==[
Generate term alternants (e.g. simplified versions of traditional Chinese terms) using a language-specific method, and
return them as a table. If the language provides no method for generating alternants, return a table containing only the
input term.
]==]
function Language:generateAlternants(text, sc)
local generate_alternants = self._data.generate_alternants
if generate_alternants == nil then
return {text}
end
sc = checkScript(text, self, sc)
return require("Module:" .. generate_alternants).generateAlternants(text, self, sc)
end
--[==[
Create a sort key for the given stripped text, following the rules appropriate for the language. This removes
diacritical marks from the stripped text if they are not considered significant for sorting, and may perform some other
changes. Any initial hyphen is also removed, and anything in parentheses is removed as well. The `sort_key` setting for
each language in the data modules defines the replacements made by this function, or it gives the name of the module
that takes the stripped text and returns a sortkey.
]==]
function Language:makeSortKey(text, sc)
if (not text) or text == "" then
return text
end
if match(text, "<[^<>]+>") then
track("track HTML tag")
end
-- Remove directionality/control characters, bold, italics, soft hyphens, strip markers and HTML tags.
-- FIXME: Partly duplicated with remove_formatting() in [[Module:links]].
text = ugsub(text, "[\194\173\216\156\226\128\142\226\128\143\226\128\170-\226\128\174\226\129\166-\226\129\175]", "")
text = text:gsub("('*)'''(.-'*)'''", "%1%2"):gsub("('*)''(.-'*)''", "%1%2")
text = gsub(unstrip(text), "<[^<>]+>", "")
text = decode_uri(text, "PATH")
text = checkNoEntities(text)
-- Remove initial hyphens and * unless the term only consists of spacing + punctuation characters.
text = ugsub(text, "^([-]*)[-־ـ᠊*]+([-]*)(.*[^%s%p].*)", "%1%2%3")
sc = checkScript(text, self, sc)
text = normalize(text, sc)
text = removeCarets(text, sc)
-- For languages with dotted dotless i, ensure that "İ" is sorted as "i", and "I" is sorted as "ı".
if self:hasDottedDotlessI() then
text = gsub(text, "I\204\135", "i") -- decomposed "İ"
:gsub("I", "ı")
text = sc:toFixedNFD(text)
end
-- Convert to lowercase, make the sortkey, then convert to uppercase. Where the language has dotted dotless i, it is
-- usually not necessary to convert "i" to "İ" and "ı" to "I" first, because "I" will always be interpreted as
-- conventional "I" (not dotless "İ") by any sorting algorithms, which will have been taken into account by the
-- sortkey substitutions themselves. However, if no sortkey substitutions have been specified, then conversion is
-- necessary so as to prevent "i" and "ı" both being sorted as "I".
--
-- An exception is made for scripts that (sometimes) sort by scraping page content, as that means they are sensitive
-- to changes in capitalization (as it changes the target page).
if not sc:sortByScraping() then
text = ulower(text)
end
local actual_substitution_data, _
-- Don't trim whitespace here because it's significant at the beginning of a sort key or sort base.
text, _, actual_substitution_data = iterateSectionSubstitutions(self, text, sc, nil, nil,
self._data.sort_key, "sort_key", "makeSortKey", "notrim")
if not sc:sortByScraping() then
if self:hasDottedDotlessI() and not actual_substitution_data then
text = text:gsub("ı", "I"):gsub("i", "İ")
text = sc:toFixedNFC(text)
end
text = uupper(text)
end
-- Remove parentheses, as long as they are either preceded or followed by something.
text = gsub(text, "(.)[()]+", "%1"):gsub("[()]+(.)", "%1")
text = escape_risky_characters(text)
return text
end
--[==[
Create the form used as as a basis for display text and transliteration. FIXME: Rename to correctInputText().
]==]
local function processDisplayText(text, self, sc, keepCarets, keepPrefixes)
local subbedChars = {}
text, subbedChars = doTempSubstitutions(text, subbedChars, keepCarets)
text = decode_uri(text, "PATH")
text = checkNoEntities(text)
sc = checkScript(text, self, sc)
text = normalize(text, sc)
text, subbedChars = iterateSectionSubstitutions(self, text, sc, subbedChars, keepCarets, self._data.display_text,
"display_text", "makeDisplayText")
text = removeCarets(text, sc)
-- Remove any interwiki link prefixes (unless they have been escaped or this has been disabled).
if find(text, ":") and not keepPrefixes then
local rep
repeat
text, rep = gsub(text, "\\\\(\\*:)", "\3%1")
until rep == 0
text = gsub(text, "\\:", "\4")
while true do
local prefix = gsub(text, "^(.-):.+", function(m1)
return (gsub(m1, "\244[\128-\191]*", ""))
end)
-- Check if the prefix is an interwiki, though ignore capitalised Wiktionary:, which is a namespace.
if not prefix or prefix == text or prefix == "Wiktionary"
or not (load_data("Module:data/interwikis")[ulower(prefix)] or prefix == "") then
break
end
text = gsub(text, "^(.-):(.*)", function(m1, m2)
local ret = {}
for subbedChar in gmatch(m1, "\244[\128-\191]*") do
insert(ret, subbedChar)
end
return concat(ret) .. m2
end)
end
text = gsub(text, "\3", "\\"):gsub("\4", ":")
end
return text, subbedChars
end
--[==[
Make the display text (i.e. what is displayed on the page).
]==]
function Language:makeDisplayText(text, sc, keepPrefixes)
if not text or text == "" then
return text
end
local subbedChars
text, subbedChars = processDisplayText(text, self, sc, nil, keepPrefixes)
text = escape_risky_characters(text)
return undoTempSubstitutions(text, subbedChars)
end
--[==[
Transliterate the text from the given script into Latin script (see [[Wiktionary:Transliteration and romanization]]).
The language must have the `translit` property for this to work; if it is not present, {nil} is returned.
The `sc` parameter is handled by the transliteration module, and how it is handled is specific to that module. Some
transliteration modules may tolerate {nil} as the script, others require it to be one of the possible scripts that the
module can transliterate, and will throw an error if it's not one of them. For this reason, the `sc` parameter should
always be provided when writing non-language-specific code.
The `module_override` parameter is used to override the default module that is used to provide the transliteration.
This is useful in cases where you need to demonstrate a particular module in use, but there is no default module yet,
or you want to demonstrate an alternative version of a transliteration module before making it official. It should not
be used in real modules or templates, only for testing. All uses of this parameter are tracked by
[[Wiktionary:Tracking/languages/module_override]].
'''Known bugs''':
* This function assumes {tr(s1) .. tr(s2) == tr(s1 .. s2)}. When this assertion fails, wikitext markups like
<nowiki>'''</nowiki> can cause wrong transliterations.
* HTML entities like `&apos;`, often used to escape wikitext markups, do not work.
]==]
function Language:transliterate(text, sc, module_override)
-- If there is no text, or the language doesn't have transliteration data and there's no override, return nil.
if not text or text == "" or text == "-" then
return text
end
-- If the script is not transliteratable (and no override is given), return nil.
sc = checkScript(text, self, sc)
if not (sc:isTransliterated() or module_override) then
-- temporary tracking to see if/when this gets triggered
track("non-transliterable")
track("non-transliterable/" .. self._code)
track("non-transliterable/" .. sc:getCode())
track("non-transliterable/" .. sc:getCode() .. "/" .. self._code)
return nil
end
-- Remove any strip markers.
text = unstrip(text)
-- Do not process the formatting into PUA characters for certain languages.
local processed = load_data(languages_data_module).substitution[self._code] ~= "none"
-- Get the display text with the keepCarets flag set.
local subbedChars
if processed then
text, subbedChars = processDisplayText(text, self, sc, true)
end
-- Transliterate (using the module override if applicable).
text, subbedChars = iterateSectionSubstitutions(self, text, sc, subbedChars, true, module_override or
self._data.translit, "translit", "tr")
if not text then
return nil
end
-- Incomplete transliterations return nil.
local charset = sc.characters
if charset and umatch(text, "[" .. charset .. "]") then
-- Remove any characters in Latin, which includes Latin characters also included in other scripts (as these are
-- false positives), as well as any PUA substitutions. Anything remaining should only be script code "None"
-- (e.g. numerals).
local check_text = ugsub(text, "[" .. get_script("Latn").characters .. "-]+", "")
-- Set none_is_last_resort_only flag, so that any non-None chars will cause a script other than "None" to be
-- returned.
if find_best_script_without_lang(check_text, true):getCode() ~= "None" then
return nil
end
end
if processed then
text = escape_risky_characters(text)
text = undoTempSubstitutions(text, subbedChars)
end
-- If the script does not use capitalization, then capitalize any letters of the transliteration which are
-- immediately preceded by a caret (and remove the caret).
if text and not sc:hasCapitalization() and text:find("^", 1, true) then
text = processCarets(text, "%^([\128-\191\244]*%*?)([^\128-\191\244][\128-\191]*)", function(m1, m2)
return m1 .. uupper(m2)
end)
end
-- Track module overrides.
if module_override ~= nil then
track("module_override")
end
return text
end
do
local function handle_language_spec(self, spec, sc)
local ret = self["_" .. spec]
if ret == nil then
ret = self._data[spec]
if type(ret) == "string" then
ret = list_to_set(split(ret, ",", true, true))
end
self["_" .. spec] = ret
end
if type(ret) == "table" then
ret = ret[sc:getCode()]
end
return not not ret
end
function Language:overrideManualTranslit(sc)
return handle_language_spec(self, "override_translit", sc)
end
function Language:link_tr(sc)
return handle_language_spec(self, "link_tr", sc)
end
end
--[==[
Return {true} if the language has a transliteration module, or {false} if it doesn't.
]==]
function Language:hasTranslit()
return not not self._data.translit
end
--[==[
Return {true} if the language uses the letters I/ı and İ/i, or {false} if it doesn't.]==]
function Language:hasDottedDotlessI()
return not not self._data.dotted_dotless_i
end
function Language:toJSON(opts)
local strip_diacritics, strip_diacritics_patterns, strip_diacritics_remove_diacritics = self._data.strip_diacritics
if strip_diacritics then
if strip_diacritics.from then
strip_diacritics_patterns = {}
for i, from in ipairs(strip_diacritics.from) do
insert(strip_diacritics_patterns, {from = from, to = strip_diacritics.to[i] or ""})
end
end
strip_diacritics_remove_diacritics = strip_diacritics.remove_diacritics
end
-- mainCode should only end up non-nil if dontCanonicalizeAliases is passed to make_object().
-- props should either contain zero-argument functions to compute the value, or the value itself.
local props = {
ancestors = function() return self:getAncestorCodes() end,
canonicalName = function() return self:getCanonicalName() end,
categoryName = function() return self:getCategoryName("nocap") end,
code = self._code,
mainCode = self._mainCode,
parent = function() return self:getParentCode() end,
full = function() return self:getFullCode() end,
stripDiacriticsPatterns = strip_diacritics_patterns,
stripDiacriticsRemoveDiacritics = strip_diacritics_remove_diacritics,
family = function() return self:getFamilyCode() end,
aliases = function() return self:getAliases() end,
varieties = function() return self:getVarieties() end,
otherNames = function() return self:getOtherNames() end,
pseudoFamilies = function() return self:getPseudoFamilies() end,
scripts = function() return self:getScriptCodes() end,
type = function() return keys_to_list(self:getTypes()) end,
wikimediaLanguages = function() return self:getWikimediaLanguageCodes() end,
wikidataItem = function() return self:getWikidataItem() end,
wikipediaArticle = function() return self:getWikipediaArticle(true) end,
}
local ret = {}
for prop, val in pairs(props) do
if not opts.skip_fields or not opts.skip_fields[prop] then
if type(val) == "function" then
ret[prop] = val()
else
ret[prop] = val
end
end
end
-- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`.
return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts)
end
function export.getDataModuleName(code)
local letter = match(code, "^(%l)%l%l?$")
return "Module:" .. (
letter == nil and "languages/data/exceptional" or
#code == 2 and "languages/data/2" or
"languages/data/3/" .. letter
)
end
get_data_module_name = export.getDataModuleName
function export.getExtraDataModuleName(code)
return get_data_module_name(code) .. "/extra"
end
get_extra_data_module_name = export.getExtraDataModuleName
do
local function make_stack(data)
local key_types = {
[2] = "unique",
aliases = "unique",
other_names = "unique",
type = "append",
varieties = "unique",
wikipedia_article = "unique",
wikimedia_codes = "unique"
}
local function __index(self, k)
local stack, key_type = getmetatable(self), key_types[k]
-- Data that isn't inherited from the parent.
if key_type == "unique" then
local v = stack[stack[make_stack]][k]
if v == nil then
local layer = stack[0]
if layer then -- Could be false if there's no extra data.
v = layer[k]
end
end
return v
-- Data that is appended by each generation.
elseif key_type == "append" then
local parts, offset, n = {}, 0, stack[make_stack]
for i = 1, n do
local part = stack[i][k]
if part == nil then
offset = offset + 1
else
parts[i - offset] = part
end
end
return offset ~= n and concat(parts, ",") or nil
end
local n = stack[make_stack]
while true do
local layer = stack[n]
if not layer then -- Could be false if there's no extra data.
return nil
end
local v = layer[k]
if v ~= nil then
return v
end
n = n - 1
end
end
local function __newindex()
error("table is read-only")
end
local function __pairs(self)
-- Iterate down the stack, caching keys to avoid duplicate returns.
local stack, seen = getmetatable(self), {}
local n = stack[make_stack]
local iter, state, k, v = pairs(stack[n])
return function()
repeat
repeat
k = iter(state, k)
if k == nil then
n = n - 1
local layer = stack[n]
if not layer then -- Could be false if there's no extra data.
return nil
end
iter, state, k = pairs(layer)
end
until not (k == nil or seen[k])
-- Get the value via a lookup, as the one returned by the
-- iterator will be the raw value from the current layer,
-- which may not be the one __index will return for that
-- key. Also memoize the key in `seen` (even if the lookup
-- returns nil) so that it doesn't get looked up again.
-- TODO: store values in `self`, avoiding the need to create
-- the `seen` table. The iterator will need to iterate over
-- `self` with `next` first to find these on future loops.
v, seen[k] = self[k], true
until v ~= nil
return k, v
end
end
local __ipairs = require(table_module).indexIpairs
function make_stack(data)
local stack = {
data,
[make_stack] = 1, -- stores the length and acts as a sentinel to confirm a given metatable is a stack.
__index = __index,
__newindex = __newindex,
__pairs = __pairs,
__ipairs = __ipairs,
}
stack.__metatable = stack
return setmetatable({}, stack), stack
end
return make_stack(data)
end
local function get_stack(data)
local stack = getmetatable(data)
return stack and type(stack) == "table" and stack[make_stack] and stack or nil
end
--[==[
<span style="color: var(--wikt-palette-red,#BA0000)">This function is not for use in entries or other content pages.</span>
Return a blob of data about the language. The format of this blob is undocumented, and perhaps unstable; it's intended
for things like the module's own unit-tests, which are "close friends" with the module and will be kept up-to-date as
the format changes. If `extra` is set, any extra data in the relevant `/extra` module will be included. (Note that it
will be included anyway if it has already been loaded into the language object.) If `raw` is set, then the returned data
will not contain any data inherited from parent objects.
-- Do NOT use these methods!
-- All uses should be pre-approved on the talk page!
]==]
function Language:getData(extra, raw)
if extra then
self:loadInExtraData()
end
local data = self._data
-- If raw is not set, just return the data.
if not raw then
return data
end
local stack = get_stack(data)
-- If there isn't a stack or its length is 1, return the data. Extra data (if any) will be included, as it's
-- stored at key 0 and doesn't affect the reported length.
if stack == nil then
return data
end
local n = stack[make_stack]
if n == 1 then
return data
end
extra = stack[0]
-- If there isn't any extra data, return the top layer of the stack.
if extra == nil then
return stack[n]
end
-- If there is, return a new stack which has the top layer at key 1 and the extra data at key 0.
data, stack = make_stack(stack[n])
stack[0] = extra
return data
end
function Language:loadInExtraData()
-- Only full languages have extra data.
if not self:hasType("language", "full") then
return
end
local data = self._data
-- If there's no stack, create one.
local stack = get_stack(self._data)
if stack == nil then
data, stack = make_stack(data)
-- If already loaded, return.
elseif stack[0] ~= nil then
return
end
self._data = data
-- Load extra data from the relevant module and add it to the stack at key 0, so that the __index and __pairs
-- metamethods will pick it up, since they iterate down the stack until they run out of layers.
local code = self._code
local modulename = get_extra_data_module_name(code)
-- No data cached as false.
stack[0] = modulename and load_data(modulename)[code] or false
end
--[==[
Return the name of the module containing the language's data, e.g. [[Module:languages/data/3/k]] for three-letter codes
beginning with `k`.
]==]
function Language:getDataModuleName()
local name = self._dataModuleName
if name == nil then
name = self:hasType("etymology-only") and etymology_languages_data_module or
get_data_module_name(self._mainCode or self._code)
self._dataModuleName = name
end
return name
end
--[==[
Return the name of the module containing the language's extra data, e.g. [[Module:languages/data/3/k/extra]] for
three-letter codes beginning with `k`.
]==]
function Language:getExtraDataModuleName()
local name = self._extraDataModuleName
if name == nil then
name = not self:hasType("etymology-only") and get_extra_data_module_name(self._mainCode or self._code) or false
self._extraDataModuleName = name
end
return name or nil
end
function export.makeObject(code, data, dontCanonicalizeAliases)
local data_type = type(data)
if data_type ~= "table" then
error(("bad argument #2 to 'makeObject' (table expected, got %s)"):format(data_type))
end
-- Convert any aliases.
local input_code = code
code = normalize_code(code)
input_code = dontCanonicalizeAliases and input_code or code
local parent
if data.parent then
parent = get_by_code(data.parent, nil, true, true)
else
parent = Language
end
parent.__index = parent
local lang = {_code = input_code}
-- This can only happen if dontCanonicalizeAliases is passed to make_object().
if code ~= input_code then
lang._mainCode = code
end
local parent_data = parent._data
if parent_data == nil then
-- Full code is the same as the code.
lang._fullCode = parent._code or code
else
-- Copy full code.
lang._fullCode = parent._fullCode
local stack = get_stack(parent_data)
if stack == nil then
parent_data, stack = make_stack(parent_data)
end
-- Insert the input data as the new top layer of the stack.
local n = stack[make_stack] + 1
data, stack[n], stack[make_stack] = parent_data, data, n
end
lang._data = data
return setmetatable(lang, parent)
end
make_object = export.makeObject
end
--[==[
Find the language whose code matches the one provided. If it exists, return a `Language` object representing the
language. Otherwise, return {nil}, unless `paramForError` is given, in which case an error is generated. If
`paramForError` is {true}, a generic error message mentioning the bad code is generated; otherwise `paramForError`
should be a string or number specifying the parameter that the code came from, and this parameter will be mentioned
in the error message along with the bad code. If `allowEtymLang` is specified, etymology-only language codes are allowed
and looked up along with full language codes. If `allowFamily` is specified, language family codes are allowed and
looked up along with normal language codes.
]==]
function export.getByCode(code, paramForError, allowEtymLang, allowFamily)
-- [[ Track uses of paramForError, ultimately so it can be removed, as error-handling should be done by
-- [[Module:parameters]], not here. ]] -- I (Benwing) disagree; that is an idealistic goal unlikely to be achievable
-- realistically.
if paramForError ~= nil then
track("paramForError")
end
if type(code) ~= "string" then
local typ
if not code then
typ = "nil"
elseif check_object("language", true, code) then
typ = "a language object"
elseif check_object("family", true, code) then
typ = "a family object"
else
typ = "a " .. type(code)
end
error("The function getByCode expects a string as its first argument, but received " .. typ .. ".")
end
local m_data = load_data(languages_data_module)
if m_data.aliases[code] or m_data.track[code] then
track(code)
end
local norm_code = normalize_code(code)
-- Get the data, checking for etymology-only languages if allowEtymLang is set.
local data = load_data(get_data_module_name(norm_code))[norm_code] or
allowEtymLang and load_data(etymology_languages_data_module)[norm_code]
-- If no data was found and allowFamily is set, check the family data. If the main family data was found, make the
-- object with [[Module:families]] instead, as family objects have different methods. However, if it's an
-- etymology-only family, use make_object in this module (which handles object inheritance), and the
-- family-specific methods will be inherited from the parent object.
if data == nil and allowFamily then
data = load_data("Module:families/data")[norm_code]
if data ~= nil then
if data.parent == nil then
return make_family_object(norm_code, data)
elseif not allowEtymLang then
data = nil
end
end
end
local retval = code and data and make_object(code, data)
if not retval and paramForError then
require("Module:languages/errorGetBy").code(code, paramForError, allowEtymLang, allowFamily)
end
return retval
end
get_by_code = export.getByCode
--[==[
Find the language whose canonical name (the name used to represent that language on Wiktionary) or other name matches
the one provided. If it exists, return a `Language` object representing the language. Otherwise, return {nil}, unless
`paramForError` is given, in which case an error is generated. If `allowEtymLang` is specified, etymology-only language
codes are allowed and looked up along with full language codes. If `allowFamily` is specified, language family codes are
allowed and looked up along with normal language codes. The canonical name of languages should always be unique (it is
an error for two languages on Wiktionary to share the same canonical name), so this is guaranteed to give at most one
result. This function is powered by [[Module:languages/canonical names]], which contains a pre-generated mapping of
full-language canonical names to codes. It is generated by going through the [[:Category:Language data modules]] for
full languages. When `allowEtymLang` is specified for the above function, [[Module:etymology languages/canonical names]]
may also be used, and when `allowFamily` is specified for the above function, [[Module:families/canonical names]] may
also be used.
]==]
function export.getByCanonicalName(name, errorIfInvalid, allowEtymLang, allowFamily)
local byName = load_data("Module:languages/canonical names")
local code = byName and byName[name]
if not code and allowEtymLang then
byName = load_data("Module:etymology languages/canonical names")
code = byName and byName[name] or
byName[gsub(name, " [Ss]ubstrate$", "")] or
byName[gsub(name, "^a ", "")] or
byName[gsub(name, "^a ", ""):gsub(" [Ss]ubstrate$", "")] or
-- For etymology families like "ira-pro".
-- FIXME: This is not ideal, as it allows " languages" to be appended to any etymology-only language, too.
byName[match(name, "^(.*) languages$")]
end
if not code and allowFamily then
byName = load_data("Module:families/canonical names")
code = byName[name] or byName[match(name, "^(.*) languages$")]
end
local retval = code and get_by_code(code, errorIfInvalid, allowEtymLang, allowFamily)
if not retval and errorIfInvalid then
require("Module:languages/errorGetBy").canonicalName(name, allowEtymLang, allowFamily)
end
return retval
end
--[==[
Used by [[Module:languages/data/2]] (et al.) and [[Module:etymology languages/data]], [[Module:families/data]],
[[Module:scripts/data]] and [[Module:writing systems/data]] to finalize the data into the format that is actually returned.
]==]
function export.finalizeData(data, main_type, variety)
local fields = {"type"}
if main_type == "language" then
insert(fields, 4) -- script codes
insert(fields, "ancestors")
insert(fields, "link_tr")
insert(fields, "override_translit")
insert(fields, "wikimedia_codes")
elseif main_type == "script" then
insert(fields, 3) -- writing system codes
end -- Families and writing systems have no extra fields to process.
local fields_len = #fields
for _, entity in next, data do
if variety then
-- Move parent from 3 to "parent" and family from "family" to 3. These are different for the sake of
-- convenience, since very few varieties have the family specified, whereas all of them have a parent.
entity.parent, entity[3] = entity[3], entity.family
entity.family = nil
-- Give the type "regular" iff not a variety and no other types are assigned.
elseif not (entity.type or entity.parent) then
entity.type = "regular"
end
for i = 1, fields_len do
local key = fields[i]
local field = entity[key]
if field and type(field) == "string" then
entity[key] = gsub(field, "%s*,%s*", ",")
end
end
end
return data
end
--[==[
For backwards compatibility only; modules should require the error themselves.
]==]
function export.err(lang_code, param, code_desc, template_tag, not_real_lang)
return require("Module:languages/error")(lang_code, param, code_desc, template_tag, not_real_lang)
end
return export
mz43zcz6drvto1xyal5io97jdfkt6jx
54917
54899
2026-09-28T23:58:09Z
Deadend0914
7211
54917
Scribunto
text/plain
--[==[ intro:
This module implements fetching of language-specific information and processing text in a given language.
===Types of languages===
There are two types of languages: full languages and etymology-only languages. The essential difference is that only
full languages appear in L2 headings in vocabulary entries, and hence categories like [[:Category:French nouns]] exist
only for full languages. Etymology-only languages have either a full language or another etymology-only language as
their parent (in the parent-child inheritance sense), and for etymology-only languages with another etymology-only
language as their parent, a full language can always be derived by following the parent links upwards. For example,
"Canadian French", code `fr-CA`, is an etymology-only language whose parent is the full language "French", code `fr`.
An example of an etymology-only language with another etymology-only parent is "Northumbrian Old English", code
`ang-nor`, which has "Anglian Old English", code `ang-ang` as its parent; this is an etymology-only language whose
parent is "Old English", code `ang`, which is a full language. (This is because Northumbrian Old English is considered
a variety of Anglian Old English.) Sometimes the parent is the "Undetermined" language, code `und`; this is the case,
for example, for "substrate" languages such as "Pre-Greek", code `qsb-grc`, and "the BMAC substrate", code `qsb-bma`.
It is important to distinguish language ''parents'' from language ''ancestors''. The parent-child relationship is one
of containment, i.e. if X is a child of Y, X is considered a variety of Y. On the other hand, the ancestor-descendant
relationship is one of descent in time. For example, "Classical Latin", code `la-cla`, and "Late Latin", code `la-lat`,
are both etymology-only languages with "Latin", code `la`, as their parents, because both of the former are varieties
of Latin. However, Late Latin does *NOT* have Classical Latin as its parent because Late Latin is *not* a variety of
Classical Latin; rather, it is a descendant. There is in fact a separate `ancestors` field that is used to express the
ancestor-descendant relationship, and Late Latin's ancestor is given as Classical Latin. It is also important to note
that sometimes an etymology-only language is actually the conceptual ancestor of its parent language. This happens,
for example, with "Old Italian" (code `roa-oit`), which is an etymology-only variant of full language "Italian" (code
`it`), and with "Old Latin" (code `itc-ola`), which is an etymology-only variant of Latin. In both cases, the full
language has the etymology-only variant listed as an ancestor. This allows a Latin term to inherit from Old Latin
using the {{tl|inh}} template (where in this template, "inheritance" refers to ancestral inheritance, i.e. inheritance
in time, rather than in the parent-child sense); likewise for Italian and Old Italian.
Full languages come in three subtypes:
* {regular}: This indicates a full language that is attested according to [[WT:CFI]] and therefore permitted in the
main namespace. There may also be reconstructed terms for the language, which are placed in the
{Reconstruction} namespace and must be prefixed with * to indicate a reconstruction. Most full languages
are natural (not constructed) languages, but a few constructed languages (e.g. Esperanto and Volapük,
among others) are also allowed in the mainspace and considered regular languages.
* {reconstructed}: This language is not attested according to [[WT:CFI]], and therefore is allowed only in the
{Reconstruction} namespace. All terms in this language are reconstructed, and must be prefixed with
*. Languages such as Proto-Indo-European and Proto-Germanic are in this category.
* {appendix-constructed}: This language is attested but does not meet the additional requirements set out for
constructed languages ([[WT:CFI#Constructed languages]]). Its entries must therefore be in
the Appendix namespace, but they are not reconstructed and therefore should not have *
prefixed in links. Most constructed languages are of this subtype.
Both full languages and etymology-only languages have a {Language} object associated with them, which is fetched using
the {getByCode} function in [[Module:languages]] to convert a language code to a {Language} object. Depending on the
options supplied to this function, etymology-only languages may or may not be accepted, and family codes may be
accepted (returning a {Family} object as described in [[Module:families]]). There are also separate {getByCanonicalName}
functions in [[Module:languages]] and [[Module:etymology languages]] to convert a language's canonical name to a
{Language} object (depending on whether the canonical name refers to a full or etymology-only language).
===Textual representations===
Textual strings belonging to a given language come in several different ''text variants'':
# The ''input text'' is what the user supplies in wikitext, in the parameters to {{tl|m}}, {{tl|l}}, {{tl|ux}},
{{tl|t}}, {{tl|lang}} and the like.
# The ''corrected input text'' is the input text with some corrections and/or normalizations applied, such as
bad-character replacements for certain languages, like replacing `l` or `1` to [[palochka]] in some languages written
in Cyrillic. (FIXME: This currently goes under the name ''display text'' but that will be repurposed below. Also,
[[User:Surjection]] suggests renaming this to ''normalized input text'', but "normalized" is used in a different sense
in [[Module:usex]].)
# The ''display text'' is the text in the form as it will be displayed to the user. This is what appears in headwords,
in usexes, in displayed internal links, etc. This can include accent marks that are removed to form the stripped
display text (see below), as well as embedded bracketed links that are variously processed further. The display text
is generated from the corrected input text by applying language-specific transformations; for most languages, there
will be no such transformations. The general reason for having a difference between input and display text is to allow
for extra information in the input text that is not displayed to the user but is sent to the transliteration module.
Note that having different display and input text is only supported currently through special-casing but will be
generalized. Examples of transformations are: (1) Removing the {{cd|^}} that is used in certain East Asian (and
possibly other unicameral) languages to indicate capitalization of the transliteration (which is currently
special-cased); (2) for Korean, removing or otherwise processing hyphens (which is currently special-cased); (3) for
Arabic, removing a ''sukūn'' diacritic placed over a ''tāʔ marbūṭa'' (like this: ةْ) to indicate that the
''tāʔ marbūṭa'' is pronounced and transliterated as /t/ instead of being silent [NOTE, NOT IMPLEMENTED YET]; (4) for
Thai and Khmer, converting space-separated words to bracketed words and resolving respelling substitutions such as
`[กรีน/กฺรีน]`, which indicate how to transliterate given words [NOTE, NOT IMPLEMENTED YET except in language-specific
templates like {{tl|th-usex}}].
## The ''right-resolved display text'' is the result of removing brackets around one-part embedded links and resolving
two-part embedded links into their right-hand components (i.e. converting two-part links into the displayed form).
The process of right-resolution is what happens when you call {{cd|remove_links()}} in [[Module:links]] on some text.
When applied to the display text, it produces exactly what the user sees, without any link markup.
# The ''stripped display text'' is the result of applying diacritic-stripping to the display text.
## The ''left-resolved stripped display text'' [NEED BETTER NAME] is the result of applying left-resolution to the
stripped display text, i.e. similar to right-resolution but resolving two-part embedded links into their left-hand
components (i.e. the linked-to page). If the display text refers to a single page, the resulting of applying
diacritic stripping and left-resolution produces the ''logical pagename''.
# The ''physical pagename text'' is the result of converting the stripped display text into physical page links. If the
stripped display text contains embedded links, the left side of those links is converted into physical page links;
otherwise, the entire text is considered a pagename and converted in the same fashion. The conversion does three
things: (1) converts characters not allowed in pagenames into their "unsupported title" representation, e.g.
{{cd|Unsupported titles/`gt`}} in place of the logical name {{cd|>}}; (2) handles certain special-cased
unsupported-title logical pagenames, such as {{cd|Unsupported titles/Space}} in place of {{cd|[space]}} and
{{cd|Unsupported titles/Ancient Greek dish}} in place of a very long Greek name for a gourmet dish as found in
Aristophanes; (3) converts "mammoth" pagenames such as [[a]] into their appropriate split component, e.g.
[[a/languages A to L]].
# The ''source translit text'' is the text as supplied to the language-specific {{cd|transliterate()}} method. The form
of the source translit text may need to be language-specific, e.g Thai and Khmer will need the corrected input text,
whereas other languages may need to work off the display text. [FIXME: It's still unclear to me how embedded bracketed
links are handled in the existing code.] In general, embedded links need to be right-resolved (see above), but when
this happens is unclear to me [FIXME]. Some languages have a chop-up-and-paste-together scheme that sends parts of the
text through the transliterate mechanism, and for others (those listed with "cont" in {{cd|substitution}} in
[[Module:languages/data]]) they receive the full input text, but preprocessed in certain ways. (The wisdom of this is
still unclear to me.)
# The ''transliterated text'' (or ''transliteration'') is the result of transliterating the source translit text. Unlike
for all the other text variants except the transcribed text, it is always in the Latin script.
# The ''transcribed text'' (or ''transcription'') is the result of transcribing the source translit text, where
"transcription" here means a close approximation to the phonetic form of the language in languages (e.g. Akkadian,
Sumerian, Ancient Egyptian, maybe Tibetan) that have a wide difference between the written letters and spoken form.
Unlike for all the other text variants other than the transliterated text, it is always in the Latin script.
Currently, the transcribed text is always supplied manually be the user; there is no such thing as a
{{cd|transcribe()}} method on language objects.
# The ''sort key'' is the text used in sort keys for determining the placing of pages in categories they belong to. The
sort key is generated from the pagename or a specified ''sort base'' by lowercasing, doing language-specific
transformations and then uppercasing the result. If the sort base is supplied and is generated from input text, it
needs to be converted to display text, have embedded links removed through right-resolution and have
diacritic-stripping applied.
# There are other text variants that occur in usexes (specifically, there are normalized variants of several of the
above text variants), but we can skip them for now.
The following methods exist on {Language} objects to convert between different text variants:
# {correctInputText} (currently called {makeDisplayText}): This converts input text to corrected input text.
# {stripDiacritics}: This converts to stripped display text. [FIXME: This needs some rethinking. In particular,
{stripDiacritics} is sometimes called on input text, corrected input text or display text (in various paths inside of
[[Module:links]], and, in the case of input text, usually from other modules). We need to make sure we don't try to
convert input text to display text twice, but at the same time we need to support calling it directly on input text
since so many modules do this. This means we need to add a parameter indicating whether the passed-in text is input,
corrected input, or display text; if the former two, we call {correctInputText} ourselves.]
# {logicalToPhysical}: This converts logical pagenames to physical pagenames.
# {transliterate}: This appears to convert input text with embedded brackets removed into a transliteration.
[FIXME: This needs some rethinking. In particular, it calls {processDisplayText} on its input, which won't work
for Thai and Khmer, so we may need language-specific flags indicating whether to pass the input text directly to the
language transliterate method. In addition, I'm not sure how embedded links are handled in the existing translit code;
a lot of callers remove the links themselves before calling {transliterate()}, which I assume is wrong.]
# {makeSortKey}: This converts display text (?) to a sort key. [FIXME: Clarify this.]
]==]
local export = {}
local debug_track_module = "Module:debug/track"
local etymology_languages_data_module = "Module:etymology languages/data"
local families_module = "Module:families"
local headword_page_module = "Module:headword/page"
local json_module = "Module:JSON"
local language_like_module = "Module:language-like"
local languages_data_module = "Module:languages/data"
local languages_data_patterns_module = "Module:languages/data/patterns"
local links_data_module = "Module:links/data"
local load_module = "Module:load"
local scripts_module = "Module:scripts"
local scripts_data_module = "Module:scripts/data"
local string_encode_entities_module = "Module:string/encode entities"
local string_pattern_escape_module = "Module:string/patternEscape"
local string_replacement_escape_module = "Module:string/replacementEscape"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local wikimedia_languages_module = "Module:wikimedia languages"
-- Old English localization: language names come from [[Module:sprǣcnaman]], which is also what
-- [[Bysen:sprǣc]] (the ==L2== heading template) uses, so L2 headings, categories, wordstǣr lines and
-- links can never disagree with each other. The module is optional: if it is missing, the English
-- names from the data modules are used exactly as before.
local ang_names_module = "Module:sprǣcnaman"
local ang_names
local function get_ang_names()
if ang_names == nil then
local ok, mod = pcall(require, ang_names_module)
ang_names = ok and mod or false
end
return ang_names or nil
end
-- Old English name of the given language, or nil.
local function ang_name(lang)
local mod = get_ang_names()
return mod and mod.get_name(lang) or nil
end
-- Code of the language with the given Old English name, or nil.
local function code_of_ang_name(name)
local mod = get_ang_names()
return mod and mod.get_code(name) or nil
end
local mw = mw
local string = string
local table = table
local char = string.char
local concat = table.concat
local find = string.find
local floor = math.floor
local get_by_code -- Defined below.
local get_data_module_name -- Defined below.
local get_extra_data_module_name -- Defined below.
local getmetatable = getmetatable
local gmatch = string.gmatch
local gsub = string.gsub
local insert = table.insert
local ipairs = ipairs
local is_known_language_tag = mw.language.isKnownLanguageTag
local make_object -- Defined below.
local match = string.match
local next = next
local pairs = pairs
local remove = table.remove
local require = require
local select = select
local setmetatable = setmetatable
local sub = string.sub
local type = type
local unstrip = mw.text.unstrip
-- Loaded as needed by findBestScript.
local Hans_chars
local Hant_chars
local function check_object(...)
check_object = require(utilities_module).check_object
return check_object(...)
end
local function debug_track(...)
debug_track = require(debug_track_module)
return debug_track(...)
end
local function decode_entities(...)
decode_entities = require(string_utilities_module).decode_entities
return decode_entities(...)
end
local function decode_uri(...)
decode_uri = require(string_utilities_module).decode_uri
return decode_uri(...)
end
local function deep_copy(...)
deep_copy = require(table_module).deepCopy
return deep_copy(...)
end
local function encode_entities(...)
encode_entities = require(string_encode_entities_module)
return encode_entities(...)
end
local function get_L2_sort_key(...)
get_L2_sort_key = require(headword_page_module).get_L2_sort_key
return get_L2_sort_key(...)
end
local function get_script(...)
get_script = require(scripts_module).getByCode
return get_script(...)
end
local function find_best_script_without_lang(...)
find_best_script_without_lang = require(scripts_module).findBestScriptWithoutLang
return find_best_script_without_lang(...)
end
local function get_family(...)
get_family = require(families_module).getByCode
return get_family(...)
end
local function get_plaintext(...)
get_plaintext = require(utilities_module).get_plaintext
return get_plaintext(...)
end
local function get_wikimedia_lang(...)
get_wikimedia_lang = require(wikimedia_languages_module).getByCode
return get_wikimedia_lang(...)
end
local function keys_to_list(...)
keys_to_list = require(table_module).keysToList
return keys_to_list(...)
end
local function list_to_set(...)
list_to_set = require(table_module).listToSet
return list_to_set(...)
end
local function load_data(...)
load_data = require(load_module).load_data
return load_data(...)
end
local function make_family_object(...)
make_family_object = require(families_module).makeObject
return make_family_object(...)
end
local function pattern_escape(...)
pattern_escape = require(string_pattern_escape_module)
return pattern_escape(...)
end
local function replacement_escape(...)
replacement_escape = require(string_replacement_escape_module)
return replacement_escape(...)
end
local function safe_require(...)
safe_require = require(load_module).safe_require
return safe_require(...)
end
local function shallow_copy(...)
shallow_copy = require(table_module).shallowCopy
return shallow_copy(...)
end
local function split(...)
split = require(string_utilities_module).split
return split(...)
end
local function to_json(...)
to_json = require(json_module).toJSON
return to_json(...)
end
local function u(...)
u = require(string_utilities_module).char
return u(...)
end
local function ugsub(...)
ugsub = require(string_utilities_module).gsub
return ugsub(...)
end
local function ulen(...)
ulen = require(string_utilities_module).len
return ulen(...)
end
local function ulower(...)
ulower = require(string_utilities_module).lower
return ulower(...)
end
local function umatch(...)
umatch = require(string_utilities_module).match
return umatch(...)
end
local function uupper(...)
uupper = require(string_utilities_module).upper
return uupper(...)
end
local function track(page)
debug_track("languages/" .. page)
return true
end
local function normalize_code(code)
return load_data(languages_data_module).aliases[code] or code
end
local function check_inputs(self, check, default, ...)
local n = select("#", ...)
if n == 0 then
return false
end
local ret = check(self, (...))
if ret ~= nil then
return ret
elseif n > 1 then
local inputs = {...}
for i = 2, n do
ret = check(self, inputs[i])
if ret ~= nil then
return ret
end
end
end
return default
end
local function make_link(self, target, display)
local prefix, main
if self:getFamilyCode() == "qfa-sub" then
prefix, main = display:match("^(the )(.*)")
if not prefix then
prefix, main = display:match("^(a )(.*)")
end
end
return (prefix or "") .. "[[" .. target .. "|" .. (main or display) .. "]]"
end
-- Convert risky characters to HTML entities, which minimizes interference once returned (e.g. for "sms:a", "<!-- -->" etc.).
local function escape_risky_characters(text)
-- Spacing characters in isolation generally need to be escaped in order to be properly processed by the MediaWiki
-- software.
if umatch(text, "^%s*$") then
return encode_entities(text, text)
end
return encode_entities(text, "!#%&*+/:;<=>?@[\\]_{|}")
end
-- Temporarily convert various formatting characters to PUA to prevent them from being disrupted by the substitution process.
local function doTempSubstitutions(text, subbedChars, keepCarets, noTrim)
-- Clone so that we don't insert any extra patterns into the table in package.loaded. For some reason, using require
-- seems to keep memory use down; probably because the table is always cloned.
local patterns = shallow_copy(require(languages_data_patterns_module))
if keepCarets then
insert(patterns, "((\\+)%^)")
insert(patterns, "((%^))")
end
-- Ensure any whitespace at the beginning and end is temp substituted, to prevent it from being accidentally
-- trimmed. We only want to trim any final spaces added during the substitution process (e.g. by a module), which
-- means we only do this during the first round of temp substitutions.
if not noTrim then
insert(patterns, "^([\128-\191\244]*(%s+))")
insert(patterns, "((%s+)[\128-\191\244]*)$")
end
-- Pre-substitution, of "[[" and "]]", which makes pattern matching more accurate.
text = gsub(text, "%f[%[]%[%[", "\1"):gsub("%f[%]]%]%]", "\2")
local i = #subbedChars
for _, pattern in ipairs(patterns) do
-- Patterns ending in \0 stand are for things like "[[" or "]]"), so the inserted PUA are treated as breaks
-- between terms by modules that scrape info from pages.
local term_divider
pattern = gsub(pattern, "%z$", function(divider)
term_divider = divider == "\0"
return ""
end)
text = gsub(text, pattern, function(...)
local m = {...}
local m1New = m[1]
for k = 2, #m do
local n = i + k - 1
subbedChars[n] = m[k]
local byte2 = floor(n / 4096) % 64 + (term_divider and 128 or 136)
local byte3 = floor(n / 64) % 64 + 128
local byte4 = n % 64 + 128
m1New = gsub(m1New, pattern_escape(m[k]), "\244" .. char(byte2) .. char(byte3) .. char(byte4), 1)
end
i = i + #m - 1
return m1New
end)
end
text = gsub(text, "\1", "%[%["):gsub("\2", "%]%]")
return text, subbedChars
end
-- Reinsert any formatting that was temporarily substituted.
local function undoTempSubstitutions(text, subbedChars)
for i = 1, #subbedChars do
local byte2 = floor(i / 4096) % 64 + 128
local byte3 = floor(i / 64) % 64 + 128
local byte4 = i % 64 + 128
text = gsub(text, "\244[" .. char(byte2) .. char(byte2+8) .. "]" .. char(byte3) .. char(byte4),
replacement_escape(subbedChars[i]))
end
text = gsub(text, "\1", "%[%["):gsub("\2", "%]%]")
return text
end
-- Check if the raw text is an unsupported title, and if so return that. Otherwise, remove HTML entities. We do the
-- pre-conversion to avoid loading the unsupported title list unnecessarily.
local function checkNoEntities(text)
local textNoEnc = decode_entities(text)
if textNoEnc ~= text and load_data(links_data_module).unsupported_titles[text] then
return text
else
return textNoEnc
end
end
-- If no script object is provided (or if it's invalid or None), get one.
local function checkScript(text, self, sc)
if not check_object("script", true, sc) or sc:getCode() == "None" then
return self:findBestScript(text)
end
return sc
end
local function normalize(text, sc)
text = sc:fixDiscouragedSequences(text)
return sc:toFixedNFD(text)
end
--[=[
Subfunction of iterateSectionSubstitutions(). Process an individual chunk of text according to the specifications in
`substitution_data`. The input parameters are all as in the documentation of iterateSectionSubstitutions() except for
`recursed`, which is set to true if we called ourselves recursively to process a script-specific setting or
script-wide fallback. Returns two values: the processed text and the actual substitution data used to do the
substitutions (same as the `actual_substitution_data` return value to iterateSectionSubstitutions()).
]=]
local function doSubstitutions(self, text, sc, substitution_data, data_field, function_name, recursed)
-- BE CAREFUL in this function because the value at any level can be `false`, which causes no processing to be done
-- and blocks any further fallback processing.
local actual_substitution_data = substitution_data
-- If there are language-specific substitutes given in the data module, use those.
if type(substitution_data) == "table" then
-- If a script is specified, run this function with the script-specific data before continuing.
local sc_code = sc:getCode()
local has_substitution_data = false
if substitution_data[sc_code] ~= nil then
has_substitution_data = true
if substitution_data[sc_code] then
text, actual_substitution_data = doSubstitutions(self, text, sc, substitution_data[sc_code], data_field,
function_name, true)
end
-- Hant, Hans and Hani are usually treated the same, so add a special case to avoid having to specify each one
-- separately.
elseif sc_code:match("^Han") and substitution_data.Hani ~= nil then
has_substitution_data = true
if substitution_data.Hani then
text, actual_substitution_data = doSubstitutions(self, text, sc, substitution_data.Hani, data_field,
function_name, true)
end
-- Substitution data with key 1 in the outer table may be given as a fallback.
elseif substitution_data[1] ~= nil then
has_substitution_data = true
if substitution_data[1] then
text, actual_substitution_data = doSubstitutions(self, text, sc, substitution_data[1], data_field,
function_name, true)
end
end
-- Iterate over all strings in the "from" subtable, and gsub with the corresponding string in "to". We work with
-- the NFD decomposed forms, as this simplifies many substitutions.
if substitution_data.from then
has_substitution_data = true
for i, from in ipairs(substitution_data.from) do
-- Normalize each loop, to ensure multi-stage substitutions work correctly.
text = sc:toFixedNFD(text)
text = ugsub(text, sc:toFixedNFD(from), substitution_data.to[i] or "")
end
end
if substitution_data.remove_diacritics then
has_substitution_data = true
text = sc:toFixedNFD(text)
-- Convert exceptions to PUA.
local remove_exceptions, substitutes = substitution_data.remove_exceptions
if remove_exceptions then
substitutes = {}
local i = 0
for _, exception in ipairs(remove_exceptions) do
exception = sc:toFixedNFD(exception)
text = ugsub(text, exception, function(m)
i = i + 1
local subst = u(0x80000 + i)
substitutes[subst] = m
return subst
end)
end
end
-- Strip diacritics.
text = ugsub(text, "[" .. substitution_data.remove_diacritics .. "]", "")
-- Convert exceptions back.
if remove_exceptions then
text = text:gsub("\242[\128-\191]*", substitutes)
end
end
if not has_substitution_data and sc._data[data_field] then
-- If language-specific sort key (etc.) is nil, fall back to script-wide sort key (etc.).
text, actual_substitution_data = doSubstitutions(self, text, sc, sc._data[data_field], data_field,
function_name, true)
end
elseif type(substitution_data) == "string" then
-- If there is a dedicated function module, use that.
local module = safe_require("Module:" .. substitution_data)
if module then
-- TODO: translit functions should take objects, not codes.
-- TODO: translit functions should be called with form NFD.
if function_name == "tr" then
if not module[function_name] then
error(("Internal error: Module [[%s]] has no function named 'tr'"):format(substitution_data))
end
text = module[function_name](text, self._code, sc:getCode())
elseif function_name == "stripDiacritics" then
-- FIXME, get rid of this arm after renaming makeEntryName -> stripDiacritics.
if module[function_name] then
text = module[function_name](sc:toFixedNFD(text), self, sc)
elseif module.makeEntryName then
text = module.makeEntryName(sc:toFixedNFD(text), self, sc)
else
error(("Internal error: Module [[%s]] has no function named 'stripDiacritics' or 'makeEntryName'"
):format(substitution_data))
end
else
if not module[function_name] then
error(("Internal error: Module [[%s]] has no function named '%s'"):format(
substitution_data, function_name))
end
text = module[function_name](sc:toFixedNFD(text), self, sc)
end
else
error("Substitution data '" .. substitution_data .. "' does not match an existing module.")
end
elseif substitution_data == nil and sc._data[data_field] then
-- If language-specific sort key (etc.) is nil, fall back to script-wide sort key (etc.).
text, actual_substitution_data = doSubstitutions(self, text, sc, sc._data[data_field], data_field,
function_name, true)
end
-- Don't normalize to NFC if this is the inner loop or if a module returned nil.
if recursed or not text then
return text, actual_substitution_data
end
-- Fix any discouraged sequences created during the substitution process, and normalize into the final form.
return sc:toFixedNFC(sc:fixDiscouragedSequences(text)), actual_substitution_data
end
--[=[
Split the text into sections, based on the presence of temporarily substituted formatting characters, then iterate over
each section to apply substitutions (e.g. transliteration or diacritic stripping). This avoids putting PUA (Private Use
Area) characters through language-specific modules, which may be unequipped for them. This function is passed the
following values:
* `self` (the Language object);
* `text` (the text to process);
* `sc` (the script of the text, which must be specified; callers should call checkScript() as needed to autodetect the
script of the text if not given explicitly by the user);
* `subbedChars` (an array of the same length as the text, indicating which characters have been substituted and by
what, or {nil} if no substitutions are to happen);
* `keepCarets` (DOCUMENT ME);
* `substitution_data` (the data indicating which substitutions to apply, taken directly from `data_field` in the
language's data structure in a submodule of [[Module:languages/data]]);
* `data_field` (the field from which `substitution_data` was fetched, such as {"sort_key"} or {"strip_diacritics"});
* `function_name` (the name of the function to call to do the substitution, in case `substitution_data` specifies a
module to do the substitution);
* `notrim` (don't trim whitespace at the edges of `text`; set when computing the sort key, because whitespace at the
beginning of a sort key is significant and causes the resulting page to be sorted at the beginning of the category
it's in).
Return three values:
# the processed text;
# the value of `subbedChars` that was passed in, possibly modified with additional character substitutions; will be
{nil} if {nil} was passed in;
# the actual substitution data that was used to apply substitutions to `text`; this may be different from the value
of `substitution_data` passed in if that value recursively specified script-specific substitutions or if no
substitution data could be found in the language-specific data (e.g. {nil} was passed in or a structure was passed
in that had no setting for the script given in `sc`), but a script-wide fallback value was set; currently it is
only used by {makeSortKey()}.
]=]
local function iterateSectionSubstitutions(self, text, sc, subbedChars, keepCarets, substitution_data, data_field,
function_name, notrim)
local sections
-- See [[Module:languages/data]].
if not find(text, "\244") or load_data(languages_data_module).substitution[self._code] == "cont" then
sections = {text}
else
sections = split(text, "\244[\128-\143][\128-\191]*", true)
end
local actual_substitution_data
for _, section in ipairs(sections) do
-- Don't bother processing empty strings or whitespace (which may also not be handled well by dedicated
-- modules).
if gsub(section, "%s+", "") ~= "" then
local sub, this_actual_substitution_data = doSubstitutions(self, section, sc, substitution_data, data_field,
function_name)
actual_substitution_data = this_actual_substitution_data
-- Second round of temporary substitutions, in case any formatting was added by the main substitution
-- process. However, don't do this if the section contains formatting already (as it would have had to have
-- been escaped to reach this stage, and therefore should be given as raw text).
if sub and subbedChars then
local noSub
for _, pattern in ipairs(require(languages_data_patterns_module)) do
if match(section, pattern .. "%z?") then
noSub = true
end
end
if not noSub then
sub, subbedChars = doTempSubstitutions(sub, subbedChars, keepCarets, true)
end
end
if not sub then
text = sub
break
end
text = sub and gsub(text, pattern_escape(section), replacement_escape(sub), 1) or text
end
end
if not notrim then
-- Trim, unless there are only spacing characters, while ignoring any final formatting characters.
-- Do not trim sort keys because spaces at the beginning are significant.
text = text and text:gsub("^([\128-\191\244]*)%s+(%S)", "%1%2"):gsub("(%S)%s+([\128-\191\244]*)$", "%1%2") or
nil
end
return text, subbedChars, actual_substitution_data
end
-- Process carets (and any escapes). Default to simple removal, if no pattern/replacement is given.
local function processCarets(text, pattern, repl)
local rep
repeat
text, rep = gsub(text, "\\\\(\\*^)", "\3%1")
until rep == 0
return (text:gsub("\\^", "\4")
:gsub(pattern or "%^", repl or "")
:gsub("\3", "\\")
:gsub("\4", "^"))
end
-- Remove carets if they are used to capitalize parts of transliterations (unless they have been escaped).
local function removeCarets(text, sc)
if not sc:hasCapitalization() and sc:isTransliterated() and text:find("^", 1, true) then
return processCarets(text)
else
return text
end
end
local Language = {}
--[==[
Return the language code of the language. Example: {fr"} for French.
]==]
function Language:getCode()
return self._code
end
--[==[
Return the canonical name of the language. This is the name used to represent that language on Wiktionary, and is
guaranteed to be unique to that language alone. Example: {"French"} for French.
]==]
function Language:getCanonicalName()
local name = self._name
if name == nil then
name = ang_name(self) or self._data[1]
self._name = name
end
return name
end
--[==[
Return the display form of the language. The display form of a language, family or script is the form it takes when
appearing as the <code><var>source</var></code> in categories such as <code>English terms derived from
<var>source</var></code> or <code>English given names from <var>source</var></code>, and is also the displayed text
in `##makeCategoryLink()` links. For full and etymology-only languages, this is the same as the canonical name, but
for families, it reads <code>"<var>name</var> languages"</code> (e.g. {"Indo-Iranian languages"}), and for scripts,
it reads <code>"<var>name</var> script"</code> (e.g. {"Arabic script"}).
]==]
function Language:getDisplayForm()
local form = self._displayForm
if form == nil then
form = self:getCanonicalName()
-- Add article and " substrate" to substrates that lack them.
if self:getFamilyCode() == "qfa-sub" then
if not (sub(form, 1, 4) == "the " or sub(form, 1, 2) == "a ") then
form = "a " .. form
end
if not match(form, " [Ss]ubstrate") then
form = form .. " substrate"
end
end
self._displayForm = form
end
return form
end
--[==[
Return the value which should be used in the HTML `lang=` attribute for tagged text in the language.
]==]
function Language:getHTMLAttribute(sc, region)
local code = self._code
if not find(code, "-", 1, true) then
return code .. "-" .. sc:getCode() .. (region and "-" .. region or "")
end
local parent = self:getParent()
region = region or match(code, "%f[%u][%u-]+%f[%U]")
if parent then
return parent:getHTMLAttribute(sc, region)
end
-- TODO: ISO family codes can also be used.
return "mis-" .. sc:getCode() .. (region and "-" .. region or "")
end
--[==[
Return a list of the aliases that the language is known by, excluding the canonical name. Aliases are synonyms for the
language in question. The names are not guaranteed to be unique, in that sometimes more than one language is known by
the same name. Example: { {"High German", "New High German", "Deutsch"}} for {{lnl|de}}.
]==]
function Language:getAliases()
self:loadInExtraData()
return require(language_like_module).getAliases(self)
end
--[==[
Return a list of the known subvarieties of a given language, excluding subvarieties that have been given explicit
etymology-only language codes. The names are not guaranteed to be unique, in that sometimes a given name refers to a
subvariety of more than one language. Example: { {"Southern Aymara", "Central Aymara"}} for {{lnl|ay}}. Note that the
returned value can have nested tables in it, when a subvariety goes by more than one name. Example:
{ {"North Azerbaijani", "South Azerbaijani", {"Afshar", "Afshari", "Afshar Azerbaijani", "Afchar"}, {"Qashqa'i", "Qashqai", "Kashkay"}, "Sonqor"}}
for {{lnl|az}}. Here, for example, Afshar, Afshari, Afshar Azerbaijani and Afchar all refer to the same subvariety,
whose preferred name is Afshar (the one listed first). To avoid a return value with nested tables in it, specify a
non-{nil} value for the `flatten` parameter; in that case, the return value would be
{ {"North Azerbaijani", "South Azerbaijani", "Afshar", "Afshari", "Afshar Azerbaijani", "Afchar", "Qashqa'i", "Qashqai", "Kashkay", "Sonqor"}}.
]==]
function Language:getVarieties(flatten)
self:loadInExtraData()
return require(language_like_module).getVarieties(self, flatten)
end
--[==[
Return a table of the "other names" that the language is known by, which are listed in the `other_names` field in the
language's extra-data module. It should be noted that the `other_names` field itself is deprecated, and entries listed
there should eventually be moved to either `aliases` or `varieties`, or removed if they refer to larger entities which
the language in question is actually a part of.
]==]
function Language:getOtherNames() -- To be eventually removed, once there are no more uses of the `other_names` field.
self:loadInExtraData()
return require(language_like_module).getOtherNames(self)
end
--[==[
Return a combined table of the canonical name, aliases, varieties and other names of a given language.
]==]
function Language:getAllNames()
self:loadInExtraData()
return require(language_like_module).getAllNames(self)
end
--[==[
Return a table of types as a set (with the types as keys). The possible types are
* {language}: This is a language, either full or etymology-only.
* {full}: This is a "full" (not etymology-only) language, i.e. the union of {regular}, {reconstructed} and
{appendix-constructed}. Note that the types {full} and {etymology-only} also exist for families, so if you want to
check specifically for a full language and you have an object that might be a family, you should use
{hasType("language", "full")} and not simply {hasType("full")}.
* {etymology-only}: This is an etymology-only (not full) language, whose parent is another etymology-only language or a
full language. Note that the types {full} and {etymology-only} also exist for families, so if you want to check
specifically for an etymology-only language and you have an object that might be a family, you should use
{hasType("language", "etymology-only")} and not simply {hasType("etymology-only")}.
* {regular}: This indicates a full language that is attested according to [[WT:CFI]] and therefore permitted in the main
namespace. There may also be reconstructed terms for the language, which are placed in the {Reconstruction}
namespace and must be prefixed with `*` to indicate a reconstruction. Most full languages are natural
(not constructed) languages, but a few constructed languages (e.g. Esperanto and Volapük, among others) are also
allowed in the mainspace and considered regular languages.
* {reconstructed}: This language is not attested according to [[WT:CFI]], and therefore is allowed only in the
{Reconstruction} namespace. All terms in this language are reconstructed, and must be prefixed with `*`. Languages
such as Proto-Indo-European and Proto-Germanic are in this category. '''Exception:''' Reconstructed languages can
have entries in the mainspace using the ''anti-asterisk'' feature. This requires that both the headword for the
mainspace term (as specified using {{para|head}}) and links to the term are prefixed with the anti-asterisk
indicator `!!`.
* {appendix-constructed}: This language is attested but does not meet the additional requirements set out for
constructed languages ([[WT:CFI#Constructed languages]]). Its entries must therefore be in the Appendix namespace,
but they are not reconstructed and therefore should not have * prefixed in links.
]==]
function Language:getTypes()
local types = self._types
if types == nil then
types = {language = true}
if self:getFullCode() == self._code then
types.full = true
else
types["etymology-only"] = true
end
for t in gmatch(self._data.type, "[^,]+") do
types[t] = true
end
self._types = types
end
return types
end
--[==[
Given a list of types as strings, return {true} if the language has all of them.
]==]
function Language:hasType(...)
Language.hasType = require(language_like_module).hasType
return self:hasType(...)
end
--[==[
Return a list containing `WikimediaLanguage` objects (see [[Module:wikimedia languages]]), which represent languages
and their codes as they are used in Wikimedia projects for interwiki linking and such. More than one object may be
returned, as a single Wiktionary language may correspond to multiple Wikimedia languages. For example, Wiktionary's
single code `sh` (Serbo-Croatian) maps to four Wikimedia codes: `sh` (Serbo-Croatian), `bs` (Bosnian), `hr` (Croatian)
and `sr` (Serbian). The code for the Wikimedia language is retrieved from the `wikimedia_codes` property in the data
modules. If that property is not present, the code of the current language is used. If none of the available codes is
actually a valid Wikimedia code, an empty list is returned.
]==]
function Language:getWikimediaLanguages()
local wm_langs = self._wikimediaLanguageObjects
if wm_langs == nil then
local codes = self:getWikimediaLanguageCodes()
wm_langs = {}
for i = 1, #codes do
wm_langs[i] = get_wikimedia_lang(codes[i])
end
self._wikimediaLanguageObjects = wm_langs
end
return wm_langs
end
function Language:getWikimediaLanguageCodes()
local wm_langs = self._wikimediaLanguageCodes
if wm_langs == nil then
wm_langs = self._data.wikimedia_codes
if wm_langs then
wm_langs = split(wm_langs, ",", true, true)
else
local code = self._code
if is_known_language_tag(code) then
wm_langs = {code}
else
-- Inherit, but only if no codes are specified in the data *and*
-- the language code isn't a valid Wikimedia language code.
local parent = self:getParent()
wm_langs = parent and parent:getWikimediaLanguageCodes() or {}
end
end
self._wikimediaLanguageCodes = wm_langs
end
return wm_langs
end
--[==[
Return the name of the Wikipedia article for the language. `project` specifies the language and project to retrieve
the article from, defaulting to {"enwiki"} for the English Wikipedia. Normally if specified it should be the project
code for a specific-language Wikipedia e.g. "zhwiki" for the Chinese Wikipedia, but it can be any project, including
non-Wikipedia ones. If the project is the English Wikipedia and the property {wikipedia_article} is present in the data
module it will be used first. In all other cases, a sitelink will be generated from {:getWikidataItem} (if set). The
resulting value (or lack of value) is cached so that subsequent calls are fast. If no value could be determined, and
`noCategoryFallback` is {false}, `##Language:getCategoryName` is used as fallback; otherwise, {nil} is returned. Note
that if `noCategoryFallback` is {nil} or omitted, it defaults to {false} if the project is the English Wikipedia,
otherwise to {true}. In other words, under normal circumstances, if the English Wikipedia article couldn't be retrieved,
the return value will fall back to a link to the language's category, but this won't normally happen for any other
project.
]==]
function Language:getWikipediaArticle(noCategoryFallback, project)
Language.getWikipediaArticle = require(language_like_module).getWikipediaArticle
return self:getWikipediaArticle(noCategoryFallback, project)
end
function Language:makeWikipediaLink()
return make_link(self, "w:" .. self:getWikipediaArticle(), self:getCanonicalName())
end
--[==[
Return the name of the Wikimedia Commons category page for the language.
]==]
function Language:getCommonsCategory()
Language.getCommonsCategory = require(language_like_module).getCommonsCategory
return self:getCommonsCategory()
end
--[==[
Return the Wikidata item ID for the language or {nil}. This corresponds to the the second field in the data modules.
]==]
function Language:getWikidataItem()
Language.getWikidataItem = require(language_like_module).getWikidataItem
return self:getWikidataItem()
end
--[==[
Return a list of `Script` objects for all scripts that the language is written in. See [[Module:scripts]].
]==]
function Language:getScripts()
local scripts = self._scriptObjects
if scripts == nil then
local codes = self:getScriptCodes()
if codes[1] == "All" then
scripts = load_data(scripts_data_module)
else
scripts = {}
for i = 1, #codes do
scripts[i] = get_script(codes[i])
end
end
self._scriptObjects = scripts
end
return scripts
end
--[==[
Return the list of script codes in the language's data file.
]==]
function Language:getScriptCodes()
local scripts = self._scriptCodes
if scripts == nil then
scripts = self._data[4]
if scripts then
local codes, n = {}, 0
for code in gmatch(scripts, "[^,]+") do
n = n + 1
-- Special handling of "Hants", which represents "Hani", "Hant" and "Hans" collectively.
if code == "Hants" then
codes[n] = "Hani"
codes[n + 1] = "Hant"
codes[n + 2] = "Hans"
n = n + 2
else
codes[n] = code
end
end
scripts = codes
else
scripts = {"None"}
end
self._scriptCodes = scripts
end
return scripts
end
--[==[
Given some text, iterate through the scripts of a given language trying to find the script that best matches the text.
Return a {Script} object representing the script. If no match is found at all, it returns the {None} script object.
]==]
function Language:findBestScript(text, forceDetect)
if not text or text == "" or text == "-" then
return get_script("None")
end
-- Differs from table returned by getScriptCodes, as Hants is not normalized into its constituents.
local codes = self._bestScriptCodes
if codes == nil then
codes = self._data[4]
codes = codes and split(codes, ",", true, true) or {"None"}
self._bestScriptCodes = codes
end
local first_sc = codes[1]
if first_sc == "All" then
return find_best_script_without_lang(text)
end
local codes_len = #codes
if not (forceDetect or first_sc == "Hants" or codes_len > 1) then
first_sc = get_script(first_sc)
local charset = first_sc.characters
return charset and umatch(text, "[" .. charset .. "]") and first_sc or get_script("None")
end
-- Remove all formatting characters.
text = get_plaintext(text)
-- Remove all spaces and any ASCII punctuation. Some non-ASCII punctuation is script-specific, so can't be removed.
text = ugsub(text, "[%s!\"#%%&'()*,%-./:;?@[\\%]_{}]+", "")
if #text == 0 then
return get_script("None")
end
-- Try to match every script against the text,
-- and return the one with the most matching characters.
local bestcount, bestscript, length = 0
for i = 1, codes_len do
local sc = codes[i]
-- Special case for "Hants", which is a special code that represents whichever of "Hant" or "Hans" best matches,
-- or "Hani" if they match equally. This avoids having to list all three. In addition, "Hants" will be treated
-- as the best match if there is at least one matching character, under the assumption that a Han script is
-- desirable in terms that contain a mix of Han and other scripts (not counting those which use Jpan or Kore).
if sc == "Hants" then
local Hani = get_script("Hani")
if not Hant_chars then
Hant_chars = load_data("Module:zh/data/ts")
Hans_chars = load_data("Module:zh/data/st")
end
local t, s, found = 0, 0
-- This is faster than using mw.ustring.gmatch directly.
for ch in gmatch((ugsub(text, "[" .. Hani.characters .. "]", "\255%0")), "\255(.[\128-\191]*)") do
found = true
if Hant_chars[ch] then
t = t + 1
if Hans_chars[ch] then
s = s + 1
end
elseif Hans_chars[ch] then
s = s + 1
else
t, s = t + 1, s + 1
end
end
if found then
if t == s then
return Hani
end
return get_script(t > s and "Hant" or "Hans")
end
else
sc = get_script(sc)
if not length then
length = ulen(text)
end
-- Count characters by removing everything in the script's charset and comparing to the original length.
local charset = sc.characters
local count = charset and length - ulen((ugsub(text, "[" .. charset .. "]+", ""))) or 0
if count >= length then
return sc
elseif count > bestcount then
bestcount = count
bestscript = sc
end
end
end
-- Return best matching script, or otherwise None.
return bestscript or get_script("None")
end
--[==[
Return a `Family` object for the language family that the language belongs to. See [[Module:families]].
]==]
function Language:getFamily()
local family = self._familyObject
if family == nil then
family = self:getFamilyCode()
-- If the value is nil, it's cached as false.
family = family and get_family(family) or false
self._familyObject = family
end
return family or nil
end
--[==[
Return the family code in the language's data file.
]==]
function Language:getFamilyCode()
local family = self._familyCode
if family == nil then
-- If the value is nil, it's cached as false.
family = self._data[3] or false
self._familyCode = family
end
return family or nil
end
function Language:getFamilyName()
local family = self._familyName
if family == nil then
family = self:getFamily()
-- If the value is nil, it's cached as false.
family = family and family:getCanonicalName() or false
self._familyName = family
end
return family or nil
end
do
local function check_family(self, family)
if type(family) == "table" then
family = family:getCode()
end
if self:getFamilyCode() == family then
return true
end
local self_family = self:getFamily()
if self_family:inFamily(family) then
return true
-- If the family isn't a real family (e.g. creoles) check any ancestors.
elseif self_family:inFamily("qfa-not") then
local ancestors = self:getAncestors()
for _, ancestor in ipairs(ancestors) do
if ancestor:inFamily(family) then
return true
end
end
end
end
--[==[
Check whether the language belongs to `family` (which can be a family code or object). A list of objects can be given in
place of `family`; in that case, return true if the language belongs to any of the specified families. Note that some
languages (in particular, certain creoles) can have multiple immediate ancestors potentially belonging to different
families; in that case, return true if the language belongs to any of the specified families.
]==]
function Language:inFamily(...)
if self:getFamilyCode() == nil then
return false
end
return check_inputs(self, check_family, false, ...)
end
end
function Language:getParent()
local parent = self._parentObject
if parent == nil then
parent = self:getParentCode()
-- If the value is nil, it's cached as false.
parent = parent and get_by_code(parent, nil, true, true) or false
self._parentObject = parent
end
return parent or nil
end
function Language:getParentCode()
local parent = self._parentCode
if parent == nil then
-- If the value is nil, it's cached as false.
parent = self._data.parent or false
self._parentCode = parent
end
return parent or nil
end
function Language:getParentName()
local parent = self._parentName
if parent == nil then
parent = self:getParent()
-- If the value is nil, it's cached as false.
parent = parent and parent:getCanonicalName() or false
self._parentName = parent
end
return parent or nil
end
function Language:getParentChain()
local chain = self._parentChain
if chain == nil then
chain = {}
local parent, n = self:getParent(), 0
while parent do
n = n + 1
chain[n] = parent
parent = parent:getParent()
end
self._parentChain = chain
end
return chain
end
--[==[
Return a list of the pseudo-families (if any) that a language belongs to. The returned value is a list of Family
objects. Pseudo-families are groupings of languages that are not clades but share some geographic, ethnic or other
characteristic (e.g. [[:Category:Papuan languages]], [[:Category:Jewish languages]]).
]==]
function Language:getPseudoFamilies()
self:loadInExtraData()
return require(language_like_module).getPseudoFamilies(self)
end
do
local function check_lang(self, lang)
for _, parent in ipairs(self:getParentChain()) do
if (type(lang) == "string" and lang or lang:getCode()) == parent:getCode() then
return true
end
end
end
function Language:hasParent(...)
return check_inputs(self, check_lang, false, ...)
end
end
--[==[
If the language is etymology-only, iterate through parents until a full language or family is found, and the
corresponding object is returned. If the language is a full language, return that language.
]==]
function Language:getFull()
local full = self._fullObject
if full == nil then
full = self:getFullCode()
full = full == self._code and self or get_by_code(full)
self._fullObject = full
end
return full
end
--[==[
If the language is an etymology-only language, iterate through parents until a full language or family is found, and
the corresponding code is returned. If the language is a full language, return that language's code.
]==]
function Language:getFullCode()
return self._fullCode or self._code
end
--[==[
If the language is an etymology-only language, iterate through parents until a full language or family is found, and the
corresponding canonical name is returned. If the language is a full language, return that language's canonical name.
]==]
function Language:getFullName()
local full = self._fullName
if full == nil then
full = self:getFull():getCanonicalName()
self._fullName = full
end
return full
end
--[==[
Return a list of {Language} objects for all languages that this language is directly descended from. Generally this is
only a single language, but creoles, pidgins and mixed languages can have multiple ancestors.
]==]
function Language:getAncestors()
local ancestors = self._ancestorObjects
if ancestors == nil then
ancestors = {}
local ancestor_codes = self:getAncestorCodes()
if #ancestor_codes > 0 then
for _, ancestor in ipairs(ancestor_codes) do
insert(ancestors, get_by_code(ancestor, nil, true))
end
else
local fam = self:getFamily()
local protoLang = fam and fam:getProtoLanguage() or nil
-- For the cases where the current language is the proto-language
-- of its family, or an etymology-only language that is ancestral to that
-- proto-language, we need to step up a level higher right from the
-- start.
if protoLang and (
protoLang:getCode() == self._code or
(self:hasType("etymology-only") and protoLang:hasAncestor(self))
) then
fam = fam:getFamily()
protoLang = fam and fam:getProtoLanguage() or nil
end
while not protoLang and not (not fam or fam:getCode() == "qfa-not") do
fam = fam:getFamily()
protoLang = fam and fam:getProtoLanguage() or nil
end
insert(ancestors, protoLang)
end
self._ancestorObjects = ancestors
end
return ancestors
end
do
-- Avoid a language being its own ancestor via class inheritance. We only need to check for this if the language has
-- inherited an ancestor table from its parent, because we never want to drop ancestors that have been explicitly
-- set in the data. Recursively iterate over ancestors until we either find self or run out. If self is found,
-- return true.
local function check_ancestor(self, lang)
local codes = lang:getAncestorCodes()
if not codes then
return nil
end
for i = 1, #codes do
local code = codes[i]
if code == self._code then
return true
end
local anc = get_by_code(code, nil, true)
if check_ancestor(self, anc) then
return true
end
end
end
--[==[
Return a list of `Language` codes for all languages that this language is directly descended from. Generally this is
only a single language, but creoles, pidgins and mixed languages can have multiple ancestors.
]==]
function Language:getAncestorCodes()
if self._ancestorCodes then
return self._ancestorCodes
end
local data = self._data
local codes = data.ancestors
if codes == nil then
codes = {}
self._ancestorCodes = codes
return codes
end
codes = split(codes, ",", true, true)
self._ancestorCodes = codes
-- If there are no codes or the ancestors weren't inherited data, there's nothing left to check.
if #codes == 0 or self:getData(false, "raw").ancestors ~= nil then
return codes
end
local i = 1
while i <= #codes do
if check_ancestor(self, self) then
remove(codes, i)
else
i = i + 1
end
end
return codes
end
end
--[==[
Given a list of language objects or codes, return true if at least one of them is an ancestor. This includes any
etymology-only children of that ancestor. If the language's ancestor(s) are etymology-only languages, it will also
return true for those language parent(s) (e.g. if Vulgar Latin is the ancestor, it will also return true for its parent,
Latin). However, a parent is excluded from this if the ancestor is also ancestral to that parent (e.g. if Classical
Persian is the ancestor, Persian would return {false}, because Classical Persian is also ancestral to Persian).
]==]
function Language:hasAncestor(...)
local function iterateOverAncestorTree(node, func, parent_check)
local ancestors = node:getAncestors()
local ancestorsParents = {}
for _, ancestor in ipairs(ancestors) do
-- When checking the parents of the other language, and the ancestor is also a parent, skip to the next
-- ancestor, so that we exclude any etymology-only children of that parent that are not directly related
-- (see below).
local ret = (parent_check or not node:hasParent(ancestor)) and
func(ancestor) or iterateOverAncestorTree(ancestor, func, parent_check)
if ret then
return ret
end
end
-- Check the parents of any ancestors. We don't do this if checking the parents of the other language, so that
-- we exclude any etymology-only children of those parents that are not directly related (e.g. if the ancestor
-- is Vulgar Latin and we are checking New Latin, we want it to return false because they are on different
-- ancestral branches. As such, if we're already checking the parent of New Latin (Latin) we don't want to
-- compare it to the parent of the ancestor (Latin), as this would be a false positive; it should be one or the
-- other).
if not parent_check then
return nil
end
for _, ancestor in ipairs(ancestors) do
local ancestorParents = ancestor:getParentChain()
for _, ancestorParent in ipairs(ancestorParents) do
if ancestorParent:getCode() == self._code or ancestorParent:hasAncestor(ancestor) then
break
else
insert(ancestorsParents, ancestorParent)
end
end
end
for _, ancestorParent in ipairs(ancestorsParents) do
local ret = func(ancestorParent)
if ret then
return ret
end
end
end
local function do_iteration(otherlang, parent_check)
-- otherlang can't be self
if (type(otherlang) == "string" and otherlang or otherlang:getCode()) == self._code then
return false
end
repeat
if iterateOverAncestorTree(
self,
function(ancestor)
return ancestor:getCode() == (type(otherlang) == "string" and otherlang or otherlang:getCode())
end,
parent_check
) then
return true
elseif type(otherlang) == "string" then
otherlang = get_by_code(otherlang, nil, true)
end
otherlang = otherlang:getParent()
parent_check = false
until not otherlang
end
local parent_check = true
for _, otherlang in ipairs{...} do
local ret = do_iteration(otherlang, parent_check)
if ret then
return true
end
end
return false
end
do
local function construct_node(lang, memo)
local branch, ancestors = {lang = lang:getCode()}
memo[lang:getCode()] = branch
for _, ancestor in ipairs(lang:getAncestors()) do
if ancestors == nil then
ancestors = {}
end
insert(ancestors, memo[ancestor:getCode()] or construct_node(ancestor, memo))
end
branch.ancestors = ancestors
return branch
end
function Language:getAncestorChain()
local chain = self._ancestorChain
if chain == nil then
chain = construct_node(self, {})
self._ancestorChain = chain
end
return chain
end
end
function Language:getAncestorChainOld()
local chain = self._ancestorChain
if chain == nil then
chain = {}
local step = self
while true do
local ancestors = step:getAncestors()
step = #ancestors == 1 and ancestors[1] or nil
if not step then
break
end
insert(chain, step)
end
self._ancestorChain = chain
end
return chain
end
local function fetch_descendants(self, fmt)
local descendants, family = {}, self:getFamily()
-- Iterate over all three datasets.
for _, data in ipairs{
require("Module:languages/code to canonical name"),
require("Module:etymology languages/code to canonical name"),
require("Module:families/code to canonical name"),
} do
for code in pairs(data) do
local lang = get_by_code(code, nil, true, true)
if not lang then
error(("Internal error: code '%s' can't be fetched"):format(code))
end
-- Test for a descendant. Earlier tests weed out most candidates, while the more intensive tests are only used sparingly.
if (
code ~= self._code and -- Not self.
lang:inFamily(family) and -- In the same family.
(
family:getProtoLanguageCode() == self._code or -- Self is the protolanguage.
self:hasDescendant(lang) or -- Full hasDescendant check.
(lang:getFullCode() == self._code and not self:hasAncestor(lang)) -- Etymology-only child which isn't an ancestor.
)
) then
if fmt == "object" then
insert(descendants, lang)
elseif fmt == "code" then
insert(descendants, code)
elseif fmt == "name" then
insert(descendants, lang:getCanonicalName())
end
end
end
end
return descendants
end
function Language:getDescendants()
local descendants = self._descendantObjects
if descendants == nil then
descendants = fetch_descendants(self, "object")
self._descendantObjects = descendants
end
return descendants
end
function Language:getDescendantCodes()
local descendants = self._descendantCodes
if descendants == nil then
descendants = fetch_descendants(self, "code")
self._descendantCodes = descendants
end
return descendants
end
function Language:getDescendantNames()
local descendants = self._descendantNames
if descendants == nil then
descendants = fetch_descendants(self, "name")
self._descendantNames = descendants
end
return descendants
end
do
local function check_lang(self, lang)
if type(lang) == "string" then
lang = get_by_code(lang, nil, true)
end
if lang:hasAncestor(self) then
return true
end
end
function Language:hasDescendant(...)
return check_inputs(self, check_lang, false, ...)
end
end
local function fetch_children(self, fmt)
local m_etym_data = require(etymology_languages_data_module)
local self_code, children = self._code, {}
for code, lang in pairs(m_etym_data) do
local _lang = lang
repeat
local parent = _lang.parent
if parent == self_code then
if fmt == "object" then
insert(children, get_by_code(code, nil, true))
elseif fmt == "code" then
insert(children, code)
elseif fmt == "name" then
insert(children, lang[1])
end
break
end
_lang = m_etym_data[parent]
until not _lang
end
return children
end
function Language:getChildren()
local children = self._childObjects
if children == nil then
children = fetch_children(self, "object")
self._childObjects = children
end
return children
end
function Language:getChildrenCodes()
local children = self._childCodes
if children == nil then
children = fetch_children(self, "code")
self._childCodes = children
end
return children
end
function Language:getChildrenNames()
local children = self._childNames
if children == nil then
children = fetch_children(self, "name")
self._childNames = children
end
return children
end
function Language:hasChild(...)
local lang = ...
if not lang then
return false
elseif type(lang) == "string" then
lang = get_by_code(lang, nil, true)
end
if lang:hasParent(self) then
return true
end
return self:hasChild(select(2, ...))
end
--[==[
Return the name of the main category of that language. Example: {French language"} for French, whose category is at
[[:Category:French language]]. Unless optional argument `nocap` is given, the language name at the beginning of the
returned value will be capitalized. This capitalization is correct for category names, but not if the language name is
lowercase and the returned value of this function is used in the middle of a sentence.
]==]
function Language:getCategoryName(nocap)
local name = self._categoryName
if name == nil then
name = self:getCanonicalName()
-- If a substrate, omit any leading article.
if self:getFamilyCode() == "qfa-sub" then
name = name:gsub("^the ", ""):gsub("^a ", "")
end
-- Only add " language" if a full language.
if self:hasType("full") then
-- Unless the canonical name already ends with "language", "lect" or their derivatives, add " language".
if not (match(name, "[Ll]anguage$") or match(name, "[Ll]ect$")) then
name = name .. " language"
end
end
self._categoryName = name
end
if nocap then
return name
end
return mw.getContentLanguage():ucfirst(name)
end
--[==[
Create a link to the category; the link text is the canonical name.
]==]
function Language:makeCategoryLink()
return make_link(self, ":Category:" .. self:getCategoryName(), self:getDisplayForm())
end
function Language:getStandardCharacters(sc)
local standard_chars = self._data.standard_chars
if type(standard_chars) ~= "table" then
return standard_chars
elseif sc and type(sc) ~= "string" then
check_object("script", nil, sc)
sc = sc:getCode()
end
if (not sc) or sc == "None" then
local scripts = {}
for _, script in pairs(standard_chars) do
insert(scripts, script)
end
return concat(scripts)
end
if standard_chars[sc] then
return standard_chars[sc] .. (standard_chars[1] or "")
end
end
--[==[
Strip diacritics from display text `text` (in a language-specific fashion), which is in the script `sc`. If `sc` is
omitted or {nil}, the script is autodetected. This also strips certain punctuation characters from the end and (in the
case of Spanish upside-down question mark and exclamation points) from the beginning; strips any whitespace at the
end of the text or between the text and final stripped punctuation characters; and applies some language-specific
Unicode normalizations to replace discouraged characters with their prescribed alternatives. Return the stripped text.
]==]
function Language:stripDiacritics(text, sc)
if (not text) or text == "" then
return text
end
sc = checkScript(text, self, sc)
text = normalize(text, sc)
-- FIXME, rename makeEntryName to stripDiacritics and get rid of second and third return values
-- everywhere
local _
text, _, _ = iterateSectionSubstitutions(self, text, sc, nil, nil,
self._data.strip_diacritics or self._data.entry_name, "strip_diacritics", "stripDiacritics")
text = umatch(text, "^[¿¡]?(.-[^%s%p].-)%s*[؟?!;՛՜ ՞ ՟?!︖︕।॥။၊་།]?$") or text
return text
end
--[==[
Convert a ''logical'' pagename (the pagename as it appears to the user, after diacritics and punctuation have been
stripped) to a ''physical'' pagename (the pagename as it appears in the MediaWiki database). Reasons for a difference
between the two are (a) unsupported titles such as `[ ]` (with square brackets in them), `#` (pound/hash sign) and
`¯\_(ツ)_/¯` (with underscores), as well as overly long titles of various sorts; (b) "mammoth" pages that are split into
parts (e.g. `a`, which is split into physical pagenames `a/languages A to L` and `a/languages M to Z`). For almost all
purposes, you should work with logical and not physical pagenames. But there are certain use cases that require physical
pagenames, such as checking the existence of a page or retrieving a page's contents.
`pagename` is the logical pagename to be converted. `is_reconstructed_or_appendix` indicates whether the page is in the
`Reconstruction` or `Appendix` namespaces. If it is omitted or has the value {nil}, the pagename is checked for an
initial asterisk, and if found, the page is assumed to be a `Reconstruction` page. Setting a value of `false` or `true`
to `is_reconstructed_or_appendix` disables this check and allows for mainspace pagenames that begin with an asterisk.
]==]
function Language:logicalToPhysical(pagename, is_reconstructed_or_appendix)
-- FIXME: This probably shouldn't happen but it happens when makeEntryName() receives nil.
if pagename == nil then
track("nil-passed-to-logicalToPhysical")
return nil
end
local initial_asterisk
if is_reconstructed_or_appendix == nil then
local pagename_minus_initial_asterisk
initial_asterisk, pagename_minus_initial_asterisk = pagename:match("^(%*)(.*)$")
if pagename_minus_initial_asterisk then
is_reconstructed_or_appendix = true
pagename = pagename_minus_initial_asterisk
elseif self:hasType("appendix-constructed") then
is_reconstructed_or_appendix = true
end
end
if not is_reconstructed_or_appendix then
-- Check if the pagename is a listed unsupported title.
local unsupportedTitles = load_data(links_data_module).unsupported_titles
if unsupportedTitles[pagename] then
return "Unsupported titles/" .. unsupportedTitles[pagename]
end
end
-- Set `unsupported` as true if certain conditions are met.
local unsupported
-- Check if there's an unsupported character. \239\191\189 is the replacement character U+FFFD, which can't be typed
-- directly here due to an abuse filter. Unix-style dot-slash notation is also unsupported, as it is used for
-- relative paths in links, as are 3 or more consecutive tildes. Note: match is faster with magic
-- characters/charsets; find is faster with plaintext.
if (
match(pagename, "[#<>%[%]_{|}]") or
find(pagename, "\239\191\189") or
match(pagename, "%f[^%z/]%.%.?%f[%z/]") or
find(pagename, "~~~")
) then
unsupported = true
-- If it looks like an interwiki link.
elseif find(pagename, ":") then
local prefix = gsub(pagename, "^:*(.-):.*", ulower)
if (
load_data("Module:data/namespaces")[prefix] or
load_data("Module:data/interwikis")[prefix]
) then
unsupported = true
end
end
-- Escape unsupported characters so they can be used in titles. ` is used as a delimiter for this, so a raw use of
-- it in an unsupported title is also escaped here to prevent interference; this is only done with unsupported
-- titles, though, so inclusion won't in itself mean a title is treated as unsupported (which is why it's excluded
-- from the earlier test).
if unsupported then
-- FIXME: This conversion needs to be different for reconstructed pages with unsupported characters. There
-- aren't any currently, but if there ever are, we need to fix this e.g. to put them in something like
-- Reconstruction:Proto-Indo-European/Unsupported titles/`lowbar``num`.
local unsupported_characters = load_data(links_data_module).unsupported_characters
pagename = pagename:gsub("[#<>%[%]_`{|}\239]\191?\189?", unsupported_characters)
:gsub("%f[^%z/]%.%.?%f[%z/]", function(m)
return (gsub(m, "%.", "`period`"))
end)
:gsub("~~~+", function(m)
return (gsub(m, "~", "`tilde`"))
end)
pagename = "Unsupported titles/" .. pagename
elseif not is_reconstructed_or_appendix then
-- Check if this is a mammoth page. If so, which subpage should we link to?
local m_links_data = load_data(links_data_module)
local mammoth_page_type = m_links_data.mammoth_pages[pagename]
if mammoth_page_type then
local canonical_name = self:getFullName()
if canonical_name ~= "Translingual" and canonical_name ~= "English" then
local this_subpage
local L2_sort_key = get_L2_sort_key(canonical_name)
for _, subpage_spec in ipairs(m_links_data.mammoth_page_subpage_types[mammoth_page_type]) do
-- unpack() fails utterly on data loaded using mw.loadData() even if offsets are given
local subpage, pattern = subpage_spec[1], subpage_spec[2]
if pattern == true or L2_sort_key:match(pattern) then
this_subpage = subpage
break
end
end
if not this_subpage then
error(("Internal error: Bad data in mammoth_page_subpage_pages in [[Module:links/data]] for mammoth page %s, type %s; last entry didn't have 'true' in it"):format(
pagename, mammoth_page_type))
end
pagename = pagename .. "/" .. this_subpage
end
end
end
return (initial_asterisk or "") .. pagename
end
--[==[
Strip the diacritics from a display pagename and convert the resulting logical pagename into a physical pagename.
This allows you, for example, to retrieve the contents of the page or check its existence. WARNING: This is deprecated
and will be going away. It is a simple composition of `##Language:stripDiacritics` and `##Language:logicalToPhysical`;
most callers only want the former, and if you need both, call them both yourself.
`text` and `sc` are as in `##Language:stripDiacritics`, and `is_reconstructed_or_appendix` is as in
`##Language:logicalToPhysical`.
]==]
function Language:makeEntryName(text, sc, is_reconstructed_or_appendix)
track("makeEntryName called")
return self:logicalToPhysical(self:stripDiacritics(text, sc), is_reconstructed_or_appendix)
end
--[==[
Generate term alternants (e.g. simplified versions of traditional Chinese terms) using a language-specific method, and
return them as a table. If the language provides no method for generating alternants, return a table containing only the
input term.
]==]
function Language:generateAlternants(text, sc)
local generate_alternants = self._data.generate_alternants
if generate_alternants == nil then
return {text}
end
sc = checkScript(text, self, sc)
return require("Module:" .. generate_alternants).generateAlternants(text, self, sc)
end
--[==[
Create a sort key for the given stripped text, following the rules appropriate for the language. This removes
diacritical marks from the stripped text if they are not considered significant for sorting, and may perform some other
changes. Any initial hyphen is also removed, and anything in parentheses is removed as well. The `sort_key` setting for
each language in the data modules defines the replacements made by this function, or it gives the name of the module
that takes the stripped text and returns a sortkey.
]==]
function Language:makeSortKey(text, sc)
if (not text) or text == "" then
return text
end
if match(text, "<[^<>]+>") then
track("track HTML tag")
end
-- Remove directionality/control characters, bold, italics, soft hyphens, strip markers and HTML tags.
-- FIXME: Partly duplicated with remove_formatting() in [[Module:links]].
text = ugsub(text, "[\194\173\216\156\226\128\142\226\128\143\226\128\170-\226\128\174\226\129\166-\226\129\175]", "")
text = text:gsub("('*)'''(.-'*)'''", "%1%2"):gsub("('*)''(.-'*)''", "%1%2")
text = gsub(unstrip(text), "<[^<>]+>", "")
text = decode_uri(text, "PATH")
text = checkNoEntities(text)
-- Remove initial hyphens and * unless the term only consists of spacing + punctuation characters.
text = ugsub(text, "^([-]*)[-־ـ᠊*]+([-]*)(.*[^%s%p].*)", "%1%2%3")
sc = checkScript(text, self, sc)
text = normalize(text, sc)
text = removeCarets(text, sc)
-- For languages with dotted dotless i, ensure that "İ" is sorted as "i", and "I" is sorted as "ı".
if self:hasDottedDotlessI() then
text = gsub(text, "I\204\135", "i") -- decomposed "İ"
:gsub("I", "ı")
text = sc:toFixedNFD(text)
end
-- Convert to lowercase, make the sortkey, then convert to uppercase. Where the language has dotted dotless i, it is
-- usually not necessary to convert "i" to "İ" and "ı" to "I" first, because "I" will always be interpreted as
-- conventional "I" (not dotless "İ") by any sorting algorithms, which will have been taken into account by the
-- sortkey substitutions themselves. However, if no sortkey substitutions have been specified, then conversion is
-- necessary so as to prevent "i" and "ı" both being sorted as "I".
--
-- An exception is made for scripts that (sometimes) sort by scraping page content, as that means they are sensitive
-- to changes in capitalization (as it changes the target page).
if not sc:sortByScraping() then
text = ulower(text)
end
local actual_substitution_data, _
-- Don't trim whitespace here because it's significant at the beginning of a sort key or sort base.
text, _, actual_substitution_data = iterateSectionSubstitutions(self, text, sc, nil, nil,
self._data.sort_key, "sort_key", "makeSortKey", "notrim")
if not sc:sortByScraping() then
if self:hasDottedDotlessI() and not actual_substitution_data then
text = text:gsub("ı", "I"):gsub("i", "İ")
text = sc:toFixedNFC(text)
end
text = uupper(text)
end
-- Remove parentheses, as long as they are either preceded or followed by something.
text = gsub(text, "(.)[()]+", "%1"):gsub("[()]+(.)", "%1")
text = escape_risky_characters(text)
return text
end
--[==[
Create the form used as as a basis for display text and transliteration. FIXME: Rename to correctInputText().
]==]
local function processDisplayText(text, self, sc, keepCarets, keepPrefixes)
local subbedChars = {}
text, subbedChars = doTempSubstitutions(text, subbedChars, keepCarets)
text = decode_uri(text, "PATH")
text = checkNoEntities(text)
sc = checkScript(text, self, sc)
text = normalize(text, sc)
text, subbedChars = iterateSectionSubstitutions(self, text, sc, subbedChars, keepCarets, self._data.display_text,
"display_text", "makeDisplayText")
text = removeCarets(text, sc)
-- Remove any interwiki link prefixes (unless they have been escaped or this has been disabled).
if find(text, ":") and not keepPrefixes then
local rep
repeat
text, rep = gsub(text, "\\\\(\\*:)", "\3%1")
until rep == 0
text = gsub(text, "\\:", "\4")
while true do
local prefix = gsub(text, "^(.-):.+", function(m1)
return (gsub(m1, "\244[\128-\191]*", ""))
end)
-- Check if the prefix is an interwiki, though ignore capitalised Wiktionary:, which is a namespace.
if not prefix or prefix == text or prefix == "Wiktionary"
or not (load_data("Module:data/interwikis")[ulower(prefix)] or prefix == "") then
break
end
text = gsub(text, "^(.-):(.*)", function(m1, m2)
local ret = {}
for subbedChar in gmatch(m1, "\244[\128-\191]*") do
insert(ret, subbedChar)
end
return concat(ret) .. m2
end)
end
text = gsub(text, "\3", "\\"):gsub("\4", ":")
end
return text, subbedChars
end
--[==[
Make the display text (i.e. what is displayed on the page).
]==]
function Language:makeDisplayText(text, sc, keepPrefixes)
if not text or text == "" then
return text
end
local subbedChars
text, subbedChars = processDisplayText(text, self, sc, nil, keepPrefixes)
text = escape_risky_characters(text)
return undoTempSubstitutions(text, subbedChars)
end
--[==[
Transliterate the text from the given script into Latin script (see [[Wiktionary:Transliteration and romanization]]).
The language must have the `translit` property for this to work; if it is not present, {nil} is returned.
The `sc` parameter is handled by the transliteration module, and how it is handled is specific to that module. Some
transliteration modules may tolerate {nil} as the script, others require it to be one of the possible scripts that the
module can transliterate, and will throw an error if it's not one of them. For this reason, the `sc` parameter should
always be provided when writing non-language-specific code.
The `module_override` parameter is used to override the default module that is used to provide the transliteration.
This is useful in cases where you need to demonstrate a particular module in use, but there is no default module yet,
or you want to demonstrate an alternative version of a transliteration module before making it official. It should not
be used in real modules or templates, only for testing. All uses of this parameter are tracked by
[[Wiktionary:Tracking/languages/module_override]].
'''Known bugs''':
* This function assumes {tr(s1) .. tr(s2) == tr(s1 .. s2)}. When this assertion fails, wikitext markups like
<nowiki>'''</nowiki> can cause wrong transliterations.
* HTML entities like `&apos;`, often used to escape wikitext markups, do not work.
]==]
function Language:transliterate(text, sc, module_override)
-- If there is no text, or the language doesn't have transliteration data and there's no override, return nil.
if not text or text == "" or text == "-" then
return text
end
-- If the script is not transliteratable (and no override is given), return nil.
sc = checkScript(text, self, sc)
if not (sc:isTransliterated() or module_override) then
-- temporary tracking to see if/when this gets triggered
track("non-transliterable")
track("non-transliterable/" .. self._code)
track("non-transliterable/" .. sc:getCode())
track("non-transliterable/" .. sc:getCode() .. "/" .. self._code)
return nil
end
-- Remove any strip markers.
text = unstrip(text)
-- Do not process the formatting into PUA characters for certain languages.
local processed = load_data(languages_data_module).substitution[self._code] ~= "none"
-- Get the display text with the keepCarets flag set.
local subbedChars
if processed then
text, subbedChars = processDisplayText(text, self, sc, true)
end
-- Transliterate (using the module override if applicable).
text, subbedChars = iterateSectionSubstitutions(self, text, sc, subbedChars, true, module_override or
self._data.translit, "translit", "tr")
if not text then
return nil
end
-- Incomplete transliterations return nil.
local charset = sc.characters
if charset and umatch(text, "[" .. charset .. "]") then
-- Remove any characters in Latin, which includes Latin characters also included in other scripts (as these are
-- false positives), as well as any PUA substitutions. Anything remaining should only be script code "None"
-- (e.g. numerals).
local check_text = ugsub(text, "[" .. get_script("Latn").characters .. "-]+", "")
-- Set none_is_last_resort_only flag, so that any non-None chars will cause a script other than "None" to be
-- returned.
if find_best_script_without_lang(check_text, true):getCode() ~= "None" then
return nil
end
end
if processed then
text = escape_risky_characters(text)
text = undoTempSubstitutions(text, subbedChars)
end
-- If the script does not use capitalization, then capitalize any letters of the transliteration which are
-- immediately preceded by a caret (and remove the caret).
if text and not sc:hasCapitalization() and text:find("^", 1, true) then
text = processCarets(text, "%^([\128-\191\244]*%*?)([^\128-\191\244][\128-\191]*)", function(m1, m2)
return m1 .. uupper(m2)
end)
end
-- Track module overrides.
if module_override ~= nil then
track("module_override")
end
return text
end
do
local function handle_language_spec(self, spec, sc)
local ret = self["_" .. spec]
if ret == nil then
ret = self._data[spec]
if type(ret) == "string" then
ret = list_to_set(split(ret, ",", true, true))
end
self["_" .. spec] = ret
end
if type(ret) == "table" then
ret = ret[sc:getCode()]
end
return not not ret
end
function Language:overrideManualTranslit(sc)
return handle_language_spec(self, "override_translit", sc)
end
function Language:link_tr(sc)
return handle_language_spec(self, "link_tr", sc)
end
end
--[==[
Return {true} if the language has a transliteration module, or {false} if it doesn't.
]==]
function Language:hasTranslit()
return not not self._data.translit
end
--[==[
Return {true} if the language uses the letters I/ı and İ/i, or {false} if it doesn't.]==]
function Language:hasDottedDotlessI()
return not not self._data.dotted_dotless_i
end
function Language:toJSON(opts)
local strip_diacritics, strip_diacritics_patterns, strip_diacritics_remove_diacritics = self._data.strip_diacritics
if strip_diacritics then
if strip_diacritics.from then
strip_diacritics_patterns = {}
for i, from in ipairs(strip_diacritics.from) do
insert(strip_diacritics_patterns, {from = from, to = strip_diacritics.to[i] or ""})
end
end
strip_diacritics_remove_diacritics = strip_diacritics.remove_diacritics
end
-- mainCode should only end up non-nil if dontCanonicalizeAliases is passed to make_object().
-- props should either contain zero-argument functions to compute the value, or the value itself.
local props = {
ancestors = function() return self:getAncestorCodes() end,
canonicalName = function() return self:getCanonicalName() end,
categoryName = function() return self:getCategoryName("nocap") end,
code = self._code,
mainCode = self._mainCode,
parent = function() return self:getParentCode() end,
full = function() return self:getFullCode() end,
stripDiacriticsPatterns = strip_diacritics_patterns,
stripDiacriticsRemoveDiacritics = strip_diacritics_remove_diacritics,
family = function() return self:getFamilyCode() end,
aliases = function() return self:getAliases() end,
varieties = function() return self:getVarieties() end,
otherNames = function() return self:getOtherNames() end,
pseudoFamilies = function() return self:getPseudoFamilies() end,
scripts = function() return self:getScriptCodes() end,
type = function() return keys_to_list(self:getTypes()) end,
wikimediaLanguages = function() return self:getWikimediaLanguageCodes() end,
wikidataItem = function() return self:getWikidataItem() end,
wikipediaArticle = function() return self:getWikipediaArticle(true) end,
}
local ret = {}
for prop, val in pairs(props) do
if not opts.skip_fields or not opts.skip_fields[prop] then
if type(val) == "function" then
ret[prop] = val()
else
ret[prop] = val
end
end
end
-- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`.
return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts)
end
function export.getDataModuleName(code)
local letter = match(code, "^(%l)%l%l?$")
return "Module:" .. (
letter == nil and "languages/data/exceptional" or
#code == 2 and "languages/data/2" or
"languages/data/3/" .. letter
)
end
get_data_module_name = export.getDataModuleName
function export.getExtraDataModuleName(code)
return get_data_module_name(code) .. "/extra"
end
get_extra_data_module_name = export.getExtraDataModuleName
do
local function make_stack(data)
local key_types = {
[2] = "unique",
aliases = "unique",
other_names = "unique",
type = "append",
varieties = "unique",
wikipedia_article = "unique",
wikimedia_codes = "unique"
}
local function __index(self, k)
local stack, key_type = getmetatable(self), key_types[k]
-- Data that isn't inherited from the parent.
if key_type == "unique" then
local v = stack[stack[make_stack]][k]
if v == nil then
local layer = stack[0]
if layer then -- Could be false if there's no extra data.
v = layer[k]
end
end
return v
-- Data that is appended by each generation.
elseif key_type == "append" then
local parts, offset, n = {}, 0, stack[make_stack]
for i = 1, n do
local part = stack[i][k]
if part == nil then
offset = offset + 1
else
parts[i - offset] = part
end
end
return offset ~= n and concat(parts, ",") or nil
end
local n = stack[make_stack]
while true do
local layer = stack[n]
if not layer then -- Could be false if there's no extra data.
return nil
end
local v = layer[k]
if v ~= nil then
return v
end
n = n - 1
end
end
local function __newindex()
error("table is read-only")
end
local function __pairs(self)
-- Iterate down the stack, caching keys to avoid duplicate returns.
local stack, seen = getmetatable(self), {}
local n = stack[make_stack]
local iter, state, k, v = pairs(stack[n])
return function()
repeat
repeat
k = iter(state, k)
if k == nil then
n = n - 1
local layer = stack[n]
if not layer then -- Could be false if there's no extra data.
return nil
end
iter, state, k = pairs(layer)
end
until not (k == nil or seen[k])
-- Get the value via a lookup, as the one returned by the
-- iterator will be the raw value from the current layer,
-- which may not be the one __index will return for that
-- key. Also memoize the key in `seen` (even if the lookup
-- returns nil) so that it doesn't get looked up again.
-- TODO: store values in `self`, avoiding the need to create
-- the `seen` table. The iterator will need to iterate over
-- `self` with `next` first to find these on future loops.
v, seen[k] = self[k], true
until v ~= nil
return k, v
end
end
local __ipairs = require(table_module).indexIpairs
function make_stack(data)
local stack = {
data,
[make_stack] = 1, -- stores the length and acts as a sentinel to confirm a given metatable is a stack.
__index = __index,
__newindex = __newindex,
__pairs = __pairs,
__ipairs = __ipairs,
}
stack.__metatable = stack
return setmetatable({}, stack), stack
end
return make_stack(data)
end
local function get_stack(data)
local stack = getmetatable(data)
return stack and type(stack) == "table" and stack[make_stack] and stack or nil
end
--[==[
<span style="color: var(--wikt-palette-red,#BA0000)">This function is not for use in entries or other content pages.</span>
Return a blob of data about the language. The format of this blob is undocumented, and perhaps unstable; it's intended
for things like the module's own unit-tests, which are "close friends" with the module and will be kept up-to-date as
the format changes. If `extra` is set, any extra data in the relevant `/extra` module will be included. (Note that it
will be included anyway if it has already been loaded into the language object.) If `raw` is set, then the returned data
will not contain any data inherited from parent objects.
-- Do NOT use these methods!
-- All uses should be pre-approved on the talk page!
]==]
function Language:getData(extra, raw)
if extra then
self:loadInExtraData()
end
local data = self._data
-- If raw is not set, just return the data.
if not raw then
return data
end
local stack = get_stack(data)
-- If there isn't a stack or its length is 1, return the data. Extra data (if any) will be included, as it's
-- stored at key 0 and doesn't affect the reported length.
if stack == nil then
return data
end
local n = stack[make_stack]
if n == 1 then
return data
end
extra = stack[0]
-- If there isn't any extra data, return the top layer of the stack.
if extra == nil then
return stack[n]
end
-- If there is, return a new stack which has the top layer at key 1 and the extra data at key 0.
data, stack = make_stack(stack[n])
stack[0] = extra
return data
end
function Language:loadInExtraData()
-- Only full languages have extra data.
if not self:hasType("language", "full") then
return
end
local data = self._data
-- If there's no stack, create one.
local stack = get_stack(self._data)
if stack == nil then
data, stack = make_stack(data)
-- If already loaded, return.
elseif stack[0] ~= nil then
return
end
self._data = data
-- Load extra data from the relevant module and add it to the stack at key 0, so that the __index and __pairs
-- metamethods will pick it up, since they iterate down the stack until they run out of layers.
local code = self._code
local modulename = get_extra_data_module_name(code)
-- No data cached as false.
stack[0] = modulename and load_data(modulename)[code] or false
end
--[==[
Return the name of the module containing the language's data, e.g. [[Module:languages/data/3/k]] for three-letter codes
beginning with `k`.
]==]
function Language:getDataModuleName()
local name = self._dataModuleName
if name == nil then
name = self:hasType("etymology-only") and etymology_languages_data_module or
get_data_module_name(self._mainCode or self._code)
self._dataModuleName = name
end
return name
end
--[==[
Return the name of the module containing the language's extra data, e.g. [[Module:languages/data/3/k/extra]] for
three-letter codes beginning with `k`.
]==]
function Language:getExtraDataModuleName()
local name = self._extraDataModuleName
if name == nil then
name = not self:hasType("etymology-only") and get_extra_data_module_name(self._mainCode or self._code) or false
self._extraDataModuleName = name
end
return name or nil
end
function export.makeObject(code, data, dontCanonicalizeAliases)
local data_type = type(data)
if data_type ~= "table" then
error(("bad argument #2 to 'makeObject' (table expected, got %s)"):format(data_type))
end
-- Convert any aliases.
local input_code = code
code = normalize_code(code)
input_code = dontCanonicalizeAliases and input_code or code
local parent
if data.parent then
parent = get_by_code(data.parent, nil, true, true)
else
parent = Language
end
parent.__index = parent
local lang = {_code = input_code}
-- This can only happen if dontCanonicalizeAliases is passed to make_object().
if code ~= input_code then
lang._mainCode = code
end
local parent_data = parent._data
if parent_data == nil then
-- Full code is the same as the code.
lang._fullCode = parent._code or code
else
-- Copy full code.
lang._fullCode = parent._fullCode
local stack = get_stack(parent_data)
if stack == nil then
parent_data, stack = make_stack(parent_data)
end
-- Insert the input data as the new top layer of the stack.
local n = stack[make_stack] + 1
data, stack[n], stack[make_stack] = parent_data, data, n
end
lang._data = data
return setmetatable(lang, parent)
end
make_object = export.makeObject
end
--[==[
Find the language whose code matches the one provided. If it exists, return a `Language` object representing the
language. Otherwise, return {nil}, unless `paramForError` is given, in which case an error is generated. If
`paramForError` is {true}, a generic error message mentioning the bad code is generated; otherwise `paramForError`
should be a string or number specifying the parameter that the code came from, and this parameter will be mentioned
in the error message along with the bad code. If `allowEtymLang` is specified, etymology-only language codes are allowed
and looked up along with full language codes. If `allowFamily` is specified, language family codes are allowed and
looked up along with normal language codes.
]==]
function export.getByCode(code, paramForError, allowEtymLang, allowFamily)
-- [[ Track uses of paramForError, ultimately so it can be removed, as error-handling should be done by
-- [[Module:parameters]], not here. ]] -- I (Benwing) disagree; that is an idealistic goal unlikely to be achievable
-- realistically.
if paramForError ~= nil then
track("paramForError")
end
if type(code) ~= "string" then
local typ
if not code then
typ = "nil"
elseif check_object("language", true, code) then
typ = "a language object"
elseif check_object("family", true, code) then
typ = "a family object"
else
typ = "a " .. type(code)
end
error("The function getByCode expects a string as its first argument, but received " .. typ .. ".")
end
local m_data = load_data(languages_data_module)
if m_data.aliases[code] or m_data.track[code] then
track(code)
end
local norm_code = normalize_code(code)
-- Get the data, checking for etymology-only languages if allowEtymLang is set.
local data = load_data(get_data_module_name(norm_code))[norm_code] or
allowEtymLang and load_data(etymology_languages_data_module)[norm_code]
-- If no data was found and allowFamily is set, check the family data. If the main family data was found, make the
-- object with [[Module:families]] instead, as family objects have different methods. However, if it's an
-- etymology-only family, use make_object in this module (which handles object inheritance), and the
-- family-specific methods will be inherited from the parent object.
if data == nil and allowFamily then
data = load_data("Module:families/data")[norm_code]
if data ~= nil then
if data.parent == nil then
return make_family_object(norm_code, data)
elseif not allowEtymLang then
data = nil
end
end
end
local retval = code and data and make_object(code, data)
if not retval and paramForError then
require("Module:languages/errorGetBy").code(code, paramForError, allowEtymLang, allowFamily)
end
return retval
end
get_by_code = export.getByCode
--[==[
Find the language whose canonical name (the name used to represent that language on Wiktionary) or other name matches
the one provided. If it exists, return a `Language` object representing the language. Otherwise, return {nil}, unless
`paramForError` is given, in which case an error is generated. If `allowEtymLang` is specified, etymology-only language
codes are allowed and looked up along with full language codes. If `allowFamily` is specified, language family codes are
allowed and looked up along with normal language codes. The canonical name of languages should always be unique (it is
an error for two languages on Wiktionary to share the same canonical name), so this is guaranteed to give at most one
result. This function is powered by [[Module:languages/canonical names]], which contains a pre-generated mapping of
full-language canonical names to codes. It is generated by going through the [[:Category:Language data modules]] for
full languages. When `allowEtymLang` is specified for the above function, [[Module:etymology languages/canonical names]]
may also be used, and when `allowFamily` is specified for the above function, [[Module:families/canonical names]] may
also be used.
]==]
function export.getByCanonicalName(name, errorIfInvalid, allowEtymLang, allowFamily)
local byName = load_data("Module:languages/canonical names")
local code = byName and byName[name]
-- Old English localization: also accept an Old English name (e.g. "Englisc").
if not code then
code = code_of_ang_name(name)
end
if not code and allowEtymLang then
byName = load_data("Module:etymology languages/canonical names")
code = byName and byName[name] or
byName[gsub(name, " [Ss]ubstrate$", "")] or
byName[gsub(name, "^a ", "")] or
byName[gsub(name, "^a ", ""):gsub(" [Ss]ubstrate$", "")] or
-- For etymology families like "ira-pro".
-- FIXME: This is not ideal, as it allows " languages" to be appended to any etymology-only language, too.
byName[match(name, "^(.*) languages$")]
end
if not code and allowFamily then
byName = load_data("Module:families/canonical names")
code = byName[name] or byName[match(name, "^(.*) languages$")]
end
local retval = code and get_by_code(code, errorIfInvalid, allowEtymLang, allowFamily)
if not retval and errorIfInvalid then
require("Module:languages/errorGetBy").canonicalName(name, allowEtymLang, allowFamily)
end
return retval
end
--[==[
Used by [[Module:languages/data/2]] (et al.) and [[Module:etymology languages/data]], [[Module:families/data]],
[[Module:scripts/data]] and [[Module:writing systems/data]] to finalize the data into the format that is actually returned.
]==]
function export.finalizeData(data, main_type, variety)
local fields = {"type"}
if main_type == "language" then
insert(fields, 4) -- script codes
insert(fields, "ancestors")
insert(fields, "link_tr")
insert(fields, "override_translit")
insert(fields, "wikimedia_codes")
elseif main_type == "script" then
insert(fields, 3) -- writing system codes
end -- Families and writing systems have no extra fields to process.
local fields_len = #fields
for _, entity in next, data do
if variety then
-- Move parent from 3 to "parent" and family from "family" to 3. These are different for the sake of
-- convenience, since very few varieties have the family specified, whereas all of them have a parent.
entity.parent, entity[3] = entity[3], entity.family
entity.family = nil
-- Give the type "regular" iff not a variety and no other types are assigned.
elseif not (entity.type or entity.parent) then
entity.type = "regular"
end
for i = 1, fields_len do
local key = fields[i]
local field = entity[key]
if field and type(field) == "string" then
entity[key] = gsub(field, "%s*,%s*", ",")
end
end
end
return data
end
--[==[
For backwards compatibility only; modules should require the error themselves.
]==]
function export.err(lang_code, param, code_desc, template_tag, not_real_lang)
return require("Module:languages/error")(lang_code, param, code_desc, template_tag, not_real_lang)
end
return export
bit1po5o6ftn0mb20est88wranzkyq1
Module:languages/data
828
7869
54896
54703
2026-09-28T22:15:40Z
Deadend0914
7211
54896
Scribunto
text/plain
local l = {}
l['ang'] = { name = 'Englisc', wiktionaryExists = true}
l['af'] = { name = 'Affircanisc', wiktionaryExists = true}
l['bn'] = {name = 'Bengalisc', wiktionaryExists = true}
l['cn'] = {name = 'Catalānisc', wiktionaryExists = true}
l['cs']={name = 'Bæmisc', wiktionaryExists = true}
l['da']={name = 'Densic', wiktionaryExists = true}
l['de']={name = 'Þēodisc', wiktionaryExists = true}
l['el']={name= 'Crēacisc', wiktionaryExists = true}
l['en']={name='Nīwenglisc', wiktionaryExists = true}
l['eo']={name='Esperantisc', wiktionaryExists = true}
l['es']={name='Spēonisc', wiktionaryExists = true}
l['et']={name = 'Eotolisc', wiktionaryExists = true}
l['eu']={name='Wascisc', wiktionaryExists = true}
l['fa']={name='Persisc', wiktionaryExists = true}
l['fi']={name='Finnisc', wiktionaryExists = true}
l['fo']={name='Færisc', wiktionaryExists = true}
l['fr']={name='Frencisc', wiktionaryExists = true}
l['ga']={name='Īrisc', wiktionaryExists = true}
l['gl']={name='Galizisc', wiktionaryExists = true}
l['gn']={name='Awaisc', wiktionaryExists = true}
l['gv']={name='Manisc', wiktionaryExists = true}
l['haw']={name='Hawaiisc'}
l['hi']={name='Hindisc', wiktionaryExists = true}
l['hu']={name='Hungarisc', wiktionaryExists=true}
l['id']={name='Indonesisc', wiktionaryExists = true}
l['io']={name='Idoisc', wiktionaryExists=true}
l['is']={name='Īslendisc', wiktionaryExists=true}
l['it']={name='Italisc', wiktionaryExists=true}
l['la']={name='Lǣden', wiktionaryExists=true}
l['li']={name='Limburgisc', wiktionaryExists=true}
l['lt']={name='Litwisc', wiktionaryExists=true}
l['lv']={name='Lettisc', wiktionaryExists=true}
l['nl']={name='Niðerlendisc', wiktionaryExists=true}
l['no']={name='Norþwegisc', wiktionaryExists=true}
l['pl']={name='Polisc', wiktionaryExists=true}
l['pt']={name='Portugisc', wiktionaryExists=true}
l['qu']={name='Kescwisc', wiktionaryExists=true}
l['ro']={name='Rumǣnisc', wiktionaryExists=true}
l['sa']={name='Sanscritisc', wiktionaryExists=true}
l['sq']={name='Albānisc', wiktionaryExists=true}
l['sv']={name='Swēonisc', wiktionaryExists=true}
gxt99xn0sctlqj5wuct69vywrt6al8c
54900
54896
2026-09-28T22:40:50Z
Deadend0914
7211
54900
Scribunto
text/plain
local export = {}
-- We can't use mw.loadData() on [[Module:languages/chars]] because [[Module:languages/data]] itself is sometimes loaded
-- using mw.loadData(), and calling mw.loadData() on [[Module:languages/chars]] will insert metatables into the
-- character tables, which the second mw.loadData() will choke on.
local m_chars = require("Module:languages/chars")
local u = require("Module:string/char")
local c = m_chars.chars
export.chars = c
local p = m_chars.puaChars
export.puaChars = p
local cs = m_chars.chars_substitutions
export.chars_substitutions = cs
-- FIXME! Many of the script-specific values below can be moved to [[Module:scripts/data]] to serve as script-wide
-- fallback values instead of specifying them for each language using the script.
local s = {}
-- These values are placed here to make it possible to synchronise a group of languages without the need for a dedicated function module.
-- cau
do
local cau_remove_diacritics = c.grave .. c.acute .. c.macron
local cau_from = {"[IlΙІӀᴴ]"}
local cau_to = {{
["l"] = "ӏ",
["Ι"] = "ӏ",
["І"] = "ӏ",
["Ӏ"] = "ӏ",
["ᴴ"] = "ᵸ",
}}
s["cau-Cyrl-displaytext"] = {
from = cau_from,
to = cau_to,
}
s["cau-Cyrl-stripdiacritics"] = {
remove_diacritics = cau_remove_diacritics,
from = cau_from,
to = cau_to,
}
s["cau-Latn-stripdiacritics"] = {remove_diacritics = cau_remove_diacritics}
end
s["itc-Latn-displaytext"] = {
from = {c.caron},
to = {c.breve},
}
s["itc-Latn-stripdiacritics"] = {remove_diacritics = c.macron .. c.breve .. c.diaer .. c.caron .. c.dinvbreve}
s["itc-Latn-sortkey"] = {
remove_diacritics = c.circ .. c.tilde .. c.macron .. c.breve .. c.diaer .. c.caron .. c.zigzag .. c.dmacron .. c.dtilde .. c.dinvbreve .. c.small_a .. c.small_e .. c.small_i .. c.small_o .. c.small_u, -- Chiefly medieval abbreviations.
from = {"ᵃ", "æ", "[đꝱꟈ]", "ᵉ", "ⁱ", "ꝁ", "[ƚꝉꝲ]", "ꝳ", "ꝴ", "[ꝋᵒ]", "œ", "[ꝑꝓꝕ]", "[ꝗꝙ]", "[ꝛꝵꝶꝝ]", "[ꟊˢ]", "[ꝷᵗ]", "ᵘ", "ꝟ", "⁊"},
to = {"a", "ae", "d", "e", "i", "k", "l", "m", "n", "o", "oe", "p", "q", "r", "s", "t", "u", "v", "&"}
}
s["Jpan-standardchars"] = -- exclude ぢづヂヅ
"ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちっつてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろん" ..
"ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチッツテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロン"
local jpx_displaytext = {
from = {"~", "="},
to = {"〜", "゠"}
}
s["jpx-displaytext"] = {
Jpan = jpx_displaytext,
Hani = jpx_displaytext,
Hrkt = jpx_displaytext,
Hira = jpx_displaytext,
Kana = jpx_displaytext
-- not Latn or Brai
}
s["jpx-stripdiacritics"] = s["jpx-displaytext"]
s["jpx-sortkey"] = {
Jpan = "Jpan-sortkey",
Hani = "Hani-sortkey",
Hrkt = "Hira-sortkey", -- sort general kana by normalizing to Hira
Hira = "Hira-sortkey",
Kana = "Kana-sortkey",
Latn = {remove_diacritics = c.tilde .. c.macron .. c.diaer}
}
s["jpx-translit"] = {
Hrkt = "Hrkt-translit",
Hira = "Hrkt-translit",
Kana = "Hrkt-translit"
}
s["roa-oil-sortkey"] = {
remove_diacritics = c.grave .. c.acute .. c.circ .. c.tilde .. c.diaer .. c.ringabove .. c.cedilla .. "'",
from = {"æ", "œ", "·"},
to = {"ae", "oe", " "}
}
s["wen-sortkey"] = {
from = {"ch", "[lłßꞩẜ]", "dz[" .. c.caron .. c.acute .. "]", "[bcefmnoprswz][" .. c.caron .. c.acute .. c.dotabove .. "]"},
to = {
"h" .. p[1],
{
["l"] = "l" .. p[1], ["ł"] = "l", ["ß"] = "s", ["ꞩ"] = "š", ["ẜ"] = "š",
},
{
["dz" .. c.caron] = "d" .. p[1], ["dz" .. c.acute] = "d" .. p[2]
},
{
["b" .. c.acute] = "b" .. p[1],
["c" .. c.caron] = "c" .. p[1], ["c" .. c.acute] = "c" .. p[2],
["e" .. c.caron] = "e" .. p[1], ["e" .. c.dotabove] = "e" .. p[1],
["f" .. c.acute] = "f" .. p[1],
["m" .. c.acute] = "m" .. p[1],
["n" .. c.acute] = "n" .. p[1],
["o" .. c.acute] = "o" .. p[1],
["p" .. c.acute] = "p" .. p[1],
["r" .. c.caron] = "r" .. p[1], ["r" .. c.acute] = "r" .. p[2],
["s" .. c.caron] = "s" .. p[1], ["s" .. c.acute] = "s" .. p[2],
["w" .. c.acute] = "w" .. p[1],
["z" .. c.caron] = "z" .. p[1], ["z" .. c.acute] = "z" .. p[2],
}
}
}
-- Myanmar dotted form : https://www.unicode.org/Public/UNIDATA/StandardizedVariants.txt
s["aio-displaytext"] = {
from = {"([ကဂငတထပမယလဝဢေၵၸၺႀꩠꩡꩢꩣꩤꩥꩦꩫꩬꩯꩺ])"},
to = {"%1" .. c.VS01}
}
s["aio-stripdiacritics"] = {
remove_diacritics = c.VS01,
}
s["esx-displaytext"] = {
from = {"ǝ"},
to = {"ə"},
}
s["esx-stripdiacritics"] = s["esx-displaytext"]
s["phk-displaytext"] = s["aio-displaytext"]
s["phk-stripdiacritics"] = s["aio-stripdiacritics"]
s["kht-displaytext"] = s["aio-displaytext"]
s["kht-stripdiacritics"] = s["aio-stripdiacritics"]
export.shared = s
--[==[ var:
Short-term solution to override the standard substitution process, by forcing the module to substitute the entire
text in one pass, if "cont" is given. This results in any PUA characters that are used as stand-ins for formatting being
handled by the language-specific substitution process, which is usually undesirable. If the value is "none" then the
formatting tags do not get turned into PUA characters in the first place. This override is provided for languages which
use formatting between strings of text which might need to interact with each other (e.g. Korean 값이 transliterates as "gaps-i", but [[값]] has the formatting '''값'''[[-이]]. The normal process would split the text at the second '''.)
]==]
export.substitution = {
["gmy"] = "none",
["ja"] = "cont",
["jje"] = "cont",
["ket"] = "none",
["ko"] = "cont",
["ko-ear"] = "cont",
["ru"] = "cont",
["th-new"] = "cont",
["sa"] = "cont",
["zkt"] = "cont",
}
--[==[ var:
Code aliases. The left side is the alias and the right side is the canonical code. NOTE: These are gradually
being deprecated, so should not be added to on a permanent basis. Temporary additions are permitted under reasonable
circumstances (e.g. to facilitate changing a language's code). When an alias is no longer used, it should be removed.
Aliases in this table are tracked at [[Wiktionary:Tracking/languages/LANG]]; see e.g.
[[Special:WhatLinksHere/Wiktionary:Tracking/languages/VL.]] for the `VL.` alias.
]==]
export.aliases = {
["EL."] = "la-ecc",
["LL."] = "la-lat",
["ML."] = "la-med",
["NL."] = "la-new",
["VL."] = "la-vul",
["grc-epc"] = "grc-epi",
["nds-DE"] = "nds-de",
["nds-NL"] = "nds-nl",
["roa-oan"] = "roa-ona",
["sa-cls"] = "cls",
["sa-ved"] = "vsn",
}
--[==[ var:
Codes which are tracked. Note that all aliases listed above are also tracked, so should not be duplicated here.
Tracking uses the same mechanism described above in the comment above `export.aliases`.
]==]
export.track = {
-- Codes duplicated between full and etymology-only languages.
["lzh-lit"] = true,
["lzh"] = true,
-- Languages actively being converted to families.
["bh"] = true, -- inc-bih
["nan"] = true, -- zhx-nan
-- Transcription scheme being changed.
["trk-pro"] = true,
}
return export
mpdv2gw5dmhuaq7h15kvelv3q6pv46b
Module:headword/page
828
7978
54925
54717
2026-09-29T00:05:09Z
Deadend0914
7211
54925
Scribunto
text/plain
local export = {}
local languages_module = "Module:languages"
local maintenance_category_module = "Module:maintenance category"
local pages_module = "Module:pages"
local string_compare_module = "Module:string/compare"
local string_decode_entities_module = "Module:string/decodeEntities"
local string_remove_comments_module = "Module:string/removeComments"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local template_parser_module = "Module:template parser"
local mw = mw
local string = string
local table = table
local ustring = mw.ustring
local concat = table.concat
local find = string.find
local format = string.format
local gsub = string.gsub
local insert = table.insert
local load_data = mw.loadData
local match = string.match
local new_title = mw.title.new
local pairs = pairs
local require = require
local sub = string.sub
local toNFC = ustring.toNFC
local toNFD = ustring.toNFD
local ugsub = ustring.gsub
local function class_else_type(...)
class_else_type = require(template_parser_module).class_else_type
return class_else_type(...)
end
local function decode_entities(...)
decode_entities = require(string_decode_entities_module)
return decode_entities(...)
end
local function encode_entities(...)
encode_entities = require(string_utilities_module).encode_entities
return encode_entities(...)
end
local function get_category(...)
get_category = require(maintenance_category_module).get_category
return get_category(...)
end
local function get_lang(...)
get_lang = require(languages_module).getByCode
return get_lang(...)
end
local function list_to_set(...)
list_to_set = require(table_module).listToSet
return list_to_set(...)
end
local function parse(...)
parse = require(template_parser_module).parse
return parse(...)
end
local function remove_comments(...)
remove_comments = require(string_remove_comments_module)
return remove_comments(...)
end
local function physical_to_logical_pagename_if_mammoth(...)
physical_to_logical_pagename_if_mammoth = require(pages_module).physical_to_logical_pagename_if_mammoth
return physical_to_logical_pagename_if_mammoth(...)
end
local function split(...)
split = require(string_utilities_module).split
return split(...)
end
local function string_compare(...)
string_compare = require(string_compare_module)
return string_compare(...)
end
local function uupper(...)
uupper = require(string_utilities_module).upper
return uupper(...)
end
--[==[
Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==]
-- Old English localization: the ==L2== headings are rendered by [[Bysen:sprǣc]] from
-- [[Module:sprǣcnaman]], so those names have to be recognized as language names below as well. The
-- module is optional: if it is missing, the English names are used exactly as before.
local ang_names_module = "Module:sprǣcnaman"
local ang_names
local function get_ang_names()
if ang_names == nil then
local ok, mod = pcall(require, ang_names_module)
ang_names = ok and mod or false
end
return ang_names or nil
end
local langnames
local function get_langnames()
langnames, get_langnames = load_data("Module:languages/canonical names"), nil
-- Old English localization: add the Old English language names, so that an ==L2== heading
-- written with {{Bysen:sprǣc}} is recognized as a canonical language name.
local m_ang_names = get_ang_names()
if m_ang_names then
for _, ang_name in pairs(m_ang_names.names) do
langnames[ang_name] = true
end
end
return langnames
end
-- Combining character data used when categorising unusual characters. These resolve into two patterns, used to find
-- single combining characters (i.e. character + diacritic(s)) or double combining characters (i.e. character +
-- diacritic(s) + character).
-- Charsets are in the format used by Unicode's UnicodeSet tool: https://util.unicode.org/UnicodeJsps/list-unicodeset.jsp.
-- Single combining characters.
-- Charset: [[:M:]&[:^Canonical_Combining_Class=/^Double_/:]&[:^subhead=Grapheme joiner:]&[:^Variation_Selector=Yes:]]
-- Note: concatenating hundreds of lines at once gives an error, so () are used every 150 lines to break it up into chunks.
local comb_chars_single =
("\204\128-\205\142" .. -- U+0300-U+034E
"\205\144-\205\155" .. -- U+0350-U+035B
"\205\163-\205\175" .. -- U+0363-U+036F
"\210\131-\210\137" .. -- U+0483-U+0489
"\214\145-\214\189" .. -- U+0591-U+05BD
"\214\191" .. -- U+05BF
"\215\129" .. -- U+05C1
"\215\130" .. -- U+05C2
"\215\132" .. -- U+05C4
"\215\133" .. -- U+05C5
"\215\135" .. -- U+05C7
"\216\144-\216\154" .. -- U+0610-U+061A
"\217\139-\217\159" .. -- U+064B-U+065F
"\217\176" .. -- U+0670
"\219\150-\219\156" .. -- U+06D6-U+06DC
"\219\159-\219\164" .. -- U+06DF-U+06E4
"\219\167" .. -- U+06E7
"\219\168" .. -- U+06E8
"\219\170-\219\173" .. -- U+06EA-U+06ED
"\220\145" .. -- U+0711
"\220\176-\221\138" .. -- U+0730-U+074A
"\222\166-\222\176" .. -- U+07A6-U+07B0
"\223\171-\223\179" .. -- U+07EB-U+07F3
"\223\189" .. -- U+07FD
"\224\160\150-\224\160\153" .. -- U+0816-U+0819
"\224\160\155-\224\160\163" .. -- U+081B-U+0823
"\224\160\165-\224\160\167" .. -- U+0825-U+0827
"\224\160\169-\224\160\173" .. -- U+0829-U+082D
"\224\161\153-\224\161\155" .. -- U+0859-U+085B
"\224\162\151-\224\162\159" .. -- U+0897-U+089F
"\224\163\138-\224\163\161" .. -- U+08CA-U+08E1
"\224\163\163-\224\164\131" .. -- U+08E3-U+0903
"\224\164\186-\224\164\188" .. -- U+093A-U+093C
"\224\164\190-\224\165\143" .. -- U+093E-U+094F
"\224\165\145-\224\165\151" .. -- U+0951-U+0957
"\224\165\162" .. -- U+0962
"\224\165\163" .. -- U+0963
"\224\166\129-\224\166\131" .. -- U+0981-U+0983
"\224\166\188" .. -- U+09BC
"\224\166\190-\224\167\132" .. -- U+09BE-U+09C4
"\224\167\135" .. -- U+09C7
"\224\167\136" .. -- U+09C8
"\224\167\139-\224\167\141" .. -- U+09CB-U+09CD
"\224\167\151" .. -- U+09D7
"\224\167\162" .. -- U+09E2
"\224\167\163" .. -- U+09E3
"\224\167\190" .. -- U+09FE
"\224\168\129-\224\168\131" .. -- U+0A01-U+0A03
"\224\168\188" .. -- U+0A3C
"\224\168\190-\224\169\130" .. -- U+0A3E-U+0A42
"\224\169\135" .. -- U+0A47
"\224\169\136" .. -- U+0A48
"\224\169\139-\224\169\141" .. -- U+0A4B-U+0A4D
"\224\169\145" .. -- U+0A51
"\224\169\176" .. -- U+0A70
"\224\169\177" .. -- U+0A71
"\224\169\181" .. -- U+0A75
"\224\170\129-\224\170\131" .. -- U+0A81-U+0A83
"\224\170\188" .. -- U+0ABC
"\224\170\190-\224\171\133" .. -- U+0ABE-U+0AC5
"\224\171\135-\224\171\137" .. -- U+0AC7-U+0AC9
"\224\171\139-\224\171\141" .. -- U+0ACB-U+0ACD
"\224\171\162" .. -- U+0AE2
"\224\171\163" .. -- U+0AE3
"\224\171\186-\224\171\191" .. -- U+0AFA-U+0AFF
"\224\172\129-\224\172\131" .. -- U+0B01-U+0B03
"\224\172\188" .. -- U+0B3C
"\224\172\190-\224\173\132" .. -- U+0B3E-U+0B44
"\224\173\135" .. -- U+0B47
"\224\173\136" .. -- U+0B48
"\224\173\139-\224\173\141" .. -- U+0B4B-U+0B4D
"\224\173\149-\224\173\151" .. -- U+0B55-U+0B57
"\224\173\162" .. -- U+0B62
"\224\173\163" .. -- U+0B63
"\224\174\130" .. -- U+0B82
"\224\174\190-\224\175\130" .. -- U+0BBE-U+0BC2
"\224\175\134-\224\175\136" .. -- U+0BC6-U+0BC8
"\224\175\138-\224\175\141" .. -- U+0BCA-U+0BCD
"\224\175\151" .. -- U+0BD7
"\224\176\128-\224\176\132" .. -- U+0C00-U+0C04
"\224\176\188" .. -- U+0C3C
"\224\176\190-\224\177\132" .. -- U+0C3E-U+0C44
"\224\177\134-\224\177\136" .. -- U+0C46-U+0C48
"\224\177\138-\224\177\141" .. -- U+0C4A-U+0C4D
"\224\177\149" .. -- U+0C55
"\224\177\150" .. -- U+0C56
"\224\177\162" .. -- U+0C62
"\224\177\163" .. -- U+0C63
"\224\178\129-\224\178\131" .. -- U+0C81-U+0C83
"\224\178\188" .. -- U+0CBC
"\224\178\190-\224\179\132" .. -- U+0CBE-U+0CC4
"\224\179\134-\224\179\136" .. -- U+0CC6-U+0CC8
"\224\179\138-\224\179\141" .. -- U+0CCA-U+0CCD
"\224\179\149" .. -- U+0CD5
"\224\179\150" .. -- U+0CD6
"\224\179\162" .. -- U+0CE2
"\224\179\163" .. -- U+0CE3
"\224\179\179" .. -- U+0CF3
"\224\180\128-\224\180\131" .. -- U+0D00-U+0D03
"\224\180\187" .. -- U+0D3B
"\224\180\188" .. -- U+0D3C
"\224\180\190-\224\181\132" .. -- U+0D3E-U+0D44
"\224\181\134-\224\181\136" .. -- U+0D46-U+0D48
"\224\181\138-\224\181\141" .. -- U+0D4A-U+0D4D
"\224\181\151" .. -- U+0D57
"\224\181\162" .. -- U+0D62
"\224\181\163" .. -- U+0D63
"\224\182\129-\224\182\131" .. -- U+0D81-U+0D83
"\224\183\138" .. -- U+0DCA
"\224\183\143-\224\183\148" .. -- U+0DCF-U+0DD4
"\224\183\150" .. -- U+0DD6
"\224\183\152-\224\183\159" .. -- U+0DD8-U+0DDF
"\224\183\178" .. -- U+0DF2
"\224\183\179" .. -- U+0DF3
"\224\184\177" .. -- U+0E31
"\224\184\180-\224\184\186" .. -- U+0E34-U+0E3A
"\224\185\135-\224\185\142" .. -- U+0E47-U+0E4E
"\224\186\177" .. -- U+0EB1
"\224\186\180-\224\186\188" .. -- U+0EB4-U+0EBC
"\224\187\136-\224\187\142" .. -- U+0EC8-U+0ECE
"\224\188\152" .. -- U+0F18
"\224\188\153" .. -- U+0F19
"\224\188\181" .. -- U+0F35
"\224\188\183" .. -- U+0F37
"\224\188\185" .. -- U+0F39
"\224\188\190" .. -- U+0F3E
"\224\188\191" .. -- U+0F3F
"\224\189\177-\224\190\132" .. -- U+0F71-U+0F84
"\224\190\134" .. -- U+0F86
"\224\190\135" .. -- U+0F87
"\224\190\141-\224\190\151" .. -- U+0F8D-U+0F97
"\224\190\153-\224\190\188" .. -- U+0F99-U+0FBC
"\224\191\134" .. -- U+0FC6
"\225\128\171-\225\128\190" .. -- U+102B-U+103E
"\225\129\150-\225\129\153" .. -- U+1056-U+1059
"\225\129\158-\225\129\160" .. -- U+105E-U+1060
"\225\129\162-\225\129\164" .. -- U+1062-U+1064
"\225\129\167-\225\129\173" .. -- U+1067-U+106D
"\225\129\177-\225\129\180" .. -- U+1071-U+1074
"\225\130\130-\225\130\141" .. -- U+1082-U+108D
"\225\130\143" .. -- U+108F
"\225\130\154-\225\130\157" .. -- U+109A-U+109D
"\225\141\157-\225\141\159" .. -- U+135D-U+135F
"\225\156\146-\225\156\149" .. -- U+1712-U+1715
"\225\156\178-\225\156\180" .. -- U+1732-U+1734
"\225\157\146" .. -- U+1752
"\225\157\147" .. -- U+1753
"\225\157\178" .. -- U+1772
"\225\157\179" .. -- U+1773
"\225\158\180-\225\159\147") .. -- U+17B4-U+17D3
("\225\159\157" .. -- U+17DD
"\225\162\133" .. -- U+1885
"\225\162\134" .. -- U+1886
"\225\162\169" .. -- U+18A9
"\225\164\160-\225\164\171" .. -- U+1920-U+192B
"\225\164\176-\225\164\187" .. -- U+1930-U+193B
"\225\168\151-\225\168\155" .. -- U+1A17-U+1A1B
"\225\169\149-\225\169\158" .. -- U+1A55-U+1A5E
"\225\169\160-\225\169\188" .. -- U+1A60-U+1A7C
"\225\169\191" .. -- U+1A7F
"\225\170\176-\225\171\142" .. -- U+1AB0-U+1ACE
"\225\172\128-\225\172\132" .. -- U+1B00-U+1B04
"\225\172\180-\225\173\132" .. -- U+1B34-U+1B44
"\225\173\171-\225\173\179" .. -- U+1B6B-U+1B73
"\225\174\128-\225\174\130" .. -- U+1B80-U+1B82
"\225\174\161-\225\174\173" .. -- U+1BA1-U+1BAD
"\225\175\166-\225\175\179" .. -- U+1BE6-U+1BF3
"\225\176\164-\225\176\183" .. -- U+1C24-U+1C37
"\225\179\144-\225\179\146" .. -- U+1CD0-U+1CD2
"\225\179\148-\225\179\168" .. -- U+1CD4-U+1CE8
"\225\179\173" .. -- U+1CED
"\225\179\180" .. -- U+1CF4
"\225\179\183-\225\179\185" .. -- U+1CF7-U+1CF9
"\225\183\128-\225\183\140" .. -- U+1DC0-U+1DCC
"\225\183\142-\225\183\187" .. -- U+1DCE-U+1DFB
"\225\183\189-\225\183\191" .. -- U+1DFD-U+1DFF
"\226\131\144-\226\131\176" .. -- U+20D0-U+20F0
"\226\179\175-\226\179\177" .. -- U+2CEF-U+2CF1
"\226\181\191" .. -- U+2D7F
"\226\183\160-\226\183\191" .. -- U+2DE0-U+2DFF
"\227\128\170-\227\128\175" .. -- U+302A-U+302F
"\227\130\153" .. -- U+3099
"\227\130\154" .. -- U+309A
"\234\153\175-\234\153\178" .. -- U+A66F-U+A672
"\234\153\180-\234\153\189" .. -- U+A674-U+A67D
"\234\154\158" .. -- U+A69E
"\234\154\159" .. -- U+A69F
"\234\155\176" .. -- U+A6F0
"\234\155\177" .. -- U+A6F1
"\234\160\130" .. -- U+A802
"\234\160\134" .. -- U+A806
"\234\160\139" .. -- U+A80B
"\234\160\163-\234\160\167" .. -- U+A823-U+A827
"\234\160\172" .. -- U+A82C
"\234\162\128" .. -- U+A880
"\234\162\129" .. -- U+A881
"\234\162\180-\234\163\133" .. -- U+A8B4-U+A8C5
"\234\163\160-\234\163\177" .. -- U+A8E0-U+A8F1
"\234\163\191" .. -- U+A8FF
"\234\164\166-\234\164\173" .. -- U+A926-U+A92D
"\234\165\135-\234\165\147" .. -- U+A947-U+A953
"\234\166\128-\234\166\131" .. -- U+A980-U+A983
"\234\166\179-\234\167\128" .. -- U+A9B3-U+A9C0
"\234\167\165" .. -- U+A9E5
"\234\168\169-\234\168\182" .. -- U+AA29-U+AA36
"\234\169\131" .. -- U+AA43
"\234\169\140" .. -- U+AA4C
"\234\169\141" .. -- U+AA4D
"\234\169\187-\234\169\189" .. -- U+AA7B-U+AA7D
"\234\170\176" .. -- U+AAB0
"\234\170\178-\234\170\180" .. -- U+AAB2-U+AAB4
"\234\170\183" .. -- U+AAB7
"\234\170\184" .. -- U+AAB8
"\234\170\190" .. -- U+AABE
"\234\170\191" .. -- U+AABF
"\234\171\129" .. -- U+AAC1
"\234\171\171-\234\171\175" .. -- U+AAEB-U+AAEF
"\234\171\181" .. -- U+AAF5
"\234\171\182" .. -- U+AAF6
"\234\175\163-\234\175\170" .. -- U+ABE3-U+ABEA
"\234\175\172" .. -- U+ABEC
"\234\175\173" .. -- U+ABED
"\239\172\158" .. -- U+FB1E
"\239\184\160-\239\184\175" .. -- U+FE20-U+FE2F
"\240\144\135\189" .. -- U+101FD
"\240\144\139\160" .. -- U+102E0
"\240\144\141\182-\240\144\141\186" .. -- U+10376-U+1037A
"\240\144\168\129-\240\144\168\131" .. -- U+10A01-U+10A03
"\240\144\168\133" .. -- U+10A05
"\240\144\168\134" .. -- U+10A06
"\240\144\168\140-\240\144\168\143" .. -- U+10A0C-U+10A0F
"\240\144\168\184-\240\144\168\186" .. -- U+10A38-U+10A3A
"\240\144\168\191" .. -- U+10A3F
"\240\144\171\165" .. -- U+10AE5
"\240\144\171\166" .. -- U+10AE6
"\240\144\180\164-\240\144\180\167" .. -- U+10D24-U+10D27
"\240\144\181\169-\240\144\181\173" .. -- U+10D69-U+10D6D
"\240\144\186\171" .. -- U+10EAB
"\240\144\186\172" .. -- U+10EAC
"\240\144\187\188-\240\144\187\191" .. -- U+10EFC-U+10EFF
"\240\144\189\134-\240\144\189\144" .. -- U+10F46-U+10F50
"\240\144\190\130-\240\144\190\133" .. -- U+10F82-U+10F85
"\240\145\128\128-\240\145\128\130" .. -- U+11000-U+11002
"\240\145\128\184-\240\145\129\134" .. -- U+11038-U+11046
"\240\145\129\176" .. -- U+11070
"\240\145\129\179" .. -- U+11073
"\240\145\129\180" .. -- U+11074
"\240\145\129\191-\240\145\130\130" .. -- U+1107F-U+11082
"\240\145\130\176-\240\145\130\186" .. -- U+110B0-U+110BA
"\240\145\131\130" .. -- U+110C2
"\240\145\132\128-\240\145\132\130" .. -- U+11100-U+11102
"\240\145\132\167-\240\145\132\180" .. -- U+11127-U+11134
"\240\145\133\133" .. -- U+11145
"\240\145\133\134" .. -- U+11146
"\240\145\133\179" .. -- U+11173
"\240\145\134\128-\240\145\134\130" .. -- U+11180-U+11182
"\240\145\134\179-\240\145\135\128" .. -- U+111B3-U+111C0
"\240\145\135\137-\240\145\135\140" .. -- U+111C9-U+111CC
"\240\145\135\142" .. -- U+111CE
"\240\145\135\143" .. -- U+111CF
"\240\145\136\172-\240\145\136\183" .. -- U+1122C-U+11237
"\240\145\136\190" .. -- U+1123E
"\240\145\137\129" .. -- U+11241
"\240\145\139\159-\240\145\139\170" .. -- U+112DF-U+112EA
"\240\145\140\128-\240\145\140\131" .. -- U+11300-U+11303
"\240\145\140\187" .. -- U+1133B
"\240\145\140\188" .. -- U+1133C
"\240\145\140\190-\240\145\141\132" .. -- U+1133E-U+11344
"\240\145\141\135" .. -- U+11347
"\240\145\141\136" .. -- U+11348
"\240\145\141\139-\240\145\141\141" .. -- U+1134B-U+1134D
"\240\145\141\151" .. -- U+11357
"\240\145\141\162" .. -- U+11362
"\240\145\141\163" .. -- U+11363
"\240\145\141\166-\240\145\141\172" .. -- U+11366-U+1136C
"\240\145\141\176-\240\145\141\180" .. -- U+11370-U+11374
"\240\145\142\184-\240\145\143\128" .. -- U+113B8-U+113C0
"\240\145\143\130" .. -- U+113C2
"\240\145\143\133" .. -- U+113C5
"\240\145\143\135-\240\145\143\138" .. -- U+113C7-U+113CA
"\240\145\143\140-\240\145\143\144" .. -- U+113CC-U+113D0
"\240\145\143\146" .. -- U+113D2
"\240\145\143\161" .. -- U+113E1
"\240\145\143\162" .. -- U+113E2
"\240\145\144\181-\240\145\145\134" .. -- U+11435-U+11446
"\240\145\145\158" .. -- U+1145E
"\240\145\146\176-\240\145\147\131" .. -- U+114B0-U+114C3
"\240\145\150\175-\240\145\150\181" .. -- U+115AF-U+115B5
"\240\145\150\184-\240\145\151\128" .. -- U+115B8-U+115C0
"\240\145\151\156" .. -- U+115DC
"\240\145\151\157" .. -- U+115DD
"\240\145\152\176-\240\145\153\128" .. -- U+11630-U+11640
"\240\145\154\171-\240\145\154\183" .. -- U+116AB-U+116B7
"\240\145\156\157-\240\145\156\171" .. -- U+1171D-U+1172B
"\240\145\160\172-\240\145\160\186" .. -- U+1182C-U+1183A
"\240\145\164\176-\240\145\164\181" .. -- U+11930-U+11935
"\240\145\164\183" .. -- U+11937
"\240\145\164\184" .. -- U+11938
"\240\145\164\187-\240\145\164\190" .. -- U+1193B-U+1193E
"\240\145\165\128") .. -- U+11940
("\240\145\165\130" .. -- U+11942
"\240\145\165\131" .. -- U+11943
"\240\145\167\145-\240\145\167\151" .. -- U+119D1-U+119D7
"\240\145\167\154-\240\145\167\160" .. -- U+119DA-U+119E0
"\240\145\167\164" .. -- U+119E4
"\240\145\168\129-\240\145\168\138" .. -- U+11A01-U+11A0A
"\240\145\168\179-\240\145\168\185" .. -- U+11A33-U+11A39
"\240\145\168\187-\240\145\168\190" .. -- U+11A3B-U+11A3E
"\240\145\169\135" .. -- U+11A47
"\240\145\169\145-\240\145\169\155" .. -- U+11A51-U+11A5B
"\240\145\170\138-\240\145\170\153" .. -- U+11A8A-U+11A99
"\240\145\176\175-\240\145\176\182" .. -- U+11C2F-U+11C36
"\240\145\176\184-\240\145\176\191" .. -- U+11C38-U+11C3F
"\240\145\178\146-\240\145\178\167" .. -- U+11C92-U+11CA7
"\240\145\178\169-\240\145\178\182" .. -- U+11CA9-U+11CB6
"\240\145\180\177-\240\145\180\182" .. -- U+11D31-U+11D36
"\240\145\180\186" .. -- U+11D3A
"\240\145\180\188" .. -- U+11D3C
"\240\145\180\189" .. -- U+11D3D
"\240\145\180\191-\240\145\181\133" .. -- U+11D3F-U+11D45
"\240\145\181\135" .. -- U+11D47
"\240\145\182\138-\240\145\182\142" .. -- U+11D8A-U+11D8E
"\240\145\182\144" .. -- U+11D90
"\240\145\182\145" .. -- U+11D91
"\240\145\182\147-\240\145\182\151" .. -- U+11D93-U+11D97
"\240\145\187\179-\240\145\187\182" .. -- U+11EF3-U+11EF6
"\240\145\188\128" .. -- U+11F00
"\240\145\188\129" .. -- U+11F01
"\240\145\188\131" .. -- U+11F03
"\240\145\188\180-\240\145\188\186" .. -- U+11F34-U+11F3A
"\240\145\188\190-\240\145\189\130" .. -- U+11F3E-U+11F42
"\240\145\189\154" .. -- U+11F5A
"\240\147\145\128" .. -- U+13440
"\240\147\145\135-\240\147\145\149" .. -- U+13447-U+13455
"\240\150\132\158-\240\150\132\175" .. -- U+1611E-U+1612F
"\240\150\171\176-\240\150\171\180" .. -- U+16AF0-U+16AF4
"\240\150\172\176-\240\150\172\182" .. -- U+16B30-U+16B36
"\240\150\189\143" .. -- U+16F4F
"\240\150\189\145-\240\150\190\135" .. -- U+16F51-U+16F87
"\240\150\190\143-\240\150\190\146" .. -- U+16F8F-U+16F92
"\240\150\191\164" .. -- U+16FE4
"\240\150\191\176" .. -- U+16FF0
"\240\150\191\177" .. -- U+16FF1
"\240\155\178\157" .. -- U+1BC9D
"\240\155\178\158" .. -- U+1BC9E
"\240\156\188\128-\240\156\188\173" .. -- U+1CF00-U+1CF2D
"\240\156\188\176-\240\156\189\134" .. -- U+1CF30-U+1CF46
"\240\157\133\165-\240\157\133\169" .. -- U+1D165-U+1D169
"\240\157\133\173-\240\157\133\178" .. -- U+1D16D-U+1D172
"\240\157\133\187-\240\157\134\130" .. -- U+1D17B-U+1D182
"\240\157\134\133-\240\157\134\139" .. -- U+1D185-U+1D18B
"\240\157\134\170-\240\157\134\173" .. -- U+1D1AA-U+1D1AD
"\240\157\137\130-\240\157\137\132" .. -- U+1D242-U+1D244
"\240\157\168\128-\240\157\168\182" .. -- U+1DA00-U+1DA36
"\240\157\168\187-\240\157\169\172" .. -- U+1DA3B-U+1DA6C
"\240\157\169\181" .. -- U+1DA75
"\240\157\170\132" .. -- U+1DA84
"\240\157\170\155-\240\157\170\159" .. -- U+1DA9B-U+1DA9F
"\240\157\170\161-\240\157\170\175" .. -- U+1DAA1-U+1DAAF
"\240\158\128\128-\240\158\128\134" .. -- U+1E000-U+1E006
"\240\158\128\136-\240\158\128\152" .. -- U+1E008-U+1E018
"\240\158\128\155-\240\158\128\161" .. -- U+1E01B-U+1E021
"\240\158\128\163" .. -- U+1E023
"\240\158\128\164" .. -- U+1E024
"\240\158\128\166-\240\158\128\170" .. -- U+1E026-U+1E02A
"\240\158\130\143" .. -- U+1E08F
"\240\158\132\176-\240\158\132\182" .. -- U+1E130-U+1E136
"\240\158\138\174" .. -- U+1E2AE
"\240\158\139\172-\240\158\139\175" .. -- U+1E2EC-U+1E2EF
"\240\158\147\172-\240\158\147\175" .. -- U+1E4EC-U+1E4EF
"\240\158\151\174" .. -- U+1E5EE
"\240\158\151\175" .. -- U+1E5EF
"\240\158\163\144-\240\158\163\150" .. -- U+1E8D0-U+1E8D6
"\240\158\165\132-\240\158\165\138") -- U+1E944-U+1E94A
-- Double combining characters.
-- Charset: [[:M:]&[:Canonical_Combining_Class=/^Double_/:]&[:^subhead=Grapheme joiner:]&[:^Variation_Selector=Yes:]]
local comb_chars_double =
"\205\156-\205\162" .. -- U+035C-U+0362
"\225\183\141" .. -- U+1DCD
"\225\183\188" -- U+1DFC
-- Variation selectors etc.; separated out so that we don't get categories for them.
-- Charset: [[:M:]&[[:subhead=Grapheme joiner:][:Variation_Selector=Yes:]]].
local comb_chars_other =
"\205\143" .. -- U+034F
"\225\160\139-\225\160\141" .. -- U+180B-U+180D
"\225\160\143" .. -- U+180F
"\239\184\128-\239\184\143" .. -- U+FE00-U+FE0F
"\243\160\132\128-\243\160\135\175" -- U+E0100-U+E01EF
local comb_chars_all = comb_chars_single .. comb_chars_double .. comb_chars_other
local comb_chars = {
combined_single = "[^" .. comb_chars_all .. "][" .. comb_chars_single .. comb_chars_other .. "]+%f[^" .. comb_chars_all .. "]",
combined_double = "[^" .. comb_chars_all .. "][" .. comb_chars_single .. comb_chars_other .. "]*[" .. comb_chars_double .. "]+[" .. comb_chars_all .. "]*.[" .. comb_chars_single .. comb_chars_other .. "]*",
diacritics_single = "[" .. comb_chars_single .. "]",
diacritics_double = "[" .. comb_chars_double .. "]",
diacritics_all = "[" .. comb_chars_all .. "]"
}
-- Somewhat curated list from https://unicode.org/Public/emoji/16.0/emoji-sequences.txt.
-- NOTE: There are lots more emoji sequences involving non-emoji Plane 0 symbols followed by 0xFE0F, which we don't
-- (yet?) handle.
local emoji_chars =
"\226\140\154" .. -- U+231A (⌚)
"\226\140\155" .. -- U+231B (⌛)
"\226\140\168" .. -- U+2328 (⌨)
"\226\143\143" .. -- U+23CF (⏏)
"\226\143\169-\226\143\179" .. -- U+23E9-U+23F3 (⏩-⏳)
"\226\143\184-\226\143\186" .. -- U+23F8-U+23FA (⏸-⏺)
"\226\150\170" .. -- U+25AA (▪)
"\226\150\171" .. -- U+25AB (▫)
"\226\150\182" .. -- U+25B6 (▶)
"\226\151\128" .. -- U+25C0 (◀)
"\226\151\187-\226\151\190" .. -- U+25FB-U+25FE (◻-◾)
"\226\152\128-\226\152\132" .. -- U+2600-U+2604 (☀-☄)
"\226\152\142" .. -- U+260E (☎)
"\226\152\145" .. -- U+2611 (☑)
"\226\152\148" .. -- U+2614 (☔)
"\226\152\149" .. -- U+2615 (☕)
"\226\152\152" .. -- U+2618 (☘)
"\226\152\157" .. -- U+261D (☝)
"\226\152\160" .. -- U+2620 (☠)
"\226\152\162" .. -- U+2622 (☢)
"\226\152\163" .. -- U+2623 (☣)
"\226\152\166" .. -- U+2626 (☦)
"\226\152\170" .. -- U+262A (☪)
"\226\152\174" .. -- U+262E (☮)
"\226\152\175" .. -- U+262F (☯)
"\226\152\184-\226\152\186" .. -- U+2638-U+263A (☸-☺)
"\226\153\136-\226\153\147" .. -- U+2648-U+2653 (♈-♓)
"\226\153\159" .. -- U+265F (♟)
"\226\153\160" .. -- U+2660 (♠)
"\226\153\163" .. -- U+2663 (♣)
"\226\153\165" .. -- U+2665 (♥)
"\226\153\166" .. -- U+2666 (♦)
"\226\153\168" .. -- U+2668 (♨)
"\226\153\187" .. -- U+267B (♻)
"\226\153\190" .. -- U+267E (♾)
"\226\153\191" .. -- U+267F (♿)
"\226\154\146-\226\154\151" .. -- U+2692-U+2697 (⚒-⚗)
"\226\154\153" .. -- U+2699 (⚙)
"\226\154\155" .. -- U+269B (⚛)
"\226\154\156" .. -- U+269C (⚜)
"\226\154\160" .. -- U+26A0 (⚠)
"\226\154\161" .. -- U+26A1 (⚡)
"\226\154\170" .. -- U+26AA (⚪)
"\226\154\171" .. -- U+26AB (⚫)
"\226\154\176" .. -- U+26B0 (⚰)
"\226\154\177" .. -- U+26B1 (⚱)
"\226\154\189" .. -- U+26BD (⚽)
"\226\154\190" .. -- U+26BE (⚾)
"\226\155\132" .. -- U+26C4 (⛄)
"\226\155\133" .. -- U+26C5 (⛅)
"\226\155\136" .. -- U+26C8 (⛈)
"\226\155\142" .. -- U+26CE (⛎)
"\226\155\143" .. -- U+26CF (⛏)
"\226\155\145" .. -- U+26D1 (⛑)
"\226\155\147" .. -- U+26D3 (⛓)
"\226\155\148" .. -- U+26D4 (⛔)
"\226\155\169" .. -- U+26E9 (⛩)
"\226\155\170" .. -- U+26EA (⛪)
"\226\155\176-\226\155\181" .. -- U+26F0-U+26F5 (⛰-⛵)
"\226\155\183-\226\155\186" .. -- U+26F7-U+26FA (⛷-⛺)
"\226\155\189" .. -- U+26FD (⛽)
"\226\156\130" .. -- U+2702 (✂)
"\226\156\133" .. -- U+2705 (✅)
"\226\156\136-\226\156\141" .. -- U+2708-U+270D (✈-✍)
"\226\156\143" .. -- U+270F (✏)
"\226\156\146" .. -- U+2712 (✒)
"\226\156\148" .. -- U+2714 (✔)
"\226\156\150" .. -- U+2716 (✖)
"\226\156\157" .. -- U+271D (✝)
"\226\156\161" .. -- U+2721 (✡)
"\226\156\168" .. -- U+2728 (✨)
"\226\156\179" .. -- U+2733 (✳)
"\226\156\180" .. -- U+2734 (✴)
"\226\157\132" .. -- U+2744 (❄)
"\226\157\135" .. -- U+2747 (❇)
"\226\157\140" .. -- U+274C (❌)
"\226\157\142" .. -- U+274E (❎)
"\226\157\147-\226\157\149" .. -- U+2753-U+2755 (❓-❕)
"\226\157\151" .. -- U+2757 (❗)
"\226\157\163" .. -- U+2763 (❣)
"\226\157\164" .. -- U+2764 (❤)
"\226\158\149-\226\158\151" .. -- U+2795-U+2797 (➕-➗)
"\226\158\161" .. -- U+27A1 (➡)
"\226\158\176" .. -- U+27B0 (➰)
"\226\158\191" .. -- U+27BF (➿)
"\226\164\180" .. -- U+2934 (⤴)
"\226\164\181" .. -- U+2935 (⤵)
"\226\172\133-\226\172\135" .. -- U+2B05-U+2B07 (⬅-⬇)
"\226\172\155" .. -- U+2B1B (⬛)
"\226\172\156" .. -- U+2B1C (⬜)
"\226\173\144" .. -- U+2B50 (⭐)
"\226\173\149" .. -- U+2B55 (⭕)
"\227\128\176" .. -- U+3030 (〰)
"\227\128\189" .. -- U+303D (〽)
"\227\138\151" .. -- U+3297 (㊗)
"\227\138\153" .. -- U+3299 (㊙)
"\240\159\128\132" .. -- U+1F004 (🀄)
"\240\159\131\143" .. -- U+1F0CF (🃏)
"\240\159\133\176" .. -- U+1F170 (🅰)
"\240\159\133\177" .. -- U+1F171 (🅱)
"\240\159\133\190" .. -- U+1F17E (🅾)
"\240\159\133\191" .. -- U+1F17F (🅿)
"\240\159\134\142" .. -- U+1F18E (🆎)
"\240\159\134\145-\240\159\134\154" .. -- U+1F191-U+1F19A (🆑-🆚)
"\240\159\136\129" .. -- U+1F201 (🈁)
"\240\159\136\130" .. -- U+1F202 (🈂)
"\240\159\136\154" .. -- U+1F21A (🈚)
"\240\159\136\175" .. -- U+1F22F (🈯)
"\240\159\136\178-\240\159\136\186" .. -- U+1F232-U+1F23A (🈲-🈺)
"\240\159\137\144" .. -- U+1F250 (🉐)
"\240\159\137\145" .. -- U+1F251 (🉑)
"\240\159\140\128-\240\159\153\143" .. -- U+1F300-U+1F64F (🌀-🙏)
"\240\159\154\128-\240\159\155\151" .. -- U+1F680-U+1F6D7 (🚀-🛗)
"\240\159\155\156-\240\159\155\172" .. -- U+1F6DC-U+1F6EC (🛜-🛬)
"\240\159\155\176-\240\159\155\188" .. -- U+1F6F0-U+1F6FC (🛰-🛼)
"\240\159\159\160-\240\159\159\171" .. -- U+1F7E0-U+1F7EB (🟠-🟫)
"\240\159\159\176" .. -- U+1F7F0 (🟰)
"\240\159\164\140-\240\159\169\147" .. -- U+1F90C-U+1FA53 (🤌-🩓)
"\240\159\169\160-\240\159\169\173" .. -- U+1FA60-U+1FA6D (🩠-🩭)
"\240\159\169\176-\240\159\169\188" .. -- U+1FA70-U+1FA7C (🩰-🩼)
"\240\159\170\128-\240\159\170\137" .. -- U+1FA80-U+1FA89 (🪀-)
"\240\159\170\143-\240\159\171\134" .. -- U+1FA8F-U+1FAC6 (-)
"\240\159\171\142-\240\159\171\156" .. -- U+1FACE-U+1FADC (🫎-)
"\240\159\171\159-\240\159\171\169" .. -- U+1FADF-U+1FAE9 (-)
"\240\159\171\176-\240\159\171\184" -- U+1FAF0-U+1FAF8 (🫰-🫸)
local unsupported_characters
local function get_unsupported_characters()
unsupported_characters, get_unsupported_characters = {}, nil
for k, v in pairs(load_data("Module:links/data").unsupported_characters) do
unsupported_characters[v] = k
end
return unsupported_characters
end
-- The list of unsupported titles and invert it (so the keys are pagenames and values are canonical titles).
local unsupported_titles
local function get_unsupported_titles()
unsupported_titles, get_unsupported_titles = {}, nil
for k, v in pairs(load_data("Module:links/data").unsupported_titles) do
unsupported_titles[v] = k
end
return unsupported_titles
end
-- To save on memory, we only cache names with either non-ASCII characters in them or ASCII characters to be removed or
-- transformed (apostrophe, double quote, hyphen).
local L2_sort_key_cache = {}
function export.get_L2_sort_key(L2)
if L2 == "Translingual" then
return "\1"
elseif L2 == "English" then
return "\2"
elseif match(L2, "^[%z\1-\b\14-!#-&(-,.-\127]+$") then
return L2
end
local sort_key = L2_sort_key_cache[L2]
if sort_key then
return sort_key
end
sort_key = toNFC(ugsub(ugsub(toNFD(L2), "[" .. comb_chars_all .. "'\"ʻʼ]+", ""), "[%s%-]+", " "))
L2_sort_key_cache[L2] = sort_key
return sort_key
end
--[==[
Given a pagename (or {nil} for the current page), create and return a data structure describing the page. The returned
object includes the following fields:
* `comb_chars`: A table containing various Lua character class patterns for different types of combined characters
(those that decompose into multiple characters in the NFD decomposition). The patterns are meant to be used with
{mw.ustring.find()}. The keys are:
** `single`: Single combining characters (character + diacritic), without surrounding brackets;
** `double`: Double combining characters (character + diacritic + character), without surrounding brackets;
** `vs`: Variation selectors, without surrounding brackets;
** `all`: Concatenation of `single` + `double` + `vs`, without surrounding brackets;
** `diacritics_single`: Like `single` but with surrounding brackets;
** `diacritics_double`: Like `double` but with surrounding brackets;
** `diacritics_all`: Like `all` but with surrounding brackets;
** `combined_single`: Lua pattern for matching a spacing character followed by one or more single combining characters;
** `combined_double`: Lua pattern for matching a combination of two spacing characters separated by one or more double
combining characters, possibly also with single combining characters;
* `emoji_pattern`: A Lua character class pattern (including surrounding brackets) that matches emojis. Meant to be used
with {mw.ustring.find()}.
* `L2_list`: Ordered list of L2 headings on the page, with the extra key `n` that gives the length of the list.
* `L2_sections`: Lookup table of L2 headings on the page, where the key is the section number assigned by the preprocessor, and the value is the L2 heading name. Once an invocation has got its actual section number from get_current_L2 in [[Module:pages]], it can use this table to determine its parent L2. TODO: We could expand this to include subsections, to check POS headings are correct etc.
* `unsupported_titles`: Map from pagenames to canonical titles for unsupported-title pages.
* `namespace`: Namespace of the pagename.
* `ns`: Namespace table for the page from mw.site.namespaces (TODO: merge with `namespace` above).
* `full_raw_pagename`: Full version of the '''RAW''' pagename (i.e. unsupported-title pages aren't canonicalized);
including the namespace and the base (portion before the slash).
* `pagename`: Canonicalized subpage portion of the pagename (unsupported-title pages are canonicalized).
* `pagename_with_base`: Same as `pagename` in the main namespace; otherwise, the whole pagename without the namespace.
* `decompose_pagename`: Equivalent of `pagename` in NFD decomposition.
* `pagename_len`: Length of `pagename` in Unicode chars, where combinations of spacing character + decomposed diacritic
are treated as single characters.
* `explode_pagename`: Set of characters found in `pagename`. The keys are characters (where combinations of spacing
character + decomposed diacritic are treated as single characters).
* `encoded_pagename`: FIXME: Document me.
* `pagename_defaultsort`: FIXME: Document me.
* `raw_defaultsort`: FIXME: Document me.
* `wikitext_topic_cat`: FIXME: Document me.
* `wikitext_langname_cat`: FIXME: Document me.
`no_fetch_content` says to not fetch and parse the content or set a DEFAULTSORT sort key, in order to save time on
test and documentation pages that have lots of template invocations that set `|pagename=`. It turns out nearly all the
time of this function is contained in the line `frame:callParserFunction("DEFAULTSORT", data.pagename_defaultsort)`,
so we skip it on test and documentation pages where it accomplishes nothing in any case.
]==]
function export.process_page(pagename, no_fetch_content)
local data = {
comb_chars = comb_chars,
emoji_pattern = "[" .. emoji_chars .. "]",
unsupported_titles = unsupported_titles or get_unsupported_titles()
}
local cats = {}
data.cats = cats
-- We cannot store `raw_title` in `data` because it contains a metatable.
local raw_title
local function bad_pagename()
if not pagename then
error("Internal error: Something wrong, `data.pagename` not specified but current title contains illegal characters")
else
error(format("Bad value for `data.pagename`: '%s', which must not contain illegal characters", pagename))
end
end
if pagename then -- for testing, doc pages, etc.
raw_title = new_title(pagename)
if not raw_title then
bad_pagename()
end
else
raw_title = mw.title.getCurrentTitle()
end
local nsText = raw_title.nsText
local namespace_is_reconstruction = nsText == "Reconstruction"
data.namespace = nsText
data.ns = mw.site.namespaces[raw_title.namespace]
local full_raw_pagename = raw_title.fullText
data.full_raw_pagename = full_raw_pagename
local frame = mw.getCurrentFrame()
-- WARNING: `content` may be nil, e.g. if we're substing a template like {{ja-new}} on a not-yet-created page
-- or if the module specifies the subpage as `data.pagename` (which many modules do) and we're in an Appendix
-- or other non-mainspace page. We used to make the latter an error but there are too many modules that do it,
-- and substing on a nonexistent page is totally legit, and we don't actually need to be able to access the
-- content of the page.
local content = not no_fetch_content and raw_title:getContent() or nil
-- Get the pagename.
pagename = physical_to_logical_pagename_if_mammoth(raw_title)
pagename = gsub(pagename, "^Unsupported titles/(.+)", function(m)
insert(cats, "Unsupported titles")
local title = (unsupported_titles or get_unsupported_titles())[m]
if title then
return title
end
-- Substitute pairs of "`". Those not used for escaping should be escaped as "`grave`", but might not be,
-- so if a pair don't form a match, the closing "`" should become the opening "`" of the next match attempt.
-- This has to be done manually, instead of using gsub.
local open_pos = find(m, "`")
if not open_pos then
return m
end
title = {sub(m, 1, open_pos - 1)}
while true do
local close_pos = find(m, "`", open_pos + 1)
if not close_pos then
-- Add "`" plus any remaining characters.
insert(title, sub(m, open_pos))
break
end
local escape = sub(m, open_pos, close_pos)
local ch = (unsupported_characters or get_unsupported_characters())[escape]
-- Match found, so substitute the character and move to the first "`" after the match if found, or
-- otherwise return.
if ch then
insert(title, ch)
local nxt_pos = close_pos + 1
open_pos = find(m, "`", nxt_pos)
-- Add any characters between the match and the next "`" or end.
if open_pos then
insert(title, sub(m, nxt_pos, open_pos - 1))
else
insert(title, sub(m, nxt_pos))
break
end
-- Match not found, so make the closing "`" the opening "`" of the next attempt.
else
-- Add the failed match, except for the closing "`".
insert(title, sub(m, open_pos, close_pos - 1))
open_pos = close_pos
end
end
return concat(title)
end)
-- Save pagename, as the local variable will be destructively modified.
data.pagename = pagename
if nsText == "" then
data.pagename_with_base = pagename
else
data.pagename_with_base = raw_title.text
end
-- Decompose the pagename in Unicode normalization form D.
data.decompose_pagename = toNFD(pagename)
-- Explode the current page name into a character table, taking decomposed combining characters into account.
local explode_pagename = {}
local pagename_len = 0
local function explode(char)
explode_pagename[char] = true
pagename_len = pagename_len + 1
return ""
end
pagename = ugsub(pagename, comb_chars.combined_double, explode)
pagename = gsub(ugsub(pagename, comb_chars.combined_single, explode), ".[\128-\191]*", explode)
data.explode_pagename = explode_pagename
data.pagename_len = pagename_len
-- Generate DEFAULTSORT.
data.encoded_pagename = encode_entities(data.pagename)
data.pagename_defaultsort = get_lang("mul"):makeSortKey(data.encoded_pagename)
if not no_fetch_content then
frame:callParserFunction("DEFAULTSORT", data.pagename_defaultsort)
end
data.raw_defaultsort = uupper(raw_title.text)
-- Make `L2_list` and `L2_sections`, note raw wikitext use of {{DEFAULTSORT:}} and {{DISPLAYTITLE:}}, then add categories if any unwanted L1 headings are found, the L2 headings are in the wrong order, or they don't match a canonical language name.
-- Note: HTML comments shouldn't be removed from `content` until after this step, as they can affect the result.
do
local L2_list, L2_list_len, L2_sections = {}, 0, {}
local prev, rc
local new_cats, L2_wrong_order = {}
local function handle_heading(heading)
local level = heading.level
if level > 2 then
return
end
local name = heading:get_name()
-- heading:get_name() will return nil if there are any newline characters in the preprocessed heading name (e.g. from an expanded template). In such cases, the preprocessor section count still increments (since it's calculated pre-expansion), but the heading will fail, so the L2 count shouldn't be incremented.
if name == nil then
return
end
L2_list_len = L2_list_len + 1
L2_list[L2_list_len] = name
L2_sections[heading.section] = name
-- Also add any L1s, since they terminate the preceding L2, but add a maintenance category since it's probably a mistake.
if level == 1 then
new_cats["Pages with unwanted L1 headings"] = true
end
-- Check the heading is in the right order.
-- FIXME: we need a more sophisticated sorting method which handles non-diacritic special characters (e.g. Magɨ).
if prev and not (
L2_wrong_order or
string_compare(export.get_L2_sort_key(prev), export.get_L2_sort_key(name))
) then
new_cats["Pages with language headings in the wrong order"] = true
L2_wrong_order = true
end
-- Check it's a canonical language name.
if not (langnames or get_langnames())[name] then
new_cats["Pages with nonstandard language headings"] = true
end
prev = name
end
local function handle_template(template)
-- Turn off redirect checking except in the Reconstruction namespace because the rc flag is only
-- used in the Reconstruction namespace and the other names are parser functions, which AFAIK can't
-- be redirected to.
local name = template:get_name(nil, not namespace_is_reconstruction and "no_redirect" or nil)
if name == "DEFAULTSORT:" then
new_cats["Pages with DEFAULTSORT conflicts"] = true
elseif name == "DISPLAYTITLE:" then
new_cats["Pages with DISPLAYTITLE conflicts"] = true
elseif name == "reconstructed" then
rc = true
end
end
if content then
for node in parse(content):iterate_nodes() do
local node_class = class_else_type(node)
if node_class == "heading" then
handle_heading(node)
elseif node_class == "template" then
handle_template(node)
elseif node_class == "parameter" then
new_cats["Pages with raw triple-brace template parameters"] = true
end
end
end
L2_list.n = L2_list_len
data.L2_list = L2_list
data.L2_sections = L2_sections
insert(cats, get_category("Pages with entries"))
insert(cats, get_category(format("Pages with %s entr%s", L2_list_len, L2_list_len == 1 and "y" or "ies")))
for cat in pairs(new_cats) do
insert(cats, get_category(cat))
end
if namespace_is_reconstruction and not rc then
local langname = match(full_raw_pagename, "^Reconstruction:([^/]+)/.")
if langname then
insert(cats, get_category(langname .. " entries missing Template:reconstructed"))
end
end
end
------ 4. Parse page for maintenance categories. ------
-- Use of tab characters.
if content and find(content, "\t", 1, true) then
insert(cats, get_category("Pages with tab characters"))
end
-- Unencoded character(s) in title.
local IDS = list_to_set{"⿰", "⿱", "⿲", "⿳", "⿴", "⿵", "⿶", "⿷", "⿸", "⿹", "⿺", "⿻", "", "", "", "", ""}
for char in pairs(explode_pagename) do
if IDS[char] and char ~= data.pagename then
insert(cats, "Terms containing unencoded characters")
break
end
end
-- Raw wikitext use of a topic or langname category. Also check if any raw sortkeys have been used.
do
local wikitext_topic_cat = {}
local wikitext_langname_cat = {}
local raw_sortkey
-- If a raw sortkey has been found, add it to the relevant table.
-- If there's no table (or the index is just `true`), create one first.
local function add_cat_table(t, lang, sortkey)
local t_lang = t[lang]
if not sortkey then
if not t_lang then
t[lang] = true
end
return
elseif t_lang == true or not t_lang then
t_lang = {}
t[lang] = t_lang
end
t_lang[uupper(decode_entities(sortkey))] = true
end
local function process_category(content, cat, colon, nxt)
local pipe = find(cat, "|", colon + 1, true)
-- Categories cannot end "|]]".
if pipe == #cat then
return
end
local title = new_title(pipe and sub(cat, 1, pipe - 1) or cat)
if not (title and title.namespace == 14) then
return
end
-- Get the sortkey (if any), then canonicalize category title.
local sortkey = pipe and sub(cat, pipe + 1) or nil
cat = title.text
if sortkey then
raw_sortkey = true
-- If the sortkey contains "[", the first "]" of a final "]]]" is treated as part of the sortkey.
if find(sortkey, "[", 1, true) and sub(content, nxt, nxt) == "]" then
sortkey = sortkey .. "]"
end
end
local code = match(cat, "^([%w%-.]+):")
if code then
add_cat_table(wikitext_topic_cat, code, sortkey)
return
end
-- Split by word.
cat = split(cat, " ", true, true)
-- Formerly we looked for the language name anywhere in the category. This is simply wrong
-- because there are no categories like 'Alsatian French lemmas' (only L2 languages
-- have langname categories), but doing it this way wrongly catches things like [[Category:Shapsug Adyghe]]
-- in [[Category:Adyghe entries with language name categories using raw markup]].
local n = #cat - 1
if n <= 0 then
return
end
-- Go from longest to shortest and stop once we've found a language name. Going from shortest
-- to longest or not stopping after a match risks falsely matching (e.g.) German Low German
-- categories as German.
repeat
local name = concat(cat, " ", 1, n)
if (langnames or get_langnames())[name] then
add_cat_table(wikitext_langname_cat, name, sortkey)
return
end
n = n - 1
until n == 0
end
if content then
-- Remove comments, then iterate over category links.
content = remove_comments(content, "BOTH")
local head = find(content, "[[", 1, true)
while head do
local close = find(content, "]]", head + 2, true)
if not close then
break
end
-- Make sure there are no intervening "[[" between head and close.
local open = find(content, "[[", head + 2, true)
while open and open < close do
head = open
open = find(content, "[[", head + 2, true)
end
local cat = sub(content, head + 2, close - 1)
-- Locate the colon, and weed out most unwanted links. "[ _\128-\244]*" catches valid whitespace, and ensures any category links using the colon trick are ignored. We match all non-ASCII characters, as there could be multibyte spaces, and mw.title.new will filter out any remaining false-positives; this is a lot faster than running mw.title.new on every link.
local colon = match(cat, "^[ _\128-\244]*[Cc][Aa][Tt][EeGgOoRrYy _\128-\244]*():")
if colon then
process_category(content, cat, colon, close + 2)
end
head = open
end
end
data.wikitext_topic_cat = wikitext_topic_cat
data.wikitext_langname_cat = wikitext_langname_cat
if raw_sortkey then
insert(cats, get_category("Pages with raw sortkeys"))
end
end
return data
end
return export
7cubvdhwb3risefslzp6kxwcrr21b48
Module:form of
828
7987
54919
54733
2026-09-29T00:01:29Z
Deadend0914
7211
54919
Scribunto
text/plain
local export = {}
export.force_cat = false -- for testing; set to true to display categories even on non-mainspace pages
local debug_track_module = "Module:debug/track"
local etymology_module = "Module:etymology"
local form_of_cats_module = "Module:form of/cats"
local form_of_data_module = "Module:form of/data"
local form_of_data1_module = "Module:form of/data/1"
local form_of_data2_module = "Module:form of/data/2"
local form_of_functions_module = "Module:form of/functions"
local form_of_lang_data_module_prefix = "Module:form of/lang-data/"
local function_module = "Module:fun"
local headword_data_module = "Module:headword/data"
local json_module = "Module:JSON"
local labels_module = "Module:labels"
local links_module = "Module:links"
local load_module = "Module:load"
local parse_utilities_module = "Module:parse utilities"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local table_deep_equals_module = "Module:table/deepEquals"
local utilities_module = "Module:utilities"
local anchor_encode = mw.uri.anchorEncode
local concat = table.concat
local dump = mw.dumpObject
local fetch_categories_and_labels -- Defined below.
local format_form_of -- Defined below.
local get_tag_display_form -- Defined below.
local get_tag_set_display_form -- Defined below.
local insert = table.insert
local ipairs = ipairs
local is_link_or_html -- Defined below.
local list_to_text = mw.text.listToText
local lookup_shortcut -- Defined below.
local lookup_tag -- Defined below.
local normalize_tag_set -- Defined below.
local parse_tag_set_properties -- Defined below.
local require = require
local sort = table.sort
local split_tag_set -- Defined below.
local type = type
--[==[
Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==]
local function append(...)
append = require(table_module).append
return append(...)
end
local function contains(...)
contains = require(table_module).contains
return contains(...)
end
local function debug_track(...)
debug_track = require(debug_track_module)
return debug_track(...)
end
local function deep_copy(...)
deep_copy = require(table_module).deepCopy
return deep_copy(...)
end
local function deep_equals(...)
deep_equals = require(table_deep_equals_module)
return deep_equals(...)
end
local function extend(...)
extend = require(table_module).extend
return extend(...)
end
local function format_categories(...)
format_categories = require(utilities_module).format_categories
return format_categories(...)
end
local function full_link(...)
full_link = require(links_module).full_link
return full_link(...)
end
local function insert_if_not(...)
insert_if_not = require(table_module).insertIfNot
return insert_if_not(...)
end
local function is_subset_list(...)
is_subset_list = require(table_module).isSubsetList
return is_subset_list(...)
end
local function iterate_from(...)
iterate_from = require(function_module).iterateFrom
return iterate_from(...)
end
local function join_multiparts(...)
join_multiparts = require(form_of_functions_module).join_multiparts
return join_multiparts(...)
end
local function load_data(...)
load_data = require(load_module).load_data
return load_data(...)
end
local function parse_inline_modifiers(...)
parse_inline_modifiers = require(parse_utilities_module).parse_inline_modifiers
return parse_inline_modifiers(...)
end
local function remove_links(...)
remove_links = require(links_module).remove_links
return remove_links(...)
end
local function safe_load_data(...)
safe_load_data = require(load_module).safe_load_data
return safe_load_data(...)
end
local function safe_require(...)
safe_require = require(load_module).safe_require
return safe_require(...)
end
local function serial_comma_join(...)
serial_comma_join = require(table_module).serialCommaJoin
return serial_comma_join(...)
end
local function shallow_copy(...)
shallow_copy = require(table_module).shallowCopy
return shallow_copy(...)
end
local function show_labels(...)
show_labels = require(labels_module).show_labels
return show_labels(...)
end
local function slice(...)
slice = require(table_module).slice
return slice(...)
end
local function split(...)
split = require(string_utilities_module).split
return split(...)
end
local function ucfirst(...)
ucfirst = require(string_utilities_module).ucfirst
return ucfirst(...)
end
--[==[
Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==]
local cat_functions
local function get_cat_functions()
cat_functions, get_cat_functions = require(form_of_functions_module).cat_functions, nil
return cat_functions
end
local default_pagename
local function get_default_pagename()
default_pagename, get_default_pagename = load_data(headword_data_module).pagename, nil
return default_pagename
end
local display_handlers
local function get_display_handlers()
display_handlers, get_display_handlers = require(form_of_functions_module).display_handlers, nil
return display_handlers
end
local m_cats_data
local function get_m_cats_data()
m_cats_data, get_m_cats_data = load_data(form_of_cats_module), nil
return m_cats_data
end
local m_data
local function get_m_data()
-- Needs require.
m_data, get_m_data = require(form_of_data_module), nil
return m_data
end
local m_data1
local function get_m_data1()
m_data1, get_m_data1 = load_data(form_of_data1_module), nil
return m_data1
end
local m_data2
local function get_m_data2()
m_data2, get_m_data2 = load_data(form_of_data2_module), nil
return m_data2
end
local m_pos_data
local function get_m_pos_data()
m_pos_data, get_m_pos_data = load_data(headword_data_module).pos_aliases, nil
return m_pos_data
end
--[==[ intro:
This module implements the underlying processing of {{tl|form of}}, {{tl|inflection of}} and specific variants such as
{{tl|past participle of}} and {{tl|alternative spelling of}}. Most of the logic in this file is to handle tags in
{{tl|inflection of}}. Other related files:
* [[Module:form of/templates]] contains the majority of the logic that implements the templates themselves.
* [[Module:form of/data/1]] is a data-only file containing information on the more common inflection tags, listing the
tags, their shortcuts, the category they belong to (tense-aspect, case, gender, voice-valence, etc.), the appropriate
glossary link and the wikidata ID.
* [[Module:form of/data/2]] is a data-only file containing information on the less common inflection tags, in the same
format as [[Module:form of/data/1]].
* [[Module:form of/lang-data/LANGCODE]] is a data-only file containing information on the language-specific inflection
tags for the language with code LANGCODE, in the same format as [[Module:form of/data/1]]. Language-specific tags
override general tags.
* [[Module:form of/cats]] is a data-only file listing the language-specific categories that are added when the
appropriate combinations of tags are seen for a given language.
* [[Module:form of/functions]] contains functions for use with [[Module:form of/data/1]] and [[Module:form of/cats]].
They are contained in this module because data-only modules can't contain code. The functions in this file are of two
types:
*# Display handlers allow for customization of the display of multipart tags (see below). Currently there is only
one such handler, for handling multipart person tags such as `1//2//3`.
*# Cat functions allow for more complex categorization logic, and are referred to by name in [[Module:form of/cats]].
Currently no such functions exist.
The following terminology is used in conjunction with {{tl|inflection of}}:
* A ''tag'' is a single grammatical item, as specified in a single numbered parameter of {{tl|inflection of}}. Examples
are `masculine`, `nominative`, or `first-person`. Tags may be abbreviated, e.g. `m` for `masculine`, `nom` for
`nominative`, or `1` for `first-person`. Such abbreviations are called ''aliases'', and some tags have multiple
equivalent aliases (e.g. `p` or `pl` for `plural`). The full, non-abbreviated form of a tag is called its
''canonical form''.
* The ''display form'' of a tag is the way it's displayed to the user. Usually the displayed text of the tag is the same
as its canonical form, and it normally functions as a link to a glossary entry explaining the tag. Usually the link is
to an entry in [[Appendix:Glossary]], but sometimes the tag is linked to an individual dictionary entry or to a
Wikipedia entry. Occasionally, the display text differs from the canonical form of the tag. An example is the tag
`comparative case`, which has the display text read as simply `comparative`. Normally, tags referring to cases don't
have the word "case" in them, but in this case the tag `comparative` was already used as an alias for the tag
`comparative degree`, so the tag was named `comparative case` to avoid clashing. A similar situation occurs with
`adverbial case` vs. the grammar tag `adverbial` (as in `adverbial participle`).
* A ''tag set'' is an ordered list of tags, which together express a single inflection, for example, `1|s|pres|ind`,
which can be expanded to canonical-form tags as `first-person|singular|present|indicative`.
* A ''conjoined tag set'' is a tag set that consists of multiple individual tag sets separated by a semicolon, e.g.
`1|s|pres|ind|;|2|s|imp`, which specifies two tag sets, `1|s|pres|ind` as above and `2|s|imp` (in canonical form,
`second-person|singular|imperative`). Multiple tag sets specified in a single call to {{tl|inflection of}} are
specified in this fashion. Conjoined tag sets can also occur in list-tag shortcuts.
* A ''multipart tag'' is a tag that embeds multiple tags within it, such as `f//n` or `nom//acc//voc`. These are used in
the case of [[syncretism]], when the same form applies to multiple inflections. Examples are the Spanish present
subjunctive, where the first-person and third-person singular have the same form (e.g. {{m|es|siga}} from
{{m|es|seguir|t=to follow}}), or Latin third-declension adjectives, where the dative and ablative plural of all
genders have the same form (e.g. {{m|la|omnibus}} from {{m|la|omnis|t=all}}). These would be expressed respectively as
`1//3|s|pres|sub` and `dat//abl|m//f//n|p`, where the use of the multipart tag compactly encodes the syncretism and
avoids the need to individually list out all of the inflections. Multipart tags currently display as a list separated
by a slash, e.g. ''dative/ablative'' or ''masculine/feminine/neuter'' where each individual word is linked
appropriately. As a special case, multipart tags involving persons display specially; for example, the multipart tag
`1//2//3` displays as ''first-, second- and third-person'', with the word "person" occurring only once.
* A ''two-level multipart tag'' is a special type of multipart tag that joins two or more tag sets instead of joining
individual tags. The tags within the tag set are joined by a colon, e.g. `1:s//3:p`, which is displayed as
''first-person singular and third-person plural'', e.g. for use with the form {{m|grc|μέλλον}} of the verb
{{m|grc|μέλλω|t=to intend}}, which uses the tag set `1:s//3:p|impf|actv|indc|unaugmented` to express the syncretism
between the first singular and third plural forms of the imperfect active indicative unaugmented conjugation.
Two-level multipart tags should be used sparingly; if in doubt, list out the inflections separately. [FIXME: Make
two-level multipart tags obsolete.]
* A ''shortcut'' is a tag that expands to any type of tag described above, or to any type of tag set described above.
Aliases are a particular type of shortcut whose expansion is a single non-multipart tag.
* A ''multipart shortcut'' is a shortcut that expands into a multipart tag, for example `123`, which expands to the
multipart tag `1//2//3`. Only the most common such combinations exist as shortcuts.
* A ''list shortcut'' is a special type of shortcut that expands to a list of tags instead of a single tag. For example,
the shortcut `1s` expands to `1|s` (first-person singular). Only the most common such combinations exist as shortcuts.
* A ''conjoined shortcut'' is a special type of list shortcut that consists of a conjoined tag set (multiple logical tag
sets). For example, the English language-specific shortcut `ed-form` expands to `spast|;|past|part`, expressing the
common syncretism between simple past and past participle in English (and in this case, `spast` is itself a list
shortcut that expands to `simple|past`).]==]
-- Add tracking category for PAGE when called from {{inflection of}} or
-- similar TEMPLATE. The tracking category linked to is
-- [[Wiktionary:Tracking/inflection of/PAGE]].
local function track(page)
debug_track("inflection of/" ..
-- avoid including links in pages (may cause error)
page:gsub("%[", "("):gsub("%]", ")"):gsub("|", "!")
)
end
local function wrap_in_span(text, classes)
if classes then
return ("<span class='%s'>%s</span>"):format(classes, text)
else
return text
end
end
local function show_linked_term(data)
local termobj, face, span_classes, ok_to_destructively_modify, overall_lang, text_classes =
data.termobj, data.face, data.span_classes, data.ok_to_destructively_modify, data.overall_lang,
data.text_classes
local need_to_copy, pretext_lang
local categories = {}
if overall_lang and overall_lang:getCode() ~= termobj.lang:getCode() then
local lang_display
lang_display, categories = require(etymology_module).insert_source_cat_get_display {
lang = data.overall_lang,
source = termobj.lang,
}
pretext_lang = wrap_in_span(lang_display .. " ", text_classes)
end
local has_decoration = termobj.q or termobj.qq or termobj.a or termobj.aa or termobj.l or termobj.ll or termobj.refs
-- `show_decorations` is set by parse_{term,list}_with_inline_modifiers_and_separate_params in
-- [[Module:parameter utilities]], called in [[Module:form of/templates]], so in most circumstances
-- it's already set and we don't need to do a shallow-copy to set it.
local need_to_set_show_decorations = has_decoration and not termobj.show_decorations
need_to_copy = not ok_to_destructively_modify and (pretext_lang or need_to_set_show_decorations)
if need_to_copy then
termobj = shallow_copy(termobj)
end
if pretext_lang then
termobj.pretext = pretext_lang
end
if need_to_set_show_decorations then
termobj.show_decorations = true
end
return wrap_in_span(full_link(termobj, face), span_classes), categories
end
--[==[
Lowest-level implementation of form-of templates, including the general {{tl|form of}} as well as those that deal with
inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and
specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with
the following fields:
* `.lang`: Overall language of the form-of template. If specified, any lemmas, enclitics or base lemmas that are of a
different language will have that language displayed before the term in question.
* `.text`: Text to insert before the lemmas. Wrapped in the value of `.text_classes`, or its default; see below.
* `.lemmas`: List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed
directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the
language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()}
and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively,
`.lemmas` can be a string, which is displayed directly, or omitted, to show no lemma links and omit the connecting
text.
* `.lemma_face`: "Face" to use when displaying the lemma objects. Usually should be set to {"term"}.
* `.conj`: Conjunction or separator to use when joining multiple lemma objects. If {nil}, defaults to {"and"}. If this
has the value {false}, the lemmas are preceded with the `.separator` field in each lemma.
* `.enclitics`: List of enclitics to display after the lemmas, in parens.
* `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}.
* `.base_lemmas`: List of base lemmas to display after the lemmas, in the case where the lemmas in `.lemmas` are
themselves forms of another lemma (the base lemma), e.g. a comparative, superlative or participle. Each object is of
the form { { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, conj = "CONJ" }} where PARAM_OBJ describes
the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas);
LEMMA_OBJ is an object suitable to be passed to {full_link()} in [[Module:links]]; and CONJ is the conjunction to
join multiple lemmas with, defaulting to {"and"}. PARAM_OBJ is of the format
{ { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{tl|inflection of}}
etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as
{ {"comd"}} or { {"past", "part"}}.
* `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is
{"form-of-definition use-with-mention"}. Use `false` for no wrapping.
* `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}.
Use `false` for no wrapping.
* `.posttext`: Additional text to display after the lemma links.
* `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified
in-place to save memory; otherwise they will be copied before modifying.
Returns two values, the formatted string and any categories to add the page to (which will arise if `.lang` is
specified and a language other than `.lang` is given in one of the lemmas in `.lemmas` or enclitics in `.enclitics`).
]==]
function export.format_form_of(data)
if type(data) ~= "table" then
error("Internal error: First argument must now be a table of arguments")
end
local text_classes = data.text_classes
if text_classes == nil and not data.nowrap then
text_classes = "form-of-definition use-with-mention"
end
local lemma_classes = data.lemma_classes
if lemma_classes == nil then
lemma_classes = "form-of-definition-link"
end
local parts = {}
if text_classes then
insert(parts, "<span class='" .. text_classes .. "'>")
end
insert(parts, data.text)
if data.text ~= "" and data.lemmas then
insert(parts, " ")
end
local categories = {}
if data.lemmas then
if type(data.lemmas) == "string" then
insert(parts, wrap_in_span(data.lemmas, lemma_classes))
else
local formatted_terms = {}
for _, lemma in ipairs(data.lemmas) do
local linked_term, this_categories = show_linked_term {
termobj = lemma,
face = data.lemma_face,
span_classes = lemma_classes,
ok_to_destructively_modify = data.ok_to_destructively_modify,
overall_lang = data.lang,
text_classes = text_classes
}
if this_categories[1] then
extend(categories, this_categories)
end
if data.conj == false and lemma.separator then
insert(formatted_terms, lemma.separator)
end
insert(formatted_terms, linked_term)
end
if data.conj == false then
insert(parts, concat(formatted_terms))
else
insert(parts, serial_comma_join(formatted_terms, {conj = data.conj or "and"}))
end
end
if data.lit then
insert(parts, ", literally " .. require(links_module).mark(data.lit, "gloss"))
end
end
if data.enclitics and #data.enclitics > 0 then
-- The outer parens need to be outside of the text_classes span so they show in upright instead of italic, or
-- they will clash with upright parens generated by link annotations such as transliterations and pos=.
if text_classes then
insert(parts, "</span>")
end
local formatted_terms = {}
for _, enclitic in ipairs(data.enclitics) do
-- FIXME, should we have separate clitic face and/or classes?
local linked_term, this_categories = show_linked_term {
termobj = enclitic,
face = data.lemma_face,
span_classes = lemma_classes,
ok_to_destructively_modify = data.ok_to_destructively_modify,
overall_lang = data.lang,
text_classes = text_classes
}
if this_categories[1] then
extend(categories, this_categories)
end
insert(formatted_terms, linked_term)
end
insert(parts, " (")
insert(parts, wrap_in_span("with enclitic" .. (#data.enclitics > 1 and "s" or "") .. " ", text_classes))
insert(parts, serial_comma_join(formatted_terms, {conj = data.enclitic_conj or "and"}))
insert(parts, ")")
if text_classes then
insert(parts, "<span class='" .. text_classes .. "'>")
end
end
if data.base_lemmas and #data.base_lemmas > 0 then
for _, base_lemma in ipairs(data.base_lemmas) do
insert(parts, ", the ")
if text_classes then
insert(parts, "</span>")
end
insert(parts, (export.tagged_inflections {
lang = data.lang or base_lemma.lemmas[1].lang,
tags = base_lemma.paramobj.tags,
lemmas = base_lemma.lemmas,
conj = base_lemma.conj or "and",
lemma_face = data.lemma_face,
no_format_categories = true,
nocat = true,
text_classes = data.text_classes,
ok_to_destructively_modify = data.ok_to_destructively_modify,
}))
if text_classes then
insert(parts, "<span class='" .. text_classes .. "'>")
end
end
end
-- FIXME, should posttext go before enclitics? If so we need to have separate handling for the
-- final colon when there are multiple tag sets in tagged_inflections().
if data.posttext then
insert(parts, data.posttext)
end
if text_classes then
insert(parts, "</span>")
end
return concat(parts), categories
end
format_form_of = export.format_form_of
--[==[
Return true if `tag` contains an internal link or HTML.]==]
function export.is_link_or_html(tag)
return tag:find("[[", nil, true) or tag:find("|", nil, true) or tag:find("<", nil, true)
end
is_link_or_html = export.is_link_or_html
--[==[
Look up a tag (either a shortcut of any sort of a canonical long-form tag) and return its expansion. The expansion
will be a string unless the shortcut is a list-tag shortcut such as `1s`; in that case, the expansion will be a
list. The caller must handle both cases. Only one level of expansion happens; hence, `acc` expands to {"accusative"},
`1s` expands to { {"1", "s"}} (not to { {"first", "singular"}}) and `123` expands to {"1//2//3"}. The expansion will be
the same as the passed-in tag in the following circumstances:
# The tag is `;` (this is special-cased, and no lookup is done).
# The tag is a multipart tag such as `nom//acc` (this is special-cased, and no lookup is done).
# The tag contains a raw link (this is special-cased, and no lookup is done).
# The tag contains HTML (this is special-cased, and no lookup is done).
# The tag is already a canonical long-form tag.
# The tag is unrecognized.
This function first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in
[[Module:form of/data/1]] (which includes more common non-lang-specific tags) and finally (only if the tag is not
recognized as a shortcut or canonical tag, and is not of types 1-4 above) in [[Module:form of/data/2]].
If the expansion is a string and is different from the tag, track it if `do_track` is true.]==]
function export.lookup_shortcut(tag, lang, do_track)
-- If there is HTML or a link in the tag, return it directly; don't try
-- to look it up, which will fail.
if tag == ";" or tag:find("//", nil, true) or is_link_or_html(tag) then
return tag
end
local expansion
while lang do
local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode())
-- If this is a canonical long-form tag, just return it, and don't check for shortcuts. This is an
-- optimization; see below.
if langdata then
if langdata.tags[tag] then
return tag
end
expansion = langdata.shortcuts[tag]
if expansion then
break
end
end
-- If the language has a parent (i.e. a superordinate variety), try again with that.
lang = lang:getParent()
end
if not expansion then
-- If this is a canonical long-form tag, just return it, and don't check for shortcuts (which will cause
-- [[Module:form of/data/2]] to be loaded, because there won't be a shortcut entry in [[Module:form of/data/1]] --
-- or, for that matter, in [[Module:form of/data/2]]). This is an optimization; the code will still work without
-- it, but will use up more memory.
if (m_data1 or get_m_data1()).tags[tag] then
return tag
end
expansion = m_data1.shortcuts[tag]
end
if not expansion then
expansion = (m_data2 or get_m_data2()).shortcuts[tag]
end
if not expansion then
return tag
end
-- Maybe track the expansion if it's not the same as the raw tag.
if do_track and expansion ~= tag and type(expansion) == "string" then
track("tag/" .. tag)
end
return expansion
end
lookup_shortcut = export.lookup_shortcut
--[==[
Look up a normalized/canonicalized tag and return the data object associated with it. If the tag isn't found, return
nil. This first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in
[[Module:form of/data/1]] (which includes more common non-lang-specific tags) and then finally in
[[Module:form of/data/2]].]==]
function export.lookup_tag(tag, lang)
while lang do
local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode())
local tag = langdata and langdata.tags[tag]
if tag then
return tag
end
-- If the language has a parent (i.e. a superordinate variety), try again with that.
lang = lang:getParent()
end
local tagobj = (m_data1 or get_m_data1()).tags[tag]
if tagobj then
return tagobj
end
local tagobj2 = (m_data2 or get_m_data2()).tags[tag]
if tagobj2 then
return tagobj2
end
return nil
end
lookup_tag = export.lookup_tag
-- Normalize a single tag, which may be a shortcut but should not be a multipart tag, a multipart shortcut or a list
-- shortcut.
local function normalize_single_tag(tag, lang, do_track)
local expansion = lookup_shortcut(tag, lang, do_track)
if type(expansion) ~= "string" then
error("Tag '" .. tag .. "' is a list shortcut, which is not allowed here")
end
tag = expansion
if not lookup_tag(tag, lang) and do_track then
-- If after all expansions and normalizations we don't recognize the canonical tag, track it.
track("unknown")
track("unknown/" .. tag)
end
return tag
end
--[=[
Normalize a component of a multipart tag. This should not have any // in it, but may join multiple individual tags with
a colon, and may be a single list-tag shortcut, which is treated as if colon-separated. The return value may be a list
of tags.
]=]
local function normalize_multipart_component(tag, lang, do_track)
-- If there is HTML or a link in the tag, don't try to split on colon. A colon may legitimately occur in either one,
-- and we don't want these things parsed. Note that we don't do this check before splitting on //, which we don't
-- expect to occur in links or HTML; see comment in normalize_tag().
if is_link_or_html(tag) then
return tag
end
local components = split(tag, ":", true)
if #components == 1 then
-- We allow list-tag shortcuts inside of multipart tags, e.g.
-- '1s//3p'. Check for this now.
tag = lookup_shortcut(tag, lang, do_track)
if type(tag) == "table" then
-- Temporary tracking as we will disallow this.
track("list-tag-inside-of-multipart")
-- We found a list-tag shortcut; treat as if colon-separated.
components = tag
else
return normalize_single_tag(tag, lang, do_track)
end
end
local normtags = {}
-- Temporary tracking as we will disallow this.
track("two-level-multipart")
for _, component in ipairs(components) do
if do_track then
-- There are multiple components; track each of the individual
-- raw tags.
track("tag/" .. component)
end
insert(normtags, normalize_single_tag(component, lang, do_track))
end
return normtags
end
--[=[
Normalize a single tag. The return value may be a list (in the case of multipart tags), which will contain nested lists
in the case of two-level multipart tags.
]=]
local function normalize_tag(tag, lang, do_track)
-- We don't check for links or HTML before splitting on //, which we don't expect to occur in links or HTML. Doing
-- it this way allows for a tag like '{{lb|grc|Epic}}//{{lb|grc|Ionic}}' to function correctly (the template calls
-- will be expanded before we process the tag, and will contain links and HTML). The only check we do is for a URL,
-- which shouldn't normally occur, but might if the user tries to put an external link into the tag. URL's with //
-- normally have the sequence ://, which should never normally occur when // and : are used in their normal ways.
if tag:find("://", nil, true) then
return tag
end
local split_tags = split(tag, "//", true)
if #split_tags == 1 then
local retval = normalize_multipart_component(tag, lang, do_track)
if type(retval) == "table" then
-- The user gave a tag like '1:s', i.e. with colon but without //. Allow this, but we need to return a
-- nested list.
return {retval}
end
return retval
end
local normtags = {}
for _, single_tag in ipairs(split_tags) do
if do_track then
-- If the tag was a multipart tag, track each of individual raw tags.
track("tag/" .. single_tag)
end
insert(normtags, normalize_multipart_component(single_tag, lang, do_track))
end
return normtags
end
--[==[
Normalize a tag set (a list of tags) into its canonical-form tags. The return value is a list of normalized tag sets
(a list because of there may be conjoined shortcuts among the input tags). A normalized tag set is a list of tag
elements, where each element is either a string (the canonical form of a tag), a list of such strings (in the case of
multipart tags) or a list of lists of such strings (in the case of two-level multipart tags). For example, the multipart
tag `nom//acc//voc` will be represented in canonical form as { {"nominative", "accusative", "vocative"}}, and the
two-level multipart tag `1:s//3:p` will be represented as { {{"first-person", "singular"}, {"third-person", "plural"}}}.
Example 1:
{normalize_tag_set({"nom//acc//voc", "n", "p"})} = { {{{"nominative", "accusative", "vocative"}, "masculine", "plural"}}}
Example 2:
{normalize_tag_set({"ed-form"}, ENGLISH)} = { {{"simple", "past"}, {"past", "participle"}}}
Example 3:
{normalize_tag_set({"archaic", "ed-form"}, ENGLISH)} = { {{"archaic", "simple", "past"}, {"archaic", "past", "participle"}}}]==]
function export.normalize_tag_set(tag_set, lang, do_track)
-- We track usage of shortcuts, normalized forms and (in the case of multipart tags or list tags) intermediate
-- forms. For example, if the tags 1s|mn|gen|indefinite are passed in, we track the following:
-- [[Wiktionary:Tracking/inflection of/tag/1s]]
-- [[Wiktionary:Tracking/inflection of/tag/1]]
-- [[Wiktionary:Tracking/inflection of/tag/s]]
-- [[Wiktionary:Tracking/inflection of/tag/first-person]]
-- [[Wiktionary:Tracking/inflection of/tag/singular]]
-- [[Wiktionary:Tracking/inflection of/tag/mn]]
-- [[Wiktionary:Tracking/inflection of/tag/m//n]]
-- [[Wiktionary:Tracking/inflection of/tag/m]]
-- [[Wiktionary:Tracking/inflection of/tag/n]]
-- [[Wiktionary:Tracking/inflection of/tag/masculine]]
-- [[Wiktionary:Tracking/inflection of/tag/neuter]]
-- [[Wiktionary:Tracking/inflection of/tag/gen]]
-- [[Wiktionary:Tracking/inflection of/tag/genitive]]
-- [[Wiktionary:Tracking/inflection of/tag/indefinite]]
local output_tag_set = {}
local saw_semicolon = false
for _, tag in ipairs(tag_set) do
if do_track then
-- Track the raw tag.
track("tag/" .. tag)
end
-- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list
-- of tags).
tag = lookup_shortcut(tag, lang, do_track)
if type(tag) == "table" then
if contains(tag, ";") then
-- If we saw a conjoined shortcut, we need to use a more general algorithm that can expand a single
-- tag set into multiple.
saw_semicolon = true
break
end
for _, t in ipairs(tag) do
if do_track then
-- If the tag expands to a list of raw tags, track each of those.
track("tag/" .. t)
end
insert(output_tag_set, normalize_tag(t, lang, do_track))
end
else
insert(output_tag_set, normalize_tag(tag, lang, do_track))
end
end
if not saw_semicolon then
return {output_tag_set}
end
-- Use a more general algorithm that handles conjoined shortcuts.
output_tag_set = {}
for i, tag in ipairs(tag_set) do
if do_track then
-- Track the raw tag.
track("tag/" .. tag)
end
-- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list
-- of tags).
tag = lookup_shortcut(tag, lang, do_track)
if type(tag) == "table" then
local output_tag_sets = {}
local shortcut_tag_sets = split_tag_set(tag)
local normalized_shortcut_tag_sets = {}
for _, shortcut_tag_set in ipairs(shortcut_tag_sets) do
extend(normalized_shortcut_tag_sets,
normalize_tag_set(shortcut_tag_set, lang, do_track))
end
local after_tags = slice(tag_set, i + 1)
local normalized_after_tags_sets = normalize_tag_set(after_tags, lang, do_track)
for _, normalized_shortcut_tag_set in ipairs(normalized_shortcut_tag_sets) do
for _, normalized_after_tags_set in ipairs(normalized_after_tags_sets) do
insert(output_tag_sets, append(output_tag_set, normalized_shortcut_tag_set,
normalized_after_tags_set))
end
end
return output_tag_sets
else
insert(output_tag_set, normalize_tag(tag, lang, do_track))
end
end
error("Internal error: Should not get here")
end
normalize_tag_set = export.normalize_tag_set
--[==[
Split a tag set that may consist of multiple semicolon-separated tag sets into the component tag sets.]==]
function export.split_tag_set(tag_set)
local split_tag_sets = {}
local cur_tag_set = {}
for _, tag in ipairs(tag_set) do
if tag == ";" then
if #cur_tag_set > 0 then
insert(split_tag_sets, cur_tag_set)
end
cur_tag_set = {}
else
insert(cur_tag_set, tag)
end
end
if #cur_tag_set > 0 then
insert(split_tag_sets, cur_tag_set)
end
return split_tag_sets
end
split_tag_set = export.split_tag_set
local tag_set_param_mods = {
lb = {
item_dest = "labels",
convert = function(arg, _parse_err)
return split(arg, "//", true)
end,
}
}
--[==[
Parse tag set properties from a tag set (list of tags). Currently no per-tag properties are recognized, and the only
per-tag-set property recognized is `<lb:...>` for specifing label(s) for the tag set. Per-tag-set properties must be
attached to the last tag.]==]
function export.parse_tag_set_properties(tag_set)
local function generate_tag_set_obj(last_tag)
tag_set[#tag_set] = last_tag
return {tags = tag_set}
end
local last_tag = tag_set[#tag_set]
-- Check for inline modifier, e.g. מרים<tr:Miryem>. But exclude HTML entry with <span ...>, <i ...>, <br/> or
-- similar in it, caused by wrapping an argument in {{l|...}}, {{af|...}} or similar. Basically, all tags of
-- the sort we parse here should consist of a less-than sign, plus letters, plus a colon, e.g. <lb:...>, so if
-- we see a tag on the outer level that isn't in this format, we don't try to parse it. The restriction to the
-- outer level is to allow generated HTML inside of e.g. qualifier tags, such as foo<q:similar to {{m|fr|bar}}>.
if last_tag:find("<", nil, true) and not last_tag:find("^[^<]*<%l*[^%l:]") then
return parse_inline_modifiers(last_tag, {
param_mods = tag_set_param_mods,
generate_obj = generate_tag_set_obj,
})
else
return generate_tag_set_obj(last_tag)
end
end
parse_tag_set_properties = export.parse_tag_set_properties
local function normalize_pos(pos)
if not pos then
return nil
end
return (m_pos_data or get_m_pos_data())[pos] or pos
end
-- Return the display form of a single canonical-form tag. The value
-- passed in must be a string (i.e. it cannot be a list describing a
-- multipart tag). To handle multipart tags, use get_tag_display_form().
-- A truthy `nolink` suppresses linking.
local function get_single_tag_display_form(normtag, lang, nolink)
local data = lookup_tag(normtag, lang)
local display = normtag
-- If the tag has a special display form, use it
if data and data.display then
display = data.display
if nolink then
display = remove_links(display)
end
end
-- If there is a nonempty glossary index, then show a link to it
if not nolink then
local glossary = data and data[(m_data or get_m_data()).GLOSSARY]
if glossary ~= nil then
if glossary == m_data.WIKT then
display = "[[" .. normtag .. "|" .. display .. "]]"
elseif glossary == m_data.WP then
display = "[[w:" .. normtag .. "|" .. display .. "]]"
elseif glossary == m_data.APPENDIX then
display = "[[Appendix:Glossary#" .. anchor_encode(normtag) .. "|" .. display .. "]]"
elseif type(glossary) ~= "string" then
error(("Internal error: Wrong type %s for glossary value %s for tag %s"):format(
type(glossary), dump(glossary), normtag))
else
local link = glossary:match("^wikt:(.*)")
if link then
display = "[[" .. link .. "|" .. display .. "]]"
end
if not link then
link = glossary:match("^w:(.*)")
if link then
display = "[[w:" .. link .. "|" .. display .. "]]"
end
end
if not link then
display = "[[Appendix:Glossary#" .. anchor_encode(glossary) .. "|" .. display .. "]]"
end
end
end
end
return display
end
--[==[
Turn a canonicalized tag spec (which describes a single, possibly multipart tag) into the displayed form. The tag spec
may be a string (a canonical-form tag); a list of canonical-form tags (in the case of a simple multipart tag); or a
list of mixed canonical-form tags and lists of such tags (in the case of a two-level multipart tag). `joiner` indicates
how to join the parts of a multipart tag, and can be either {"and"} ("foo and bar", or "foo, bar and baz" for 3 or
more), {"slash"} ("foo/bar"), {"en-dash"} ("foo–bar") or {nil}, which uses the global default found in
{multipart_join_strategy()} in [[Module:form of/functions]]. (NOTE: The global default is {"slash"} and this seems
unlikely to change.) A truthy `nolink` suppresses linking.]==]
function export.get_tag_display_form(tagspec, lang, joiner, nolink)
if type(tagspec) == "string" then
return get_single_tag_display_form(tagspec, lang, nolink)
end
-- We have a multipart tag. See if there's a display handler to display them specially.
for _, handler in ipairs(display_handlers or get_display_handlers()) do
local displayval = handler(tagspec, joiner)
if displayval then
if nolink then
displayval = remove_links(displayval)
end
return displayval
end
end
-- No display handler.
local displayed_tags = {}
for _, first_level_tag in ipairs(tagspec) do
if type(first_level_tag) == "string" then
insert(displayed_tags, get_single_tag_display_form(first_level_tag, lang, nolink))
else
-- A first-level element of a two-level multipart tag. Currently we just separate the individual components
-- with spaces, but other ways are possible, e.g. using an underscore, colon, parens or braces.
local components = {}
for _, component in ipairs(first_level_tag) do
insert(components, get_single_tag_display_form(component, lang, nolink))
end
insert(displayed_tags, concat(components, " "))
end
end
return join_multiparts(displayed_tags, joiner)
end
get_tag_display_form = export.get_tag_display_form
--[==[
Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are
represented as lists, and two-level multipart tags as lists of lists), convert to displayed form (a string). See
{get_tag_display_form()} for the meaning of `joiner`. A truthy `nolink` suppresses linking.]==]
function export.get_tag_set_display_form(normalized_tag_set, lang, joiner, nolink)
local parts = {}
for _, tagspec in ipairs(normalized_tag_set) do
local to_insert = get_tag_display_form(tagspec, lang, joiner, nolink)
-- Maybe insert a space before inserting the display form of the tag. We insert a space if
-- (a) we're not the first tag; and
-- (b) the tag we're about to insert doesn't have the "no_space_on_left" property; and
-- (c) the preceding tag doesn't have the "no_space_on_right" property.
-- NOTE: We depend here on the fact that
-- (1) all tags with either of the above properties set have the same display form as canonical form, and
-- (2) all tags with either of the above properties set are single-character tags.
-- The second property is an optimization to avoid looking up display forms resulting from multipart tags,
-- which won't be found and which will trigger loading of [[Module:form of/data/2]]. If multichar punctuation is
-- added in the future, it's ok to change the == 1 below to <= 2 or <= 3.
--
-- If the first property above fails to hold in the future, we need to track the canonical form of each tag
-- (including the previous one) as well as the display form. This would also avoid the need for the == 1 check.
if #parts > 0 then
local most_recent_tagobj = parts[#parts]:match("^.[\128-\191]*$") and lookup_tag(parts[#parts], lang)
local to_insert_tagobj = to_insert:match("^.[\128-\191]*$") and lookup_tag(to_insert, lang)
if (
(not most_recent_tagobj or not most_recent_tagobj.no_space_on_right) and
(not to_insert_tagobj or not to_insert_tagobj.no_space_on_left)
) then
insert(parts, " ")
end
end
insert(parts, to_insert)
end
return concat(parts)
end
get_tag_set_display_form = export.get_tag_set_display_form
--[==[
Split a tag set containing two-level multipart tags into one or more tag sets not containing such tags.
Single-level multipart tags are left alone. (If we need to, a slight modification of the following code
will also split single-level multipart tags.) This assumes that multipart tags are represented as lists
and two-level multipart tags are represented as lists of lists, as is output by {normalize_tag_set()}.
NOTE: We have to be careful to properly handle imbalanced two-level multipart tags such as
`def:s//p` (or the reverse, `s//def:p`).]==]
local function split_two_level_multipart_tag_set(tag_set)
for i, tag in ipairs(tag_set) do
if type(tag) == "table" then
-- We saw a multipart tag. Check if any of the parts are two-level.
local saw_two_level_tag = false
for _, first_level_tag in ipairs(tag) do
if type(first_level_tag) == "table" then
saw_two_level_tag = true
break
end
end
if saw_two_level_tag then
-- We found a two-level multipart tag.
-- (1) Extract the preceding tags.
local pre_tags = slice(tag_set, 1, i - 1)
-- (2) Extract the following tags.
local post_tags = slice(tag_set, i + 1)
-- (3) Loop over each tag set alternant in the two-level multipart tag.
-- For each alternant, form the tag set consisting of pre_tags + alternant + post_tags,
-- and recursively split that tag set.
local resulting_tag_sets = {}
for _, first_level_tag_set in ipairs(tag) do
local expanded_tag_set = {}
extend(expanded_tag_set, pre_tags)
-- The second level may have a string or a list.
if type(first_level_tag_set) == "table" then
extend(expanded_tag_set, first_level_tag_set)
else
insert(expanded_tag_set, first_level_tag_set)
end
extend(expanded_tag_set, post_tags)
extend(resulting_tag_sets, split_two_level_multipart_tag_set(expanded_tag_set))
end
return resulting_tag_sets
end
end
end
return {tag_set}
end
local function try_lang_specific_module(langcode, modules_tried, name, data)
local lang_specific_module = form_of_lang_data_module_prefix .. langcode .. "/functions"
local langdata = safe_require(lang_specific_module)
if langdata then
insert(modules_tried, lang_specific_module)
if langdata.cat_functions then
local fn = langdata.cat_functions[name]
if fn then
return fn(data), true
end
end
end
return nil, false
end
-- Call a named function, either from the lang-specific data in
-- [[Module:form of/lang-specific/LANGCODE/functions]] or in [[Module:form of/functions]].
local function call_named_function(name, funtype, normalized_tag_set, lang, POS, pagename, lemmas)
local data = {
pagename = pagename or default_pagename or get_default_pagename(),
lemmas = lemmas,
tag_set = normalized_tag_set,
lang = lang,
POS = POS
}
local modules_tried = {}
-- First try lang-specific.
while lang do
local retval, found_it = try_lang_specific_module(lang:getCode(), modules_tried, name, data)
if found_it then
return retval
end
-- If the language has a parent (i.e. a superordinate variety), try again with that.
lang = lang:getParent()
end
-- Try lang-independent.
insert(modules_tried, form_of_functions_module)
local fn = (cat_functions or get_cat_functions())[name]
if fn then
return fn(data)
end
for i, modname in ipairs(modules_tried) do
modules_tried[i] = "[[" .. modname .. "]]"
end
error(("No %s function named '%s' in %s"):format(funtype, name, list_to_text(modules_tried, nil, " or ")))
end
-- Given a tag from the current tag set (which may be a list in case of a multipart tag),
-- and a tag from a categorization spec, check that the two match.
-- (1) If both are strings, we just check for equality.
-- (2) If the spec tag is a string and the tag set tag is a list (i.e. it originates from a
-- multipart tag), we check that the spec tag is in the list. This is because we want to treat
-- multipart tags in user-specified tag sets as if the user had specified multiple tag sets.
-- For example, if the user said "1//3|s|pres|ind" and the categorization spec says {"has", "1"},
-- we want this to match, because "1//3|s|pres|ind" should be treated equivalently to two tag
-- sets "1|s|pres|ind" and "3|s|pres|ind", and the former matches the categorization spec.
-- (3) If the spec tag is a list (i.e. it originates from a multipart tag), we check that the
-- tag set tag is also a list and is a superset of the spec tag. For example, if the categorization
-- spec says {"has", "1//3"}, then the tag set tag must be a multipart tag that has both "1" and "3"
-- in it. "1//3" works, as does "1//2//3".
local function tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag)
if type(spec_tag) == "table" then
if type(tag_set_tag) == "table" and is_subset_list(spec_tag, tag_set_tag) then
return true
end
elseif type(tag_set_tag) == "table" then
if contains(tag_set_tag, spec_tag) then
return true
end
elseif tag_set_tag == spec_tag then
return true
end
return false
end
-- Check that the current tag set matches the given spec tag. This means that any of the tags
-- in the current tag set match, according to tag_set_tag_matches_spec_tag(); see above. If the
-- current tag set contains only string tags (i.e. no multipart tags), and the spec tag is a
-- string (i.e. not a multipart tag), this boils down to list containment, but it gets more
-- complex when multipart tags are present.
local function tag_set_matches_spec_tag(spec_tag, tag_set, lang)
spec_tag = normalize_tag(spec_tag, lang)
for _, tag_set_tag in ipairs(tag_set) do
if tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) then
return true
end
end
return false
end
-- Check whether the given spec matches the current tag set. Two values are returned:
-- (1) whether the spec matches the tag set; (2) the index of the category to add if
-- the spec matches.
local function check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
if type(spec) == "boolean" then
return spec
elseif type(spec) ~= "table" then
error("Wrong type of condition " .. spec .. ": " .. type(spec))
end
local predicate = spec[1]
if predicate == "has" then
return tag_set_matches_spec_tag(spec[2], tag_set, lang), 3
elseif predicate == "hasall" then
for _, tag in ipairs(spec[2]) do
if not tag_set_matches_spec_tag(tag, tag_set, lang) then
return false, 3
end
end
return true, 3
elseif predicate == "hasany" then
for _, tag in ipairs(spec[2]) do
if tag_set_matches_spec_tag(tag, tag_set, lang) then
return true, 3
end
end
return false, 3
elseif predicate == "tags=" then
local normalized_spec_tag_sets = normalize_tag_set(spec[2], lang)
if #normalized_spec_tag_sets > 1 then
error("Internal error: No support for conjoined shortcuts in category/label specs in "
.. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|"))
end
local normalized_spec_tag_set = normalized_spec_tag_sets[1]
-- Check for and disallow two-level multipart tags in the specs. FIXME: Remove this when we remove
-- support for two-level multipart tags.
for _, tag in ipairs(normalized_spec_tag_set) do
if type(tag) == "table" then
for _, subtag in ipairs(tag) do
if type(subtag) == "table" then
error("Internal error: No support for two-level multipart tags in category/label specs"
.. "[[Module:form of/cats]] when processing spec tag set "
.. concat(spec[2], "|"))
end
end
end
end
-- Allow tags to be in different orders, and multipart tags to be in different orders. To handle this,
-- we first check that both tag set tags and spec tags have the same length. If so, we sort the
-- multipart tags in the tag set tags and spec tags, and then check that all tags in the spec tags are
-- in the tag set tags.
if #tag_set ~= #normalized_spec_tag_set then
return false, 3
end
local tag_set_tags = deep_copy(tag_set)
for i=1,#tag_set_tags do
if type(tag_set_tags[i]) == "table" then
sort(tag_set_tags[i])
end
if type(normalized_spec_tag_set[i]) == "table" then
sort(normalized_spec_tag_set[i])
end
end
for i=1,#tag_set_tags do
if not contains(tag_set_tags, normalized_spec_tag_set[i]) then
return false, 3
end
end
return true, 3
elseif predicate == "p=" then
return POS == normalize_pos(spec[2]), 3
elseif predicate == "pany" then
for _, specpos in ipairs(spec[2]) do
if POS == normalize_pos(specpos) then
return true, 3
end
end
return false, 3
elseif predicate == "pexists" then
return POS ~= nil, 2
elseif predicate == "not" then
local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
return not condval, 3
elseif predicate == "and" then
local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
if condval then
condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
end
return condval, 4
elseif predicate == "or" then
local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
if not condval then
condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
end
return condval, 4
elseif predicate == "call" then
return call_named_function(spec[2], "condition", normalized_tag_set, lang, POS, pagename, lemmas), 3
else
error("Unrecognized predicate: " .. predicate)
end
end
-- Process a given spec. This checks any conditions in the spec against the
-- tag set, and insert any resulting categories into `categories`. Return value
-- is true if the outermost condition evaluated to true and a category was inserted
-- (this is used in {"cond" ...} conditions, which stop when a subcondition evaluates
-- to true).
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
local function process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
if not spec then
return false
elseif type(spec) == "string" then
-- A category. Substitute POS request with user-specified part of speech or default.
spec = spec:gsub("<<p=(.-)>>", function(default)
return POS or normalize_pos(default)
end)
insert(categories, lang:getFullName() .. " " .. cat_word(lang, spec))
return true
elseif type(spec) == "table" and spec.labels then
-- A label spec.
for _, label in ipairs(spec.labels) do
insert_if_not(labels, label)
end
return true
elseif type(spec) ~= "table" then
error("Wrong type of specification " .. spec .. ": " .. type(spec))
end
local predicate = spec[1]
if predicate == "multi" then
for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2.
process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
end
return true
elseif predicate == "cond" then
for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2.
if process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) then
return true
end
end
return false
elseif predicate == "call" then
return process_spec(
call_named_function(spec[2], "spec", normalized_tag_set, lang, POS, pagename, lemmas),
tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels
)
else
local condval, ifspec = check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas)
if condval then
process_spec(spec[ifspec], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
return true
else
process_spec(spec[ifspec + 1], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
-- FIXME: Are we sure this is correct?
return false
end
end
end
--[==[
Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are
represented as lists, and two-level multipart tags as lists of lists), fetch the associated categories and labels.
Return two values, a list of categories and a list of labels. `lang` is the language of term represented by the tag set,
and `POS` is the user-provided part of speech (which may be {nil}).]==]
function export.fetch_categories_and_labels(normalized_tag_set, lang, POS, pagename, lemmas)
local categories, labels = {}, {}
POS = normalize_pos(POS)
-- First split any two-level multipart tags into multiple sets, to make our life easier.
for _, tag_set in ipairs(split_two_level_multipart_tag_set(normalized_tag_set)) do
local langcode = lang:getCode()
local langspecs = (m_cats_data or get_m_cats_data())[langcode]
if langspecs then
for _, spec in ipairs(langspecs) do
process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
end
end
local full_code = lang:getFullCode()
if full_code ~= langcode then
local langspecs = (m_cats_data or get_m_cats_data())[full_code]
if langspecs then
for _, spec in ipairs(langspecs) do
process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
end
end
end
if full_code ~= "und" then
local langspecs = (m_cats_data or get_m_cats_data())["und"]
if langspecs then
for _, spec in ipairs(langspecs) do
process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels)
end
end
end
end
return categories, labels
end
fetch_categories_and_labels = export.fetch_categories_and_labels
local function format_labels(labels, data, notext)
if labels and #labels > 0 then
return show_labels{
labels = labels,
lang = data.lang,
sort = data.sort,
nocat = data.nocat
} .. (notext and (data.pretext or "") == "" and "" or " ")
else
return ""
end
end
--[==[
Implementation of templates that display inflection tags, such as the general {{tl|inflection of}}, semi-specific
variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the
information controlling the display, with the following fields:
* `.lang`: ('''''required''''') Language to use when looking up language-specific inflection tags, categories and
labels, and for displaying categories and labels.
* `.tags`: ('''''required''' unless `.tag_sets` is given'') List of non-canonicalized inflection tags. Multiple tag sets
can be indicated by a {";"} as one of the tags, and tag-set properties may be attached to the last tag of a tag set.
The tags themselves may come directly from the user (as in {{tl|inflection of}}); come partly from the user (as in
{{tl|participle of}}, which adds the tag `part` to user-specified inflection tags); or be entirely specified by the
template (as in {{tl|past participle of}}).
* `.tag_sets`: ('''''required''' unless `.tags` is given'') List of non-canonicalized tag sets and associated
per-tag-set properties. Each element of the list is an object of the form
{ {tags = {"TAG", "TAG", ...}, labels = {"LABEL", "LABEL", ...}}. If `.tag_sets` is specified, `.tags` should not be
given and vice-versa. Specifying `.tag_sets` in place of tags allowed per-tag set labels to be specified; otherwise,
there is no advantage. [[Module:pt-gl-inflections]] uses this functionality to supply labels like {"Brazil"} and
{"Portugal"} associated with specific tag sets.
* `.lemmas`: ('''''recommended''''') List of objects describing the lemma(s) of which the term in question is a
non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a
`.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is
formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in
[[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly. If omitted entirely, no lemma
links are shown and the connecting "of" is also omitted.
* `.lemma_face`: ('''''recommended''''') "Face" to use when displaying the lemma objects. Usually should be set to
{"term"}.
* `.POS`: ('''''recommended''''') Categorizing part-of-speech tag. Comes from the {{para|p}} or {{para|POS}} argument of
{{tl|inflection of}}.
* `.pagename`: Page name of "current" page or nil to use the actual page title; for testing purposes.
* `.conj`: Conjunction or separator to use when joining multiple lemma objects. Defaults to {"and"}.
* `.enclitics`: List of enclitics to display after the lemmas, in parens.
* `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}.
* `.no_format_categories`: If true, don't format the categories derived from the inflection tags; just return them.
* `.sort`: Sort key for formatted categories. Ignored when `.no_format_categories` = {true}.
* `.nocat`: Suppress computation of categories (even if `.no_format_categories` is not given).
* `.notext`: Disable display of all tag text and `inflection of` text. (FIXME: Maybe not implemented correctly.)
* `.nolink`: Suppress linking of terms in inflection tags.
* `.capfirst`: Capitalize the first word displayed.
* `.pretext`: Additional text to display before the inflection tags, but after any top-level labels.
* `.posttext`: Additional text to display after the lemma links.
* `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is
{"form-of-definition use-with-mention"}.
* `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}.
* `.joiner`: Override the joiner (normally a slash) used to join multipart tags. You should normally not specify this.
* `.nowrap`: Do not wrap the form-of definitions in a span, unless `.text_classes` is specified.
* `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified
in-place to save memory; otherwise they will be copied before modifying.
A typical call might look like this (for {{m+|es|amo}}): {
local lang = require("Module:languages").getByCode("es")
local lemma_obj = {
lang = lang,
term = "amar",
}
return m_form_of.tagged_inflections({
lang = lang, tags = {"1", "s", "pres", "ind"}, lemmas = {lemma_obj}, lemma_face = "term", POS = "verb"
})
}
Normally, one value is returned, the formatted text, which has appended to it the formatted categories derived from the
tag-set-related categories generated by the specs in [Module:form of/cats]]. To suppress this, set
`data.no_format_categories` = {true}, in which case two values are returned, the formatted text without any formatted
categories appended and a list of the categories to be formatted.
NOTE: There are two sets of categories that may be generated: (1) categories derived directly from the tag sets, as
specified in [[Module:form of/cats]]; (2) categories derived from tag-set labels, either (a) set explicitly by the
caller in `data.tag_sets`, (b) specified by the user using `<lb:...>` attached to the last tag in a tag set, or
(c) specified in [[Module:form of/cats]]. The second type (label-related categories) are currently not returned in
the second return value of {tagged_inflections()}, and are currently inserted into the output text even if
`data.no_format_categories` is set to {true}; but they can be suppressed by setting `data.nocat` = {true} (which also
suppresses the first type of categories, those derived directly from tag sets, even if `data.no_format_categories` is
set to {true}).]==]
function export.tagged_inflections(data)
if not data.tags and not data.tag_sets then
error("First argument must be a table of arguments, and `.tags` or `.tag_sets` must be specified")
end
if data.tags and data.tag_sets then
error("Both `.tags` and `.tag_sets` cannot be specified")
end
local tag_sets = data.tag_sets
if not tag_sets then
tag_sets = split_tag_set(data.tags)
for i, tag_set in ipairs(tag_sets) do
tag_sets[i] = parse_tag_set_properties(tag_set)
end
end
local inflections = {}
local categories = {}
for _, tag_set in ipairs(tag_sets) do
local normalized_tag_sets = normalize_tag_set(tag_set.tags, data.lang, "do-track")
for _, normalized_tag_set in ipairs(normalized_tag_sets) do
local this_categories, this_labels = fetch_categories_and_labels(normalized_tag_set, data.lang,
data.POS, data.pagename, type(data.lemmas) == "table" and data.lemmas or nil)
if not data.nocat then
extend(categories, this_categories)
end
local cur_infl = get_tag_set_display_form(normalized_tag_set, data.lang, data.joiner, data.nolink)
if #cur_infl > 0 then
if tag_set.labels then
this_labels = append(tag_set.labels, this_labels)
end
insert(inflections, {infl_text = cur_infl, labels = this_labels})
end
end
end
local overall_labels, need_per_tag_set_labels
for _, inflection in ipairs(inflections) do
if overall_labels == nil then
overall_labels = inflection.labels
elseif not deep_equals(overall_labels, inflection.labels) then
need_per_tag_set_labels = true
overall_labels = nil
break
end
end
if not need_per_tag_set_labels then
for _, inflection in ipairs(inflections) do
inflection.labels = nil
end
end
local format_data = shallow_copy(data)
local of_text = data.lemmas and " of" or ""
local formatted_text, this_categories
if #inflections == 1 then
if need_per_tag_set_labels then
error("Internal error: need_per_tag_set_labels should not be set with one inflection")
end
format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or
((data.capfirst and ucfirst(inflections[1].infl_text) or inflections[1].infl_text) .. of_text))
formatted_text, this_categories = format_form_of(format_data)
else
format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or
((data.capfirst and "Inflection" or "inflection") .. of_text))
format_data.posttext = (data.posttext or "") .. ":"
local link
link, this_categories = format_form_of(format_data)
local text_classes = data.text_classes
if text_classes == nil and not data.nowrap then
text_classes = "form-of-definition use-with-mention"
end
for i, inflection in ipairs(inflections) do
inflections[i] = "\n## " .. format_labels(inflection.labels, data, false) ..
wrap_in_span(inflection.infl_text, text_classes)
end
formatted_text = link .. concat(inflections)
end
if this_categories[1] then
extend(categories, this_categories)
end
if not data.no_format_categories then
if categories[1] then
formatted_text = formatted_text .. format_categories(categories, data.lang,
data.sort, nil, export.force_cat)
end
return formatted_text
end
return formatted_text, categories
end
function export.dump_form_of_data(_frame)
local data = {
require(form_of_data1_module),
require(form_of_data2_module)
}
return require(json_module).toJSON(data)
end
export.form_of_cats_module = form_of_cats_module
export.form_of_data1_module = form_of_data1_module
export.form_of_data2_module = form_of_data2_module
export.form_of_functions_module = form_of_functions_module
export.form_of_lang_data_module_prefix = form_of_lang_data_module_prefix
export.headword_data_module = headword_data_module -- so all form-of modules stay in sync
return export
5372ao39gyqdgrcci64qhc133rbhken
Module:gender and number
828
7988
54920
54734
2026-09-29T00:02:01Z
Deadend0914
7211
54920
Scribunto
text/plain
local export = {}
local decorations_module = "Module:decorations"
local load_module = "Module:load"
local parameters_module = "Module:parameters"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local concat = table.concat
local insert = table.insert
local function deep_copy(...)
deep_copy = require(table_module).deepCopy
return deep_copy(...)
end
local function format_categories(...)
format_categories = require(utilities_module).format_categories
return format_categories(...)
end
local function format_decorations(...)
format_decorations = require(decorations_module).format_decorations
return format_decorations(...)
end
local function load_data(...)
load_data = require(load_module).load_data
return load_data(...)
end
local function process_params(...)
process_params = require(parameters_module).process
return process_params(...)
end
local function split(...)
split = require(string_utilities_module).split
return split(...)
end
local gender_and_number_data
local function get_gender_and_number_data()
gender_and_number_data, get_gender_and_number_data = load_data("Module:gender and number/data"), nil
return gender_and_number_data
end
--[==[ intro:
This module creates standardised displays for gender and number. It converts a gender specification into Wiki/HTML format.
A gender/number specification consists of one or more gender/number elements, separated by hyphens. Examples are:
{"n"} (neuter gender), {"f-p"} (feminine plural), {"m-an-p"} (masculine animate plural),
{"pf"} (perfective aspect). Each gender/number element has the following properties:
# A code, as used in the spec, e.g. {"f"} for feminine, {"p"} for plural.
# A type, e.g. `gender`, `number` or `animacy`. Each element in a given spec must be of a different type.
# A display form, which in turn consists of a display code and a tooltip gloss. The display code
may not be the same as the spec code, e.g. the spec code {"an"} has display code {"anim"} and tooltip
gloss ''animate''.
# A category into which lemmas of the right part of speech are placed if they have a gender/number
spec containing the given element. For example, a noun with gender/number spec {"m-an-p"} is placed
into the categories `<var>lang</var> masculine nouns`, `<var>lang</var> animate nouns` and `<var>lang</var> pluralia tantum`.
]==]
--[==[
Version of format_genders() that can be invoked from a template.
]==]
function export.show_list(frame)
local params = {
[1] = {list = true},
["lang"] = {type = "language"},
}
local iargs = process_params(frame.args, params)
local text, cats = export.format_genders(iargs[1], iargs.lang)
if not cats then
return text
end
return text .. format_categories(cats, iargs.lang)
end
function export.format_list(...)
-- FIXME: Added 2026-09-17. Remove after 2026-10-17.
error("Use format_genders instead of format_list")
end
local function autoadd_abbr(display)
if not display then
error("Internal error: '.display' for gender/number code is missing")
end
if display:find("<abbr", nil, true) then
return display
end
return ('%s'):format(display, display)
end
--[=[
Add decorations (qualifiers, labels and references) to a formatted gender/number spec. `spec` is the object
describing the gender/number spec, which should optionally contain:
* left qualifiers in `q`, an array of strings;
* right qualifiers in `qq`, an array of strings;
* left labels in `l`, an array of strings;
* right labels in `ll`, an array of strings;
* references in `refs`, an array either of strings (formatted reference text) or objects containing fields `text`
(formatted reference text) and optionally `name` and/or `group`;
`formatted` is the formatted version of the term itself, and `lang` is the optional language object passed into
format_genders().
]=]
local function add_decorations(formatted, spec, lang)
local function field_non_empty(field)
local list = spec[field]
if not list then
return nil
end
if type(list) ~= "table" then
error(("Internal error: Wrong type for `spec.%s`=%s, should be \"table\""):format(
field, mw.dumpObject(list)))
end
return list[1]
end
if field_non_empty("q") or field_non_empty("qq") or field_non_empty("l") or field_non_empty("ll") or
field_non_empty("refs") then
formatted = format_decorations {
lang = lang,
text = formatted,
q = spec.q,
qq = spec.qq,
l = spec.l,
ll = spec.ll,
refs = spec.refs,
}
end
return formatted
end
--[==[
Format one or more gender/number specifications. Each spec is either a string, e.g. {"f-p"}, or a table of the form
{ {spec = "SPEC",
q = {"LEFT_QUALIFIER", "LEFT_QUALIFIER", ...},
qq = {"RIGHT_QUALIFIER", "RIGHT_QUALIFIER", ...},
l = {"LEFT_LABEL", "LEFT_LABEL", ...},
ll = {"RIGHT_LABEL", "RIGHT_LABEL", ...},
refs = {"FORMATTED_REFERENCE_TEXT", {text = "FORMATTED_REFERENCE_TEXT", name = "REFNAME", group = "REFGROUP"}, ...},
}} In the table format, only `spec` is required, and in the `refs` object format, only `text` is required.
If `lang` is not given, the funtion returns only one value, the formatted text.
If `lang` is given, the function returns two values:
# the formatted text;
# a list of the categories to add, which will be {nil} if there are no categories to add.
If `lang` (which should be a language object) and `pos_for_cat` (which should be a plural part of speech) are given,
gender categories such as `German masculine nouns` or `Russian imperfective verbs` are added to the categories, and
request categories such as `Requests for gender in <var>lang</var> entries` or
`Requests for animacy in <var>lang</var> entries` may also be added. Otherwise, if only `lang` is given, only request
categories may be returned. If both are omitted, only one return value is returned, as mentioned above.
]==]
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
function export.format_genders(specs, lang, pos_for_cat)
local formatted_specs, categories, seen_types = {}
local all_is_nounclass = nil
local full_langname = lang and lang:getFullName() or nil
local function do_gender_spec(spec, parts)
local types = {}
local codes = (gender_and_number_data or get_gender_and_number_data()).codes
for key, code in ipairs(parts) do
-- Is this code valid?
if not codes[code] then
error('The tag "' .. code .. '" in the gender specification "' .. spec.spec ..
'" is not valid. See [[Module:gender and number]] for a list of valid tags.')
end
-- Check for multiple genders/numbers/animacies in a single spec.
local typ = codes[code].type
if typ ~= "other" and types[typ] then
error('The gender specification "' .. spec.spec .. '" contains multiple tags of type "' .. typ .. '".')
end
types[typ] = true
parts[key] = autoadd_abbr(codes[code].display)
-- Generate categories if called for.
if lang and pos_for_cat then
local cat = codes[code].cat
if cat then
if not categories then
categories = {}
end
insert(categories, full_langname .. " " .. cat_word(lang, cat))
end
if not seen_types then
seen_types = {}
elseif seen_types[typ] and seen_types[typ] ~= code then
cat = (gender_and_number_data or get_gender_and_number_data()).multicode_cats[typ]
if cat then
if not categories then
categories = {}
end
insert(categories, full_langname .. " " .. cat_word(lang, cat))
end
end
seen_types[typ] = code
end
if lang and codes[code].req then
local type_for_req = typ
if code == "?" then
-- Keep in mind `pos_for_cat` may be nil here.
type_for_req = pos_for_cat == "verbs" and "aspect" or "gender"
end
if not categories then
categories = {}
end
insert(categories, "Requests for " .. type_for_req .. " in " .. full_langname .. " entries")
end
end
-- Add the processed codes together with non-breaking spaces
if not parts[2] and parts[1] then
return parts[1]
else
return concat(parts, " ")
end
end
for _, spec in ipairs(specs) do
if type(spec) ~= "table" then
spec = {spec = spec}
end
local spec_spec, is_nounclass = spec.spec
-- If the specification starts with cX, then it is a noun class specification.
if spec_spec:match("^%d") or spec_spec:match("^c[^-]") then
is_nounclass = true
local code = spec_spec:gsub("^c", "")
local text
if code == "?" then
text = '<abbr class="noun-class" title="noun class missing">?</abbr>'
if lang then
if not categories then
categories = {}
end
insert(categories, "Requests for noun class in " .. full_langname .. " entries")
end
else
text = '<abbr class="noun-class" title="noun class ' .. code .. '">' .. code .. "</abbr>"
if lang and pos_for_cat then
if not categories then
categories = {}
end
insert(categories, full_langname .. " " .. cat_word(lang, "class " .. code .. " POS"))
end
end
local text_with_decorations = add_decorations(text, spec, lang)
insert(formatted_specs, text_with_decorations)
else
-- Split the parts and iterate over each part, converting it into its display form
local parts = split(spec.spec, "-", true, true)
local combined_codes = (gender_and_number_data or get_gender_and_number_data()).combinations
if lang then
-- Check if the specification is valid
--elseif langinfo.genders then
-- local valid_genders = {}
-- for _, g in ipairs(langinfo.genders) do valid_genders[g] = true end
--
-- if not valid_genders[spec.spec] then
-- local valid_string = {}
-- for i, g in ipairs(langinfo.genders) do valid_string[i] = g end
-- error('The gender specification "' .. spec.spec .. '" is not valid for ' .. langinfo.names[1] .. ". Valid are: " .. concat(valid_string, ", "))
-- end
--end
end
local has_combined = false
for _, code in ipairs(parts) do
if combined_codes[code] then
has_combined = true
break
end
end
if not has_combined then
if formatted_specs[1] then
insert(formatted_specs, "or")
end
insert(formatted_specs, add_decorations(do_gender_spec(spec, parts), spec, lang))
else
-- This logic is to handle combined gender specs like 'mf' and 'mfbysense'.
local all_parts = {{}}
local extra_displays
local this_formatted_specs = {}
for _, code in ipairs(parts) do
if combined_codes[code] then
local new_all_parts = {}
for _, one_parts in ipairs(all_parts) do
for _, one_code in ipairs(combined_codes[code].codes) do
local new_combined_parts = deep_copy(one_parts)
insert(new_combined_parts, one_code)
insert(new_all_parts, new_combined_parts)
end
end
all_parts = new_all_parts
if lang and pos_for_cat then
local extra_cat = combined_codes[code].cat
if extra_cat then
if not categories then
categories = {}
end
insert(categories, full_langname .. " " .. cat_word(lang, extra_cat))
end
end
local extra_display = combined_codes[code].display
if extra_display then
if not extra_displays then
extra_displays = {}
end
insert(extra_displays, autoadd_abbr(extra_display))
end
else
for _, one_parts in ipairs(all_parts) do
insert(one_parts, code)
end
end
end
for _, this_parts in ipairs(all_parts) do
if this_formatted_specs[1] then
insert(this_formatted_specs, "or")
end
insert(this_formatted_specs, do_gender_spec(spec, this_parts))
end
if extra_displays then
for _, display in ipairs(extra_displays) do
insert(this_formatted_specs, display)
end
end
insert(formatted_specs, add_decorations(
concat(this_formatted_specs, " "), spec, lang))
end
is_nounclass = false
end
-- Ensure that the specifications are either all noun classes, or none are.
if all_is_nounclass == nil then
all_is_nounclass = is_nounclass
elseif all_is_nounclass ~= is_nounclass then
error("Noun classes and genders cannot be mixed. Please use either one or the other.")
end
end
if categories and lang and pos_for_cat then
for i, cat in ipairs(categories) do
categories[i] = cat:gsub("POS", pos_for_cat)
end
end
local formatted_retval
if all_is_nounclass then
-- Add the processed codes together with slashes
formatted_retval = '<span class="gender">class ' .. concat(formatted_specs, "/") .. "</span>"
else
-- Add the processed codes together with spaces
formatted_retval = '<span class="gender">' .. concat(formatted_specs, " ") .. "</span>"
end
if lang then
return formatted_retval, categories
else
return formatted_retval
end
end
return export
81r0wqc0am2fwupqoyj5a56p0oy78ki
Module:ang-headword
828
8016
54914
54785
2026-09-28T23:27:21Z
Deadend0914
7211
54914
Scribunto
text/plain
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("ang")
local insert = table.insert
local remove = table.remove
local function get_plaintext(...)
get_plaintext = require("Module:utilities").get_plaintext
return get_plaintext(...)
end
local function track(page)
require("Module:debug").track("ang-headword/" .. page)
return true
end
local function glossary_link(anchor, text)
text = text or anchor
return "[[Appendix:Glossary#" .. anchor .. "|" .. text .. "]]"
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local NAMESPACE = mw.title.getCurrentTitle().nsText
-- unused
-- local PAGENAME = mw.loadData("Module:headword/data").pagename
local iparams = {
[1] = {required = true},
["def"] = true,
["suff_type"] = true,
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local args = frame:getParent().args
local poscat = iargs[1]
local def = iargs.def
local suff_type = iargs.suff_type
local postype = nil
if suff_type then
postype = poscat .. "-" .. suff_type
else
postype = poscat
end
local data = {
lang = lang,
heads = {},
genders = {},
inflections = {},
categories = {},
no_redundant_head_cat = true, -- we want the headword specified to specify whether it has long vowels
}
if poscat == "suffixes" then
insert(data.categories, "Englisc " .. suff_type .. "-forming suffixes")
end
if pos_functions[postype] then
local new_poscat = pos_functions[postype](def, args, data)
if new_poscat then
poscat = new_poscat
end
end
data.pos_category = poscat
return require("Module:headword").full_headword(data)
end
local function validate_genders(genders)
for _, gspec in ipairs(genders) do
local g = gspec.spec
if g ~= "wer" and g ~= "wif" and g ~= "n" and g ~= "m-p" and g ~= "f-p" and g ~= "n-p" and g~="m" and g~="f" and g ~= "?" then
error("Invalid gender: " .. g)
end
end
end
pos_functions["nouns"] = function(def, args, data)
local params = {
["head"] = {list = true},
["id"] = true,
[1] = {type = "genders", list = "g", flatten = true, disallow_holes = true},
["g"] = {alias_of = 1, list = false},
[2] = {list = "pl", disallow_holes = true},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
validate_genders(args[1])
data.genders = args[1]
local pl = args[2]
if pl[1] then
pl.label = "nominative plural"
insert(data.inflections, pl)
end
end
pos_functions["proper nouns"] = pos_functions["nouns"]
pos_functions["verbs"] = function(def, args, data)
local params = {
[1] = {alias_of = "head", list = false},
["head"] = {list = true},
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
end
local function adjectives(pos, def, args, data)
local list = {list = true}
local params = {
[1] = {alias_of = "head", list = false},
["head"] = list,
["comp"] = list,
[2] = {alias_of = "comp", list = false},
["sup"] = list,
[3] = {alias_of = "sup", list = false},
["adv"] = list,
["indecl"] = {type = "boolean"},
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
if args.indecl then
insert(data.inflections, {label = glossary_link("indeclinable")})
end
local comp = args.comp
if #comp > 0 then
comp.label = "comparative"
insert(data.inflections, comp)
end
local sup = args.sup
if #sup > 0 then
sup.label = "superlative"
insert(data.inflections, sup)
end
if #args.adv > 0 then
args.adv.label = "adverb"
insert(data.inflections, args.adv)
end
end
pos_functions["adjectives"] = function(def, args, data)
return adjectives("adjectives", def, args, data)
end
pos_functions["participles"] = function(def, args, data)
return adjectives("participles", def, args, data)
end
pos_functions["determiners"] = function(def, args, data)
return adjectives("determiners", def, args, data)
end
pos_functions["pronouns"] = function(def, args, data)
return adjectives("pronouns", def, args, data)
end
pos_functions["suffixes-adjective"] = function(def, args, data)
return adjectives("suffixes", def, args, data)
end
pos_functions["numerals-adjective"] = function(def, args, data)
return adjectives("numerals", def, args, data)
end
pos_functions["adverbs"] = function(def, args, data)
local list = {list = true}
local params = {
[1] = {alias_of = "head", list = false},
[2] = {alias_of = "comp", list = false},
[3] = {alias_of = "sup", list = false},
["head"] = list,
["comp"] = list,
["sup"] = list,
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
local comp, sup
if args.comp[1] == "-" then
comp = "-"
elseif #args.comp > 0 then
args.comp.label = glossary_link("comparative")
comp = args.comp
end
if args.comp[1] == "-" or args.sup[1] == "-" then
sup = "-"
elseif #args.sup > 0 then
args.sup.label = glossary_link("superlative")
sup = args.sup
end
if comp == "-" then
insert(data.inflections, {label = "not " .. glossary_link("comparable")})
insert(data.categories, "Englisc uncomparable adverbs")
else
insert(data.inflections, comp)
end
if sup == "-" then
if comp ~= "-" then
insert(data.inflections, {label = "no " .. glossary_link("superlative")})
end
else
insert(data.inflections, sup)
end
end
pos_functions["suffixes-adverb"] = pos_functions["adverbs"]
local function get_forms(forms)
if #forms == 0 then
return nil
end
local i, attested = 1, false
while true do
local form = forms[i]
if form == nil then
return forms, attested
elseif form == "-" then
remove(forms, i)
else
if not (attested or get_plaintext(form):sub(1, 1) == "*") then
attested = true
end
i = i + 1
end
end
end
local function degree(pos, deg, other_arg, other_label, args, data)
local boolean = {type = "boolean"}
local list = {list = true}
local params = {
[1] = {alias_of = "head", list = false},
["head"] = list,
["positive"] = list,
[other_arg] = list,
["indecl"] = boolean,
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
if args.indecl then
insert(data.inflections, {label = glossary_link("indeclinable")})
end
local positive, positive_attested = get_forms(args.positive)
if positive then
if not positive_attested then
insert(data.categories, "Englisc " .. deg .. "-only " .. pos)
end
if #positive > 0 then
args.positive.label = "positive"
insert(data.inflections, args.positive)
else
insert(data.inflections, {label = "no positive form"})
end
end
local other = get_forms(args[other_arg])
if other then
if #other > 0 then
args[other_arg].label = other_label
insert(data.inflections, args[other_arg])
else
insert(data.inflections, {label = "no " .. other_label .. " form"})
end
end
-- If a lemma, return the primary part of speech ("adjectives" or
-- "adverbs"), so that the term is categorized in "Old English adjectives"
-- or "Old English adverbs". Otherwise, return nothing, so that the term
-- goes in the relevant non-lemma category (e.g. "Old English comparative
-- adjectives"), and into "Old English non-lemma forms".
if positive and not positive_attested then
return pos
end
end
pos_functions["comparative adjectives"] = function(def, args, data)
return degree("adjectives", "comparative", "sup", "superlative", args, data)
end
pos_functions["superlative adjectives"] = function(def, args, data)
return degree("adjectives", "superlative", "comp", "comparative", args, data)
end
pos_functions["comparative adverbs"] = function(def, args, data)
return degree("adverbs", "comparative", "sup", "superlative", args, data)
end
pos_functions["superlative adverbs"] = function(def, args, data)
return degree("adverbs", "superlative", "comp", "comparative", args, data)
end
local function non_lemma_forms(def, args, data)
local params = {
[1] = {required = true, default = def}, -- headword or cases
["head"] = {list = true, require_index = true},
["g"] = {list = true},
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
local heads = {args[1]}
for _, head in ipairs(args.head) do
insert(heads, head)
end
data.heads = heads
data.genders = args.g
data.id = args.id
end
pos_functions["noun forms"] = non_lemma_forms
pos_functions["proper noun forms"] = non_lemma_forms
pos_functions["pronoun forms"] = non_lemma_forms
pos_functions["verb forms"] = non_lemma_forms
pos_functions["adjective forms"] = non_lemma_forms
pos_functions["participle forms"] = non_lemma_forms
pos_functions["determiner forms"] = non_lemma_forms
pos_functions["numeral forms"] = non_lemma_forms
pos_functions["suffix forms"] = non_lemma_forms
return export
q0m8uxbouv15iu5krvl0uc0j27cj8ui
54924
54914
2026-09-29T00:04:06Z
Deadend0914
7211
54924
Scribunto
text/plain
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("ang")
local insert = table.insert
local remove = table.remove
local function get_plaintext(...)
get_plaintext = require("Module:utilities").get_plaintext
return get_plaintext(...)
end
local function track(page)
require("Module:debug").track("ang-headword/" .. page)
return true
end
local function glossary_link(anchor, text)
text = text or anchor
return "[[Appendix:Glossary#" .. anchor .. "|" .. text .. "]]"
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
function export.show(frame)
local NAMESPACE = mw.title.getCurrentTitle().nsText
-- unused
-- local PAGENAME = mw.loadData("Module:headword/data").pagename
local iparams = {
[1] = {required = true},
["def"] = true,
["suff_type"] = true,
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local args = frame:getParent().args
local poscat = iargs[1]
local def = iargs.def
local suff_type = iargs.suff_type
local postype = nil
if suff_type then
postype = poscat .. "-" .. suff_type
else
postype = poscat
end
local data = {
lang = lang,
heads = {},
genders = {},
inflections = {},
categories = {},
no_redundant_head_cat = true, -- we want the headword specified to specify whether it has long vowels
}
if poscat == "suffixes" then
insert(data.categories, "Englisc " .. cat_word(lang, "{type}-forming suffixes"):gsub("{type}", suff_type))
end
if pos_functions[postype] then
local new_poscat = pos_functions[postype](def, args, data)
if new_poscat then
poscat = new_poscat
end
end
data.pos_category = poscat
return require("Module:headword").full_headword(data)
end
local function validate_genders(genders)
for _, gspec in ipairs(genders) do
local g = gspec.spec
if g ~= "wer" and g ~= "wif" and g ~= "n" and g ~= "m-p" and g ~= "f-p" and g ~= "n-p" and g~="m" and g~="f" and g ~= "?" then
error("Invalid gender: " .. g)
end
end
end
pos_functions["nouns"] = function(def, args, data)
local params = {
["head"] = {list = true},
["id"] = true,
[1] = {type = "genders", list = "g", flatten = true, disallow_holes = true},
["g"] = {alias_of = 1, list = false},
[2] = {list = "pl", disallow_holes = true},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
validate_genders(args[1])
data.genders = args[1]
local pl = args[2]
if pl[1] then
pl.label = "nominative plural"
insert(data.inflections, pl)
end
end
pos_functions["proper nouns"] = pos_functions["nouns"]
pos_functions["verbs"] = function(def, args, data)
local params = {
[1] = {alias_of = "head", list = false},
["head"] = {list = true},
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
end
local function adjectives(pos, def, args, data)
local list = {list = true}
local params = {
[1] = {alias_of = "head", list = false},
["head"] = list,
["comp"] = list,
[2] = {alias_of = "comp", list = false},
["sup"] = list,
[3] = {alias_of = "sup", list = false},
["adv"] = list,
["indecl"] = {type = "boolean"},
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
if args.indecl then
insert(data.inflections, {label = glossary_link("indeclinable")})
end
local comp = args.comp
if #comp > 0 then
comp.label = "comparative"
insert(data.inflections, comp)
end
local sup = args.sup
if #sup > 0 then
sup.label = "superlative"
insert(data.inflections, sup)
end
if #args.adv > 0 then
args.adv.label = "adverb"
insert(data.inflections, args.adv)
end
end
pos_functions["adjectives"] = function(def, args, data)
return adjectives("adjectives", def, args, data)
end
pos_functions["participles"] = function(def, args, data)
return adjectives("participles", def, args, data)
end
pos_functions["determiners"] = function(def, args, data)
return adjectives("determiners", def, args, data)
end
pos_functions["pronouns"] = function(def, args, data)
return adjectives("pronouns", def, args, data)
end
pos_functions["suffixes-adjective"] = function(def, args, data)
return adjectives("suffixes", def, args, data)
end
pos_functions["numerals-adjective"] = function(def, args, data)
return adjectives("numerals", def, args, data)
end
pos_functions["adverbs"] = function(def, args, data)
local list = {list = true}
local params = {
[1] = {alias_of = "head", list = false},
[2] = {alias_of = "comp", list = false},
[3] = {alias_of = "sup", list = false},
["head"] = list,
["comp"] = list,
["sup"] = list,
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
local comp, sup
if args.comp[1] == "-" then
comp = "-"
elseif #args.comp > 0 then
args.comp.label = glossary_link("comparative")
comp = args.comp
end
if args.comp[1] == "-" or args.sup[1] == "-" then
sup = "-"
elseif #args.sup > 0 then
args.sup.label = glossary_link("superlative")
sup = args.sup
end
if comp == "-" then
insert(data.inflections, {label = "not " .. glossary_link("comparable")})
insert(data.categories, "Englisc uncomparable adverbs")
else
insert(data.inflections, comp)
end
if sup == "-" then
if comp ~= "-" then
insert(data.inflections, {label = "no " .. glossary_link("superlative")})
end
else
insert(data.inflections, sup)
end
end
pos_functions["suffixes-adverb"] = pos_functions["adverbs"]
local function get_forms(forms)
if #forms == 0 then
return nil
end
local i, attested = 1, false
while true do
local form = forms[i]
if form == nil then
return forms, attested
elseif form == "-" then
remove(forms, i)
else
if not (attested or get_plaintext(form):sub(1, 1) == "*") then
attested = true
end
i = i + 1
end
end
end
local function degree(pos, deg, other_arg, other_label, args, data)
local boolean = {type = "boolean"}
local list = {list = true}
local params = {
[1] = {alias_of = "head", list = false},
["head"] = list,
["positive"] = list,
[other_arg] = list,
["indecl"] = boolean,
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
if args.indecl then
insert(data.inflections, {label = glossary_link("indeclinable")})
end
local positive, positive_attested = get_forms(args.positive)
if positive then
if not positive_attested then
insert(data.categories, "Englisc " .. deg .. "-only " .. pos)
end
if #positive > 0 then
args.positive.label = "positive"
insert(data.inflections, args.positive)
else
insert(data.inflections, {label = "no positive form"})
end
end
local other = get_forms(args[other_arg])
if other then
if #other > 0 then
args[other_arg].label = other_label
insert(data.inflections, args[other_arg])
else
insert(data.inflections, {label = "no " .. other_label .. " form"})
end
end
-- If a lemma, return the primary part of speech ("adjectives" or
-- "adverbs"), so that the term is categorized in "Old English adjectives"
-- or "Old English adverbs". Otherwise, return nothing, so that the term
-- goes in the relevant non-lemma category (e.g. "Old English comparative
-- adjectives"), and into "Old English non-lemma forms".
if positive and not positive_attested then
return pos
end
end
pos_functions["comparative adjectives"] = function(def, args, data)
return degree("adjectives", "comparative", "sup", "superlative", args, data)
end
pos_functions["superlative adjectives"] = function(def, args, data)
return degree("adjectives", "superlative", "comp", "comparative", args, data)
end
pos_functions["comparative adverbs"] = function(def, args, data)
return degree("adverbs", "comparative", "sup", "superlative", args, data)
end
pos_functions["superlative adverbs"] = function(def, args, data)
return degree("adverbs", "superlative", "comp", "comparative", args, data)
end
local function non_lemma_forms(def, args, data)
local params = {
[1] = {required = true, default = def}, -- headword or cases
["head"] = {list = true, require_index = true},
["g"] = {list = true},
["id"] = true,
}
local args = require("Module:parameters").process(args, params)
local heads = {args[1]}
for _, head in ipairs(args.head) do
insert(heads, head)
end
data.heads = heads
data.genders = args.g
data.id = args.id
end
pos_functions["noun forms"] = non_lemma_forms
pos_functions["proper noun forms"] = non_lemma_forms
pos_functions["pronoun forms"] = non_lemma_forms
pos_functions["verb forms"] = non_lemma_forms
pos_functions["adjective forms"] = non_lemma_forms
pos_functions["participle forms"] = non_lemma_forms
pos_functions["determiner forms"] = non_lemma_forms
pos_functions["numeral forms"] = non_lemma_forms
pos_functions["suffix forms"] = non_lemma_forms
return export
1r03t2m843ip73o8dodh02dy9g4cppf
Module:headword utilities
828
8053
54918
54857
2026-09-29T00:01:00Z
Deadend0914
7211
54918
Scribunto
text/plain
local export = {}
local require_when_needed = require("Module:utilities/require when needed")
local affix_module = "Module:affix"
local debug_track_module = "Module:debug/track"
local decorations_module = "Module:decorations"
local en_utilities_module = "Module:en-utilities"
local fun_is_callable_module = "Module:fun/isCallable"
local headword_module = "Module:headword"
local headword_data_module = "Module:headword/data"
local languages_module = "Module:languages"
local links_module = "Module:links"
local parameters_module = "Module:parameters"
local parse_interface_module = "Module:parse interface"
local parse_utilities_module = "Module:parse utilities"
local string_pattern_escape_module = "Module:string/patternEscape"
local string_replacement_escape_module = "Module:string/replacementEscape"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local yesno_module = "Module:yesno"
local dump = mw.dumpObject
local unpack = unpack or table.unpack -- Lua 5.2 compatibility
local insert = table.insert
local concat = table.concat
local remove = table.remove
local sort = table.sort
local deep_equals = require_when_needed(table_module, "deepEquals")
local extend = require_when_needed(table_module, "extend")
local insert_if_not = require_when_needed(table_module, "insertIfNot")
local list_to_set = require_when_needed(table_module, "listToSet")
local serial_comma_join = require_when_needed(table_module, "serialCommaJoin")
local shallow_copy = require_when_needed(table_module, "shallowCopy")
local split = require_when_needed(string_utilities_module, "split")
local ugsub = require_when_needed(string_utilities_module, "gsub")
local umatch = require_when_needed(string_utilities_module, "match")
local pattern_escape = require_when_needed(string_pattern_escape_module)
local replacement_escape = require_when_needed(string_replacement_escape_module)
local escape_wikicode = require_when_needed(parse_utilities_module, "escape_wikicode")
local parse_inline_modifiers = require_when_needed(parse_utilities_module, "parse_inline_modifiers")
local term_contains_top_level_html = require_when_needed(parse_utilities_module, "term_contains_top_level_html")
local get_lang_by_code = require_when_needed(languages_module, "getByCode")
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
local is_callable = require_when_needed(fun_is_callable_module)
local format_decorations = require_when_needed(decorations_module, "format_decorations")
local function split_on_comma(val)
if val:find(",") then
return require(parse_interface_module).split_on_comma(val)
else
return {val}
end
end
local function ine(val)
if val == "" then return nil else return val end
end
--[=[
Add decorations to a term. `termobj` is the object describing the term, which should optionally contain:
* left qualifiers in `q`, an array of strings;
* right qualifiers in `qq`, an array of strings;
* left labels in `l`, an array of strings;
* right labels in `ll`, an array of strings;
* references in `refs`, an array either of strings (formatted reference text) or objects containing fields `text`
(formatted reference text) and optionally `name` and/or `group`;
`text` is the text of the term itself, and `lang` is the language object.
]=]
local function add_decorations(text, termobj, lang)
local function field_non_empty(field)
local list = termobj[field]
if not list then
return nil
end
if type(list) ~= "table" then
error(("Internal error: Wrong type for `termobj.%s`=%s, should be \"table\""):format(
field, mw.dumpObject(list)))
end
return list[1]
end
if field_non_empty("q") or field_non_empty("qq") or field_non_empty("l") or field_non_empty("ll") or
field_non_empty("refs") then
text = format_decorations {
lang = lang,
text = text,
q = termobj.q,
qq = termobj.qq,
l = termobj.l,
ll = termobj.ll,
refs = termobj.refs,
}
end
return text
end
local param_mods = {
id = {}, -- disabled when `is_head = true`
q = {type = "qualifier"},
qq = {type = "qualifier"},
l = {type = "labels"},
ll = {type = "labels"},
-- [[Module:headword]] expects part references in `.refs`.
ref = {item_dest = "refs", type = "references", store = "insert-flattened"},
}
local optional_param_mods = {
g = {item_dest = "genders", type = "genders"},
alt = {},
lang = {type = "language"},
sc = {type = "script"},
t = {item_dest = "gloss"},
gloss = {},
pos = {},
lit = {},
tr = {},
ts = {},
face = {},
nolinkinfl = {type = "boolean"},
}
local optional_headword_param_mods = {
sc = {type = "script"},
tr = {},
ts = {},
}
--[==[
Parse a single inflection or headword form or list of such forms. In either case, inline modifiers may be attached.
`data` is an object with the following fields:
* `val`: The raw value to parse. Required.
* `paramname`: The name of the parameter from which the value was taken; used in error messages. Required.
* `is_head`: We are parsing a headword parameter (a value which goes into the `heads` field of `data`). This changes
the allowed modifiers, disabling the `id` modifier and only allowing a subset of optional modifiers.
* `frob`: An optional function of one value to apply to the form after inline modifiers have been removed (i.e. to
apply to the `.term` field of the returned object).
* `include_mods`: List of extra inline modifiers to include, besides the default ones (see below). Each list item is
either a string specifying a recognized extra inline modifier (see `optional_param_mods` in the code), or a two-item
list of modifier name and modifier spec, where the spec should follow the syntax for modifier specs in
`parse_inline_modifiers` in [[Module:parse utilities]].
* `exclude_mods`: List of default inline modifiers to not include.
* `splitchar`: If specified, the value in `val` can be a list of forms to parse, separated by the value of `splitchar`
(which is a Lua pattern, as in `parse_inline_modifiers` in [[Module:parse utilities]]). Most commonly, `splitchar` is
a single comma and the values are comma-separated (in this case, splitting will not happen if a space follows the
comma).
* `parse_lang_prefix`: If specified, allow a language prefix to precede a form, and if found, store into the `.lang`
field of the returned object.
* `preserve_splitchar`, `delimiter_key`, `escape_fun`, `unescape_fun`, `pre_normalize_modifiers`: As in
`parse_inline_modifiers` in [[Module:parse utilities]].
Returns an object suitable for storing as one element of one of the lists in `headdata.inflections`, where `headdata`
is the structure passed to [[Module:headword]]. If `splitchar` is specified, howeve, the return value is a list of such
objects.
The following default inline modifiers are currently recognized:
* `q`: Left qualifier.
* `qq`: Right qualifier.
* `l`: Comma-separated list of left labels. No space should follow the comma.
* `ll`: Comma-separated list of right labels. No space should follow the comma.
* `ref`: Reference or references. See {{tl|IPA}} for the syntax.
* `id`: Sense ID, in case there are multiple senses. See {{tl|l}}.
The following are the recognized additional inline modifiers:
* `g`: Comma-separated list of genders.
* `alt`: Display text.
* `lang`: Language code of language of the form, if different from the language of the headword.
* `sc`: Script code of script of the form. Almost never needed.
* `t`: Gloss for the form.
* `gloss`: Gloss for the form (alias for `t`).
* `pos`: Part of speech of the form.
* `lit`: Literal meaning of the form.
* `tr`: Manual transliteration of the form.
* `ts`: Transcription of the form, for languages where the transliteration differs markedly from the pronunciation.
* `face`: Face to display the form in, e.g. {"hypothetical"} for a hypothetical form (unlinkable and displayed in italics).
* `nolinkinfl`: Make the form unlinkable.
]==]
function export.parse_term_with_modifiers(data)
local paramname, val, frob = data.paramname, data.val, data.frob
local function generate_obj(term, parse_err)
if frob then
term = frob(term, parse_err)
end
if data.parse_lang_prefix and term:find(":") then
return require(parse_utilities_module).generate_obj_maybe_parsing_lang_prefix {
term = term,
paramname = paramname,
parse_lang_prefix = true,
parse_err = parse_err,
}
else
return {term = term}
end
end
-- Check for inline modifier, e.g. מרים<tr:Miryem>. But exclude top-level HTML entry with <span ...>,
-- <sup> or similar in it.
if (val:find("<", nil, true) or data.splitchar) and not term_contains_top_level_html(val) and
-- don't parse inline modifiers if is_head and the value begins with a ~ (link modifier syntax)
(not data.is_head or not val:find("^~")) then
local param_mods = param_mods
if data.is_head then
param_mods = shallow_copy(param_mods)
param_mods.id = nil
end
if data.include_mods or data.exclude_mods then
if not data.is_head then
-- already copied when data.is_head
param_mods = shallow_copy(param_mods)
end
if data.include_mods then
local optional_mods = data.is_head and optional_headword_param_mods or optional_param_mods
for _, mod in ipairs(data.include_mods) do
if type(mod) == "table" then
if #mod ~= 2 then
error(("Internal error: Modifier spec %s in `include_mods` should be of length 2"):format(
dump(mod)))
end
local modkey, modvalue = unpack(mod)
param_mods[modkey] = modvalue
elseif not optional_mods[mod] then
error(("Internal error: Unrecognized modifier spec %s in `include_mods`"):format(
dump(mod)))
else
param_mods[mod] = optional_mods[mod]
end
end
end
if data.exclude_mods then
for _, mod in ipairs(data.exclude_mods) do
if not param_mods[mod] then
error(("Internal error: Modifier spec %s in `exclude_mods` not found among existing modifiers"
):format(dump(mod)))
else
param_mods[mod] = nil
end
end
end
end
return parse_inline_modifiers(val, {
paramname = paramname,
param_mods = param_mods,
generate_obj = generate_obj,
splitchar = data.splitchar,
preserve_splitchar = data.preserve_splitchar,
delimiter_key = data.delimiter_key,
escape_fun = data.escape_fun,
unescape_fun = data.unescape_fun,
pre_normalize_modifiers = data.pre_normalize_modifiers,
})
else
local retval = generate_obj(val)
if data.splitchar then
retval = {retval}
end
return retval
end
end
--[==[
Parse a list of inflection forms that may have inline modifiers attached. `data` is an object with the following fields:
* `forms`: The list of raw values to parse. Required.
* `paramname`: The name of the first parameter from which the value was taken; used in error messages. If this is a
two-element list, the first element is the first parameter and the second element is the prefix of the remaining
parameters. Parameter names that are numbers are handled correctly, as are those with \1 in it marking where the
parameter index goes. Required.
* `qualifiers`: If specified, a possibly gappy list of left qualifiers to add to the parsed terms (for compatibility
purposes).
* `splitchar`: As in `parse_term_with_modifiers()`. The resulting per-term lists will be flattened.
* `frob`, `include_mods`, `exclude_mods`, `is_head`, `preserve_splitchar`, `parse_lang_prefix`, `delimiter_key`,
`escape_fun`, `unescape_fun`, `pre_normalize_modifiers`: As in `parse_term_with_modifiers()`.
Returns a list of objects, suitable for storing as one of the lists in `headdata.inflections` (once a label is added),
where `headdata` is the structure passed to [[Module:headword]].
]==]
function export.parse_term_list_with_modifiers(data)
local paramname, forms = data.paramname, data.forms
local qualifiers = data.qualifiers
local first, restpref
if type(paramname) == "table" then
first = paramname[1]
restpref = paramname[2]
else
first = paramname
restpref = paramname
end
local terms = {}
data = shallow_copy(data)
for i, val in ipairs(forms) do
data.paramname = i == 1 and first or type(restpref) == "number" and restpref + i - 1 or
restpref:find("\1", nil, true) and restpref:gsub("\1", tostring(i)) or restpref .. i
data.val = val
local parsed = export.parse_term_with_modifiers(data)
if qualifiers and qualifiers[i] then
if data.splitchar then
for _, term in ipairs(parsed) do
term.q = {qualifiers[i]}
end
else
parsed.q = {qualifiers[i]}
end
end
if data.splitchar then
extend(terms, parsed)
else
terms[i] = parsed
end
end
return terms
end
--[==[
Construct a link to [[Appendix:Glossary]] for `entry`. If `text` is specified, it is the display text; otherwise,
`entry` is used.
]==]
function export.glossary_link(entry, text)
text = text or entry
return "[[Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end
function export.replace_glossary_links_in_label(label)
if label:find("<<", nil, true) then
label = label:gsub("<<(.-)|(.-)>>", export.glossary_link):gsub("<<(.-)>>", export.glossary_link)
end
return label
end
--[==[
Insert a fixed inflection (a label not associated with any inflection values) into an `inflections` field. The
`inflections` field will be initialized if needed. `data` is an object with the following fields:
* `headdata`: The headword structure passed to [[Module:headword]]. Required.
* `inflobj`: The object whose `inflections` field the terms are inserted into. Defaults to `headdata`. Only needs
to be set for nested inflections, which are specified for an inflection object rather than the headword data
structure as a whole.
* `label`: The label that the inflections are given; any parts of the label surrounded in `<<...>>` are linked to the
glossary. (If the contents of `<<...>>` contain a `|` in them, they are a two-part link.) Required.
* `originating_term`: The term object from which this label is derived. If specified, decorations will be taken from
this object.
]==]
function export.insert_fixed_inflection(data)
local headdata, origterm, label = data.headdata, data.originating_term, data.label
local inflobj = data.inflobj or headdata
inflobj.inflections = inflobj.inflections or {}
if not origterm then
insert(inflobj.inflections, {
label = export.replace_glossary_links_in_label(label)
})
else
if origterm.id then
error(("It doesn't make sense to pass in an ID '%s' for label '%s' in conjunction with a term value '%s'"
):format(origterm.id, label, origterm.term))
end
origterm = shallow_copy(origterm)
-- Preserve decorations
origterm.term = nil
origterm.label = export.replace_glossary_links_in_label(label)
insert(inflobj.inflections, origterm)
end
end
--[==[
Insert previously-parsed terms into an `inflections` field. The `inflections` field will be initialized if needed.
`data` is an object with the following fields:
* `headdata`: The headword structure passed to [[Module:headword]]. Required.
* `inflobj`: The object whose `inflections` field the terms are inserted into. Defaults to `headdata`. Only needs
to be set for nested inflections, which are specified for an inflection object rather than the headword data
structure as a whole.
* `terms`: The list of parsed terms. If {nil} or omitted, nothing happens unless `request` is set.
* `label`: The label that the inflections are given; any parts of the label surrounded in `<<...>>` are linked to the
glossary. (If the contents of `<<...>>` contain a `|` in them, they are a two-part link.) Required.
* `no_label`: If the term is {"-"} and there are no other terms, insert a fixed label with this value. Defaults to
{"no "} plus the label.
* `usually_no_label`: If the term is {"-"} and there are other terms, insert a fixed label with this value. Defaults to
{"usually no "} plus the label.
* `cats`: List of categories to insert when terms are given that are not {"-"}. Each category is a string naming a full
category to insert (including the appropriate language name prefixed).
* `no_cats`: List of categories to insert when a term is given as {"-"}.
* `usually_no_cats`: List of categories to insert when a term is given as {"-"} and additional terms are specified as
well (representing, e.g. for the inflection {"plural"}, a term which usually has no plural but does under some
circumstances). If omitted, both the categories in `cats` and `no_cats` are inserted.
* `accel`: If specified, a full accelerator object to add to the inflections.
* `request`: If specified and no terms are given, insert a label with a request for inflections to be given.
* `enable_auto_translit`: If specified and terms are given, display automatic transliteration of the terms.
The return value indicates whether the inflection exists and how many terms are in it. It is an object with the
following fields:
* `exists`: {"yes"} if one or more terms were specified; {"no"} if the value was given as {"-"}; {"usually no"} if
the first value was given as {"-"} but additional terms were supplied; otherwise {nil}, indicating that the status
is unspecified.
* `numterms`: Number of terms in the inflection. Will be 0 unless `exists` has the value {"yes"} or {"usually no"}.
* `request`: True if no terms were specified but a term request was inserted into the inflection (because
`data.request` was specified). Otherwise {nil}.
]==]
function export.insert_inflection(data)
local headdata, terms, label = data.headdata, data.terms, data.label
local inflobj = data.inflobj or headdata
local retval = {}
local accel = data.accel
if data.accel_form then
if accel then
error("Internal error: can't specify both data.accel and data.accel_form")
end
if headdata.heads then
local lemmas = {}
local lemma_translits = {}
for i, headobj in ipairs(headdata.heads) do
lemmas[i] = headobj.term
if lemmas[i] == "+" then
error("Internal error: If you use data.accel_form, you should have resolved all occurrences of + in heads appropriately")
end
lemma_translits[i] = headobj.tr
end
accel = {
lemma = lemmas,
lemma_translit = lemma_translits,
form = data.accel_form,
}
else
accel = {
form = data.accel_form,
}
end
end
local function insert_cats(cats)
for _, cat in ipairs(cats) do
insert(headdata.categories, cat)
end
end
if terms and terms[1] then
terms = shallow_copy(terms)
if terms[1].term == "-" then
if terms[2] then
export.insert_fixed_inflection {
headdata = headdata,
inflobj = inflobj,
originating_term = terms[1],
label = data.usually_no_label or "usually no " .. label,
}
remove(terms, 1)
retval.numterms = #terms
retval.exists = "usually no"
if data.usually_no_cats then
insert_cats(data.usually_no_cats)
else
if data.no_cats then
insert_cats(data.no_cats)
end
if data.cats then
insert_cats(data.cats)
end
end
else
export.insert_fixed_inflection {
headdata = headdata,
inflobj = inflobj,
originating_term = terms[1],
label = data.no_label or "no " .. label,
}
retval.numterms = 0
retval.exists = "no"
if data.no_cats then
insert_cats(data.no_cats)
end
return retval
end
else
retval.numterms = #terms
retval.exists = "yes"
if data.cats then
insert_cats(data.cats)
end
end
if data.check_missing then
error("Internal error: check_missing support removed; use checkredlinks=true in [[Module:headword]]")
end
terms.label = export.replace_glossary_links_in_label(label)
if accel then
terms.accel = accel
end
terms.enable_auto_translit = data.enable_auto_translit
inflobj.inflections = inflobj.inflections or {}
insert(inflobj.inflections, terms)
elseif data.request then
inflobj.inflections = inflobj.inflections or {}
insert(inflobj.inflections, {
label = export.replace_glossary_links_in_label(label),
request = true,
})
retval.numterms = 0
-- retval.exists = nil
retval.request = true
else
retval.numterms = 0
-- retval.exists = nil
end
return retval
end
--[==[
Parse raw arguments from `forms` for inline modifiers, and insert the resulting terms (which should not require
significant additional processing) into `headdata.inflections`. `data` is an object with the following fields:
* `forms`: The list of raw values to parse. If {nil} or omitted, nothing happens.
* `headdata`: The headword structure passed to [[Module:headword]]. Required.
* `paramname`: As in `parse_term_list_with_modifiers()`. Required.
* `label`: As in `insert_inflection()`. Required.
* `qualifiers`, `frob`, `include_mods`, `exclude_mods`, `is_head`, `splitchar`, `preserve_splitchar`, `delimiter_key`,
`escape_fun`, `unescape_fun`, `pre_normalize_modifiers`: As in `parse_term_list_with_modifiers()`.
* `accel`: As in `insert_inflection()`.
Return value is as in `insert_inflection()`.
]==]
function export.parse_and_insert_inflection(data)
local forms = data.forms
if forms and forms[1] then
data = shallow_copy(data)
data.forms = forms
data.terms = export.parse_term_list_with_modifiers(data)
return export.insert_inflection(data)
end
return {
numterms = 0
}
end
--[==[
Canonicalize a single term or term-like object or a list of either into a list of term-like objects. `abterms` is the
term or list to canonicalize, and `field` is the name of the field holding the term (defaulting to {"term"}). This
does the minimal work necessary, meaning that the return value may partly or completely share memory with the value
passed in. As a special case, if `abterms` is {nil}, {nil} is returned. If `origin_val` is specified, add a field
`origin` containing the value of `origin_val` to each resulting term-like object (in this case, the object will be
copied a necessary to avoid side-effecting the passed-in objects).
]==]
function export.canonicalize_termobj_list(abterms, field, origin_val)
if abterms == nil then
return nil
end
field = field or "term"
if type(abterms) == "string" then
return {{[field] = abterms, origin = origin_val}}
elseif not abterms[1] then
if origin_val ~= nil then
abterms = shallow_copy(abterms)
abterms.origin = origin_val
end
return {abterms}
else
-- Check if already in full list term and return directly if so (unless `origin_val` is given, in which case we
-- need to shallow-copy both the list and each term in it).
local must_convert = false
for _, term in ipairs(abterms) do
if type(term) == "string" then
must_convert = true
break
end
end
if not must_convert then
if origin_val ~= nil then
abterms = shallow_copy(abterms)
for i, abterm in ipairs(abterms) do
abterms[i] = shallow_copy(abterm)
abterms[i].origin = origin_val
end
end
return abterms
end
end
local retval = {}
for _, term in ipairs(abterms) do
if type(term) == "string" then
insert(retval, {[field] = term, origin = origin_val})
else
if origin_val ~= nil then
term = shallow_copy(term)
term.origin = origin_val
end
insert(retval, term)
end
end
return retval
end
--[==[
Combine two sets of decorations. If either is {nil}, just return the other, and if both are {nil}, return {nil}.
]==]
function export.combine_decorations(decs1, decs2)
if not decs1 and not decs2 then
return nil
end
if not decs1 then
return decs2
end
if not decs2 then
return decs1
end
local combined = shallow_copy(decs1)
for _, dec in ipairs(decs2) do
insert_if_not(combined, dec)
end
return combined
end
function export.combine_qualifiers_or_labels(...)
-- FIXME: Added 2026-09-17. Remove after a month.
error("Use combine_decorations instead")
end
--[==[
Combine the decorations (qualifiers, labels, references) and ID's of two term objects. `destobj` is the "destination
term object" into which the combined properties are written, and `srcobj` is the "source object" into which the
properties are merged. `destobj` is side-effected (but the lists inside of `destobj` are not); if this is undesirable,
make sure to shallow-copy `destobj` first. If both objects have values for a given decoration, the values of `destobj`
come first. If both objects have a value for `id`, the values must match or an error is thrown; otherwise, the resulting
value of `id` comes from whichever one is defined.
'''NOTE:''' This may not be the correct behavior when deduplicating a list of term objects. See
`insert_termobj_combining_duplicates` for a different approach.
]==]
function export.combine_termobj_decorations(destobj, srcobj)
destobj.q = export.combine_decorations(destobj.q, srcobj.q)
destobj.qq = export.combine_decorations(destobj.qq, srcobj.qq)
destobj.l = export.combine_decorations(destobj.l, srcobj.l)
destobj.ll = export.combine_decorations(destobj.ll, srcobj.ll)
destobj.refs = export.combine_decorations(destobj.refs, srcobj.refs)
if destobj.id and srcobj.id and destobj.id ~= srcobj.id then
-- FIXME: We probably want to pass in an error function
error(("Can't specify two different ID's %s and %s when combining objects"):format(srcobj.id, destobj.id))
end
destobj.id = destobj.id or srcobj.id
return destobj
end
function export.combine_termobj_qualifiers_labels(...)
-- FIXME: Added 2026-09-17. Remove after a month.
error("Use combine_termobj_decorations instead")
end
function export.termobj_has_decorations(obj)
return obj.q and obj.q[1] or obj.qq and obj.qq[1] or obj.l and obj.l[1] or obj.ll and obj.ll[1] or
obj.refs and obj.refs[1]
end
function export.termobj_has_qualifiers_or_labels(...)
-- FIXME: Added 2026-09-17. Remove after a month.
error("Use termobj_has_decorations instead")
end
local function one_decoration_equal(prop1, prop2)
local prop1_is_nil = not prop1 or not prop1[1]
local prop2_is_nil = not prop2 or not prop2[1]
if prop1_is_nil and prop2_is_nil then
return true
end
if prop1_is_nil or prop2_is_nil then
return false
end
return deep_equals(prop1, prop2)
end
function export.termobj_decorations_equal(obj1, obj2)
return one_decoration_equal(obj1.q, obj2.q) and
one_decoration_equal(obj1.qq, obj2.qq) and
one_decoration_equal(obj1.l, obj2.l) and
one_decoration_equal(obj1.ll, obj2.ll) and
one_decoration_equal(obj1.refs, obj2.refs) and
obj1.id == obj2.id
end
function export.termobj_ancillary_properties_equal(...)
-- FIXME: Added 2026-09-17. Remove after a month.
error("Use termobj_decorations_equal instead")
end
function export.convert_termobj_to_formobj(termobj)
local formobj = {
form = termobj.term,
translit = termobj.tr,
}
local footnotes
local function mods_to_footnote(mod_prefix, mod_vals)
if mod_vals and mod_vals[1] then
footnotes = footnotes or {}
for _, val in ipairs(mod_vals) do
insert(footnotes, "[" .. mod_prefix .. ":" .. val .. "]")
end
end
end
mods_to_footnote("q", termobj.q)
mods_to_footnote("qq", termobj.qq)
mods_to_footnote("l", termobj.l)
mods_to_footnote("ll", termobj.ll)
mods_to_footnote("ref", termobj.refs)
mods_to_footnote("id", termobj.id and {termobj.id} or nil)
formobj.footnotes = footnotes
return formobj
end
local recognized_multi_mods = {
q = "q",
qq = "qq",
l = "l",
ll = "ll",
ref = "refs",
}
local recognized_single_mods = {
id = "id",
}
function export.add_footnote_to_termobj(termobj, footnote)
local stripped_footnote = footnote:match("^%[(.*)%]$")
if not stripped_footnote then
error("Internal error: Footnote should be surrounded by brackets at this stage: " .. footnote)
end
local prefix, rest = stripped_footnote:match("^([a-z]+):(.+)$")
local field, is_multi
if prefix then
if recognized_multi_mods[prefix] then
field = recognized_multi_mods[prefix]
is_multi = true
elseif recognized_single_mods[prefix] then
field = recognized_single_mods[prefix]
is_multi = false
end
end
if not field then
rest = stripped_footnote
field = "l"
is_multi = true
end
if is_multi then
if not termobj[field] then
termobj[field] = {}
end
insert(termobj[field], rest)
else
if termobj[field] and termobj[field] ~= rest then
error(("Can't set two values for '%s': '%s' and '%s'"):format(field, termobj[field], rest))
end
termobj[field] = rest
end
end
function export.convert_formobj_to_termobj(formobj)
local termobj = {
term = formobj.form,
tr = formobj.translit,
}
if formobj.footnotes then
for _, footnote in ipairs(formobj.footnotes) do
export.add_footnote_to_termobj(termobj, footnote)
end
end
return termobj
end
local function extract_termobj_field_modifiers(fieldval)
return fieldval:match("^([*+]?)(.*)$")
end
function export.remove_termobj_field_modifiers(termobj)
local function remove_field_modifiers(field)
if termobj[field] and termobj[field][1] then
local any_field_modifiers = false
for _, val in ipairs(termobj[field]) do
local field_mods, _ = extract_termobj_field_modifiers(val)
if field_mods ~= "" then
any_field_modifiers = true
break
end
end
local new_field = {}
if any_field_modifiers then
for _, val in ipairs(termobj[field]) do
local _, field_without_mods = extract_termobj_field_modifiers(val)
insert_if_not(new_field, field_without_mods)
end
termobj[field] = new_field
end
end
end
remove_field_modifiers("q")
remove_field_modifiers("qq")
remove_field_modifiers("l")
remove_field_modifiers("ll")
remove_field_modifiers("refs")
end
function export.insert_termobj_combining_duplicates(destobjs, termobj)
for _, destobj in ipairs(destobjs) do
if destobj.term == termobj.term and destobj.tr == termobj.tr then
-- Form already present; maybe combine footnotes.
local function combine_field_values(field)
if termobj[field] and termobj[field][1] then
-- Check to see if there are existing values with *; if so, remove them.
if destobj[field] and destobj[field][1] then
local any_values_with_asterisk = false
for _, val in ipairs(destobj[field]) do
local field_mods, _ = extract_termobj_field_modifiers(val)
if field_mods:find("%*") then
any_values_with_asterisk = true
break
end
end
if any_values_with_asterisk then
local filtered_values = {}
for _, val in ipairs(destobj[field]) do
local field_mods, _ = extract_termobj_field_modifiers(val)
if not field_mods:find("%*") then
insert(filtered_values, val)
end
end
if filtered_values[1] then
destobj[field] = filtered_values
else
destobj[field] = nil
end
end
end
local any_footnotes_with_plus = false
for _, val in ipairs(termobj[field]) do
local field_mods, _ = extract_termobj_field_modifiers(val)
if field_mods:find("%+") then
any_footnotes_with_plus = true
break
end
end
if any_footnotes_with_plus then
if not destobj[field] then
destobj[field] = {}
else
destobj[field] = shallow_copy(destobj[field])
end
for _, val in ipairs(termobj[field]) do
local already_seen = false
local field_mods, field_without_mods = extract_termobj_field_modifiers(val)
if field_mods:find("%+") then
for _, existing_val in ipairs(destobj[field]) do
local _, existing_field_without_mods =
extract_termobj_field_modifiers(existing_val)
if existing_field_without_mods == field_without_mods then
already_seen = true
break
end
end
if not already_seen then
insert(destobj[field], val)
end
end
end
end
end
end
combine_field_values("q")
combine_field_values("qq")
combine_field_values("l")
combine_field_values("ll")
combine_field_values("refs")
if destobj.id and termobj.id and destobj.id ~= termobj.id then
-- FIXME: We probably want to pass in an error function
error(("Can't specify two different ID's %s and %s when combining objects"):format(termobj.id, destobj.id))
end
destobj.id = destobj.id or termobj.id
return
end
end
insert(destobjs, termobj)
end
export.allowed_special_indicators = {
["first"] = true,
["first-second"] = true,
["first-last"] = true,
["second"] = true,
["last"] = true,
["each"] = true,
["+"] = true, -- requests the default behavior with preposition handling
}
--[==[
Check for special indicators (values such as {"+first"} or {"+first-last"} that are used in a `pl`, `f`, etc. argument
and indicate how to inflect a multiword term). If `form` is such an indicator, the return value is `form` minus
the initial `+` sign; otherwise, if form begins with a `+` sign, an error is thrown; otherwise the return value is nil.
]==]
function export.get_special_indicator(form, noerror)
if form:find("^%+") then
form = form:gsub("^%+", "")
if not export.allowed_special_indicators[form] then
if noerror then
return nil
end
local indicators = {}
for indic, _ in pairs(export.allowed_special_indicators) do
insert(indicators, "+" .. indic)
end
sort(indicators)
error("Special inflection indicator beginning with '+' can only be " ..
mw.text.listToText(indicators) .. ": +" .. form)
end
return form
end
return nil
end
local function add_endings(bases, endings)
local retval = {}
if type(bases) ~= "table" then
bases = {bases}
end
if type(endings) ~= "table" then
endings = {endings}
end
for _, base in ipairs(bases) do
for _, ending in ipairs(endings) do
insert(retval, base .. ending)
end
end
return retval
end
--[==[
Inflect a possibly multiword or hyphenated term `form` using the function `inflect`, which is a function of one argument
that is called on a single word to inflect and should return either the inflected word or a list of inflected words.
`special` indicates how to inflect the multiword term and should be e.g. {"first"} to inflect only the first word,
{"first-last"} to inflect the first and last words, {"each"} to inflect each word, etc. See `allowed_special_indicators`
above for the possibilities. If `special` is `+`, or is omitted and the term is multiword (i.e. containing a space
character), and `prepositions` is supplied, the function checks for multiword or hyphenated terms containing the
prepositions in `prepositions`, e.g. Italian [[senso di marcia]] or [[medaglia d'oro]] or Portuguese
[[tartaruga-do-mar]]. If such a term is found, only the first word is inflected. Otherwise, the default is
{"first-last"}. `prepositions` is a list of Lua patterns matching prepositions. The patterns will automatically have the
separator character (space or hyphen) added to the left side but not the right side, so they should contain a space
character (which will automatically be converted to the appropriate separator) on the right side unless the preposition
is joined on the right side with an apostrophe. Examples of preposition patterns for Italian are {"di "}, {"sull'"} and
{"d?all[oae] "} (which matches {"dallo "}, {"dalle "}, {"alla "}, etc.).
The return value is always either a list of inflected multiword or hyphenated terms, or nil if `special` is omitted
and `form` is not multiword. (If `special` is specified and `form` is not multiword or hyphenated, an error results.)
]==]
function export.handle_multiword(form, special, inflect, prepositions, sep)
sep = sep or form:find(" ") and " " or "%-"
local raw_sep = sep == " " and " " or "-"
-- Used to add regex version of separator in the replacement portion of ugsub() or :gsub()
local sep_replacement = sep == " " and " " or "%%-"
-- Given a Lua pattern, replace space with the appropriate separator.
local function hack_re(re)
if sep == " " then
return re
end
return (re:gsub(" ", sep_replacement))
end
if special == "first" then
local first, rest = form:match(hack_re("^(.-)( .*)$"))
if not first then
error("Special indicator 'first' can only be used with a multiword term: " .. form)
end
return add_endings(inflect(first), rest)
elseif special == "second" then
local first, second, rest = form:match(hack_re("^([^ ]+ )([^ ]+)( .*)$"))
if not first then
error("Special indicator 'second' can only be used with a term with three or more words: " .. form)
end
return add_endings(add_endings({first}, inflect(second)), rest)
elseif special == "first-second" then
local first, space, second, rest = form:match(hack_re("^([^ ]+)( )([^ ]+)( .*)$"))
if not first then
error("Special indicator 'first-second' can only be used with a term with three or more words: " .. form)
end
return add_endings(add_endings(add_endings(inflect(first), space), inflect(second)), rest)
elseif special == "each" then
local terms = split(form, sep)
if #terms < 2 then
error("Special indicator 'each' can only be used with a multiword term: " .. form)
end
for i, term in ipairs(terms) do
terms[i] = inflect(term)
if i > 1 then
terms[i] = add_endings(raw_sep, terms[i])
end
end
local result = ""
for _, term in ipairs(terms) do
result = add_endings(result, term)
end
return result
elseif special == "first-last" then
local first, middle, last = form:match(hack_re("^(.-)( .* )(.-)$"))
if not first then
first, middle, last = form:match(hack_re("^(.-)( )(.*)$"))
end
if not first then
error("Special indicator 'first-last' can only be used with a multiword term: " .. form)
end
return add_endings(add_endings(inflect(first), middle), inflect(last))
elseif special == "last" then
local rest, last = form:match(hack_re("^(.* )(.-)$"))
if not rest then
error("Special indicator 'last' can only be used with a multiword term: " .. form)
end
return add_endings(rest, inflect(last))
elseif special and special ~= "+" then
error("Unrecognized special=" .. special)
end
-- Only do default behavior if special indicator '+' explicitly given or separator is space; otherwise we will
-- break existing behavior with hyphenated words.
if (special == "+" or sep == " ") and form:find(sep) then
if prepositions then
-- check for prepositions in the middle of the word; do it this way so we can handle
-- more than one word before the preposition (and usually inflect each word)
for _, prep in ipairs(prepositions) do
local first, space_prep_rest = umatch(form, hack_re("^(.-)( " .. prep .. ".*)$"))
if first then
return add_endings(inflect(first), space_prep_rest)
end
end
end
-- multiword or hyphenated expressions default to first-last; we need to pass in the separator to avoid
-- problems with multiword terms containing hyphens in the individual words
return export.handle_multiword(form, "first-last", inflect, prepositions, sep)
end
return nil
end
local function link_hyphen_split_component(word, data)
if data.link_hyphen_split_component then
return data.link_hyphen_split_component(word)
else
return "[[" .. word .. "]]"
end
end
-- Default function to split a word on apostrophes. Don't split apostrophes at the beginning or end of a word (e.g.
-- [['ndrangheta]] or [[po']]). Handle multiple apostrophes correctly, e.g. [[l'altr'ieri]] -> [[l']][altr']][[ieri]].
function export.default_split_apostrophe(word, data)
local apostrophe_parts = split(word, "'", true, true)
local linked_apostrophe_parts = {}
local apostrophes_at_beginning = ""
local i = 1
-- Apostrophes at beginning get attached to the first word after (which will always exist but may
-- be blank if the word consists only of apostrophes).
while i < #apostrophe_parts do -- <, not <=, in case the word consists only of apostrophes
local apostrophe_part = apostrophe_parts[i]
i = i + 1
if apostrophe_part == "" then
apostrophes_at_beginning = apostrophes_at_beginning .. "'"
else
break
end
end
apostrophe_parts[i] = apostrophes_at_beginning .. apostrophe_parts[i]
-- Now, do the remaining parts. A blank part indicates more than one apostrophe in a row; we join
-- all of them to the preceding word.
while i <= #apostrophe_parts do
local apostrophe_part = apostrophe_parts[i]
if apostrophe_part == "" then
linked_apostrophe_parts[#linked_apostrophe_parts] =
linked_apostrophe_parts[#linked_apostrophe_parts] .. "'"
elseif i == #apostrophe_parts then
insert(linked_apostrophe_parts, apostrophe_part)
else
insert(linked_apostrophe_parts, apostrophe_part .. "'")
end
i = i + 1
end
for j, tolink in ipairs(linked_apostrophe_parts) do
linked_apostrophe_parts[j] = link_hyphen_split_component(tolink, data)
end
return concat(linked_apostrophe_parts)
end
--[=[
Auto-add links to a word that should not have spaces but may have hyphens and/or apostrophes. We split off final
punctuation, then split on hyphens if `data.split_hyphen` is given, and also split on apostrophes if
`data.split_apostrophe` is given. We only split on hyphens if they are in the middle of the word, not at the beginning
or end (hyphens at the beginning or end indicate suffixes or prefixes, respectively). `include_hyphen_prefixes`, if
given, is a set of prefixes (not including the final hyphen) where we should include the final hyphen in the prefix.
Hence, e.g. if "anti" is in the set, a Portuguese word like [[anti-herói]] "anti-hero" will be split [[anti-]][[herói]]
(whereas a word like [[código-fonte]] "source code" will be split as [[código]]-[[fonte]]).
If `data.split_apostrophe` is specified, we split on apostrophes unless `data.no_split_apostrophe_words` is given and
the word is in the specified set, such as French [[c'est]] and [[quelqu'un]]. If `data.split_apostrophe` is true, the
default algorithm applies, which splits on all apostrophes except those at the beginning and end of a word (as in
Italian [['ndrangheta]] or [[po']]), and includes the apostrophe in the link to its left (so we auto-split French
[[l'eau]] as [[l']][[eau]] and [[l'altr'ieri]] as [[l']][altr']][[ieri]]). If `data.split_apostrophe` is specified
but not `true`, it should be a function of one argument that does custom apostrophe-splitting. The argument is the word
to split, and the return value should be the split and linked word.
]=]
local function add_single_word_links(space_word, data, term_has_spaces)
local space_word_no_punct, punct
local punct_pattern = data.punctuation
if punct_pattern and is_callable(punct_pattern) then
space_word_no_punct, punct = punct_pattern(space_word)
else
if punct_pattern == nil then
punct_pattern = "[,;:?!]"
end
space_word_no_punct, punct = umatch(space_word, "^(.*)(" .. punct_pattern .. ")$")
end
space_word_no_punct = space_word_no_punct or space_word
punct = punct or ""
local words
if space_word_no_punct:sub(1, 1) == "-" or space_word_no_punct:sub(-1) == "-" then
-- don't split prefixes and suffixes
words = {space_word_no_punct}
else
local splitter
if term_has_spaces then
splitter = data.split_hyphen_when_space
else
splitter = data.split_hyphen_when_no_space
end
if is_callable(splitter) then
words = splitter(space_word_no_punct)
if type(words) == "string" then
return words .. punct
end
end
end
if not words then
local split_hyphen
if term_has_spaces then
split_hyphen = data.split_hyphen_when_space
else
split_hyphen = data.split_hyphen_when_no_space
if split_hyphen == nil then -- default to true; use `false` to avoid this
split_hyphen = true
end
end
if split_hyphen then
words = split(space_word_no_punct, "-", true, true)
else
words = {space_word_no_punct}
end
end
local linked_words = {}
for j, word in ipairs(words) do
if j < #words and data.include_hyphen_prefixes and data.include_hyphen_prefixes[word] then
word = "[[" .. word .. "-]]"
elseif j > 1 and data.include_hyphen_suffixes and data.include_hyphen_suffixes[word] then
word = "[[-" .. word .. "]]"
else
-- Don't split on apostrophes if the word is in `no_split_apostrophe_words`.
if (not data.no_split_apostrophe_words or not data.no_split_apostrophe_words[word]) and
data.split_apostrophe and word:find("'", nil, true) then
if data.split_apostrophe == true then
word = export.default_split_apostrophe(word, data)
else -- custom apostrophe splitter/linker
word = data.split_apostrophe(word)
end
elseif word ~= "" then -- avoid -[[]]- (e.g. f--k)
word = link_hyphen_split_component(word, data)
end
if j < #words then
word = word .. "-"
end
end
insert(linked_words, word)
end
return concat(linked_words) .. punct
end
--[=[
Auto-add links to a multiword term. `data` contains fields customizing how to do this. By default we proceed as follows:
(1) If the term already has embedded links in it, they are left unchanged.
(2) Otherwise, if there are spaces present, we split on spaces and link each word separately.
(3) If a given space-separated component ends in punctuation (defaulting to [,;:?!]), it is separated off, the remainder
of the algorithm run, and the punctuation pasted back on.
(4) If there are hyphens in a given space-separated component, we may link each hyphenated term separately depending
on the settings in `data`. Normally the hyphens are not included in the linked terms, but this can be overridden
for specific prefixes and/or suffixes. By default, if there are spaces in the multiword term, we do not link
hyphenated components (because of cases like "boire du petit-lait" where "petit-lait" should be linked as a whole),
but do so otherwise (e.g. for "avant-avant-hier"); this can overridden for cases like "croyez-le ou non".
Cases where only some of the hyphens should be split can always be handled by explicitly specifying the head (e.g.
"Nord-Pas-de-Calais" given as head=[[Nord]]-[[Pas-de-Calais]]).
(5) If there are apostrophes in a given component, we may link each apostrophe-separated term separately depending
on the settings in `data`, including the apostrophe in the link to its left (so we split "de l'eau" as
"[[de]] [[l']][[eau]]").
The settings in `data` are as follows:
`split_hyphen_when_no_space`: Whether to split on hyphens when the term has no spaces. Defaults to true if set to `nil`.
This can be a function of one argument, to implement a custom splitting algorithm for hyphen-separated terms. If
this returns [FIXME: FINISH ME ...]
If `data.split_apostrophe` is specified, we split on apostrophes unless `data.no_split_apostrophe_words` is given and
the word is in the specified set, such as French [[c'est]] and [[quelqu'un]]. If `data.split_apostrophe` is true, the
default algorithm applies, which splits on all apostrophes except those at the beginning and end of a word (as in
Italian [['ndrangheta]] or [[po']]), and includes the apostrophe in the link to its left (so we auto-split French
[[l'eau]] as [[l']][[eau]] and [[l'altr'ieri]] as [[l']][altr']][[ieri]]). If `data.split_apostrophe` is specified
but not `true`, it should be a function of one argument that does custom apostrophe-splitting. The argument is the word
to split, and the return value should be the split and linked word.
We don't always split on hyphens because of cases like "boire du petit-lait" where "petit-lait" should be linked as a
whole, but provide the option to do it for cases like "croyez-le ou non". If there's no space, however, then it makes
sense to split on hyphens by `no_split_apostrophe_words` and `include_hyphen_prefixes` allow for special-case handling
of particular words and are as described in the comment above add_single_word_links().
]=]
function export.add_links_to_multiword_term(term, data)
if term:match("[%[%]]") then
return term
end
local words = split(term, " ", true, true)
local term_has_spaces = #words > 1
local linked_words = {}
for _, word in ipairs(words) do
insert(linked_words, add_single_word_links(word, data, term_has_spaces))
end
local retval = concat(linked_words, " ")
-- If we ended up with a single link consisting of the entire term,
-- remove the link.
return retval:match("^%[%[([^%[%]]*)%]%]$") or retval
end
local function canonicalize_begin_end_spec(spec)
local from, to = spec:match("^(.-):(.*)$")
if not from then
from = spec
to = ""
end
return from, to
end
--[==[
Given a `linked_term` that is the output of add_links_to_multiword_term(), apply modifications as given in
`modifier_spec` to change the link destination of subterms (normally single-word non-lemma forms; sometimes
collections of adjacent words). This is usually used to link non-lemma forms to their corresponding lemma, but can
also be used to replace a span of adjacent separately-linked words to a single multiword lemma. The format of
`modifier_spec` is one or more semicolon-separated subterm specs, where each such spec is of the form
SUBTERM:DEST, where SUBTERM is one or more words in the `linked_term` but without brackets in them, and DEST is the
corresponding link destination to link the subterm to. Any occurrence of ~ in DEST is replaced with SUBTERM.
Alternatively, a single modifier spec can be of the form BEGIN[FROM:TO], which is equivalent to writing
BEGINFROM:BEGINTO (see example below).
For example, given the source phrase [[il bue che dice cornuto all'asino]] "the pot calling the kettle black"
(literally "the ox that calls the donkey horned/cuckolded"), the result of calling add_links_to_multiword_term()
is [[il]] [[bue]] [[che]] [[dice]] [[cornuto]] [[all']][[asino]]. With a modifier_spec of 'dice:dire', the result
is [[il]] [[bue]] [[che]] [[dire|dice]] [[cornuto]] [[all']][[asino]]. Here, based on the modifier spec, the
non-lemma form [[dice]] is replaced with the two-part link [[dire|dice]].
Another example: given the source phrase [[chi semina vento raccoglie tempesta]] "sow the wind, reap the whirlwind"
(literally (he) who sows wind gathers [the] tempest"). The result of calling add_links_to_multiword_term() is
[[chi]] [[semina]] [[vento]] [[raccoglie]] [[tempesta]], and with a modifier_spec of 'semina:~re; raccoglie:~re',
the result is [[chi]] [[seminare|semina]] [[vento]] [[raccogliere|raccoglie]] [[tempesta]]. Here we use the ~
notation to stand for the non-lemma form in the destination link.
A more complex example is [[se non hai altri moccoli puoi andare a letto al buio]], which becomes
[[se]] [[non]] [[hai]] [[altri]] [[moccoli]] [[puoi]] [[andare]] [[a]] [[letto]] [[al]] [[buio]] after calling
add_links_to_multiword_term(). With the following modifier_spec:
'hai:avere; altr[i:o]; moccol[i:o]; puoi: potere; andare a letto:~; al buio:~', the result of applying the spec is
[[se]] [[non]] [[avere|hai]] [[altro|altri]] [[moccolo|moccoli]] [[potere|puoi]] [[andare a letto]] [[al buio]].
Here, we rely on the alternative notation mentioned above for e.g. 'altr[i:o]', which is equivalent to 'altri:altro',
and link multiword subterms using e.g. 'andare a letto:~'. (The code knows how to handle multiword subexpressions
properly, and if the link text and destination are the same, only a single-part link is formed.)
]==]
function export.apply_link_modifiers(linked_term, modifier_spec, lang)
local split_modspecs = split(modifier_spec, "%s*;%s*")
for j, modspec in ipairs(split_modspecs) do
local id
if modspec:find("<") then
local rest
rest, id = modspec:match("^(.*)<id:(.-)>$")
if rest then
modspec = rest
end
end
local subterm, dest, otherlang
local begin_spec, rest, end_spec = modspec:match("^%[(.-)%]([^:]*)%[(.-)%]$")
if begin_spec then
local begin_from, begin_to = canonicalize_begin_end_spec(begin_spec)
local end_from, end_to = canonicalize_begin_end_spec(end_spec)
subterm = begin_from .. rest .. end_from
dest = begin_to .. rest .. end_to
end
if not subterm then
rest, end_spec = modspec:match("^([^:]*)%[(.-)%]$")
if rest then
local end_from, end_to = canonicalize_begin_end_spec(end_spec)
subterm = rest .. end_from
dest = rest .. end_to
end
end
if not subterm then
begin_spec, rest = modspec:match("^%[(.-)%]([^:]*)$")
if begin_spec then
local begin_from, begin_to = canonicalize_begin_end_spec(begin_spec)
subterm = begin_from .. rest
dest = begin_to .. rest
end
end
if not subterm then
subterm, dest = modspec:match("^(.-)%s*:%s*(.*)$")
if subterm and subterm ~= "^" and subterm ~= "$" then
local langdest
-- Parse off an initial language code (e.g. 'en:Higgs', 'la:minūtia' or 'grc:σκατός'). Also handle
-- Wikipedia prefixes ('w:Abatemarco' or 'w:it:Colle Val d'Elsa').
otherlang, langdest = dest:match("^([A-Za-z0-9._-]+):([^ ].*)$")
if otherlang == "w" then
local foreign_wikipedia, foreign_term = langdest:match("^([A-Za-z0-9._-]+):([^ ].*)$")
if foreign_wikipedia then
otherlang = otherlang .. ":" .. foreign_wikipedia
langdest = foreign_term
end
dest = ("%s:%s"):format(otherlang, langdest)
otherlang = nil
elseif otherlang then
otherlang = get_lang_by_code(otherlang, true, "allow etym")
dest = langdest
end
end
end
if not subterm then
if modspec == "?" or modspec == "!" then
subterm = "$"
dest = modspec
elseif modspec == "..." or modspec == "...?" then
subterm = "$"
dest = " " .. modspec
elseif modspec:find("^[A-Z]$") then
-- X, Y, etc. by themselves are unlinked, to help with snowclones
subterm = modspec
dest = "_"
else
subterm = modspec
dest = "~"
end
end
if subterm == "^" then
linked_term = dest:gsub("_", " ") .. linked_term
elseif subterm == "$" then
linked_term = linked_term .. dest:gsub("_", " ")
else
if subterm:find("[", nil, true) then
error(("Subterm '%s' in modifier spec '%s' cannot have brackets in it"):format(
escape_wikicode(subterm), escape_wikicode(modspec)))
end
local escaped_subterm = pattern_escape(subterm)
local subterm_re = "%[%[" .. escaped_subterm:gsub("(%%?[ ',%-])", "%%]*%1%%[*") .. "%]%]"
local expanded_dest
if dest:find("~", nil, true) then
expanded_dest = dest:gsub("~", replacement_escape(subterm))
else
expanded_dest = dest
end
if otherlang then
expanded_dest = expanded_dest .. "#" .. otherlang:getCanonicalName()
end
local subterm_replacement
if expanded_dest == "_" then
subterm_replacement = subterm
if id then
error("Can't supply <id:...> with an unlinked subterm")
end
if otherlang then
error("Can't supply prefixed language with an unlinked subterm")
end
elseif id or otherlang then
if id and expanded_dest:find("[", nil, true) then
error("Can't supply <id:...> with destination with embedded brackets")
end
subterm_replacement = require(links_module).language_link {
lang = otherlang or lang,
term = expanded_dest,
alt = subterm,
id = id,
}
elseif expanded_dest:find("[", nil, true) then
-- Use the destination directly if it has brackets in it (e.g. to put brackets around parts of a word).
subterm_replacement = expanded_dest
elseif expanded_dest == subterm then
subterm_replacement = "[[" .. subterm .. "]]"
else
subterm_replacement = "[[" .. expanded_dest .. "|" .. subterm .. "]]"
end
local escaped_subterm_replacement = replacement_escape(subterm_replacement)
local replaced_linked_term = ugsub(linked_term, subterm_re, escaped_subterm_replacement)
if replaced_linked_term == linked_term then
mw.log(("Attempted to replace %s with %s in %s"):format(subterm_re, escaped_subterm_replacement, linked_term))
error(("Subterm '%s' could not be located in %slinked expression %s, or replacement same as subterm"):format(
subterm, j > 1 and "intermediate " or "", escape_wikicode(linked_term)))
else
linked_term = replaced_linked_term
end
end
end
return linked_term
end
local inflection_to_cats = {
plural = {
filter_plpos = function(plpos)
-- plurals also occur with determiners, adjectives etc. and we don't want to generate categories like
-- 'countable determiners', 'countable adjectives', etc. Note that the passed-in `plpos` has `proper nouns`
-- converted to `nouns`.
return plpos == "nouns"
end,
cats = {"countable {plpos}"},
no_cats = {"uncountable {plpos}"},
},
comparative = {
cats = {"comparable {plpos}"},
no_cats = {"uncomparable {plpos}"},
},
["female equivalent"] = {
cats = {"{plpos} with other-gender equivalents"},
},
["male equivalent"] = {
cats = {"{plpos} with other-gender equivalents"},
},
}
--[=[
Validate the items in `items` against the list or set of valid items in `valid_items`. If `field` is given, fetch the
item to check from that-named field of each object in `items`; otherwise use the items in `items` directly. If an error
occurs, `item_type` specifies the type of item to mention in the error message, which will also list the allowed items
(either taken directly from `valid_items` if a list, or from the sorted keys if a set).
]=]
local function validate_items(data)
local items, field, valid_items, item_type =
data.items, data.field, data.valid_items, data.item_type
local valid_set
if valid_items[1] then
valid_set = list_to_set(valid_items)
else
valid_set = valid_items
end
for _, item in ipairs(items) do
if field then
item = item[field]
end
if not valid_set[item] then
local valid_list
if valid_items[1] then
valid_list = valid_items
else
valid_list = {}
for valid_item, _ in pairs(valid_items) do
insert(valid_list, valid_item)
end
table.sort(valid_list)
end
error(("Invalid %s: %s; expected one of %s"):format(item_type, item, mw.text.listToText(valid_list)))
end
end
end
local Headdata = {}
function Headdata:get_canonicalized_plpos()
return (self.pos_category:gsub("proper noun", "noun"))
end
--[==[
Canonicalize a category. The category string will have the full language name (i.e. the name of the L2 language under
which an entry is inserted, which may a parent language if the language in question is an etymology-only language)
prepended to it, and any occurrences of `{plpos}` in the string replaced with the actual plural part of speech (with
some canonicalization; specifically, `proper nouns` is converted to `nouns` when replacing `{plpos}`). To specify a
full category and not have the language name prepended to it, precede it with {"Category:"}, which will be removed.
]==]
function Headdata:canonicalize_category(category)
if category:find("{plpos}") then
local plpos = self:get_canonicalized_plpos()
category = category:gsub("{plpos}", plpos)
end
if category:find("^Category:") then
return (category:gsub("^Category:", ""))
else
return self.langfullname .. " " .. cat_word(self.lang, category)
end
end
--[==[
Canonicalize a list of categories according to the process described in `Headdata:canonicalize_category`. This simply
loops over each category in `categories` and calls `Headdata:canonicalize_category` on each one.
]==]
function Headdata:canonicalize_categories(categories)
if not categories then
return categories
end
local canon_cats = {}
for _, cat in ipairs(categories) do
insert(canon_cats, self:canonicalize_category(cat))
end
return canon_cats
end
--[==[
Insert a category into the `categories` list in the headword `data` structure. `category` is normally a string naming
the category, which will have the full language name prepended to it and any occurrences of `{plpos}` in the string
replaced with the actual plural part of speech (with some canonicalization; specifically, `proper nouns` is converted to
`nouns` when replacing `{plpos}`). To specify a full category and not have the language name prepended to it, precede it
with {"Category:"}.
]==]
function Headdata:insert_category(category)
insert(self.categories, self:canonicalize_category(category))
end
--[==[
Validate the genders in `genders` (a list of gender spec objects, as produced by {type = "genders"} in
[[Module:parameters]] and accepted by [[Module:gender and number]]), checking that all specified genders are in the list
given in `valid_genders`. Optional `props` controls how the validation happens. In particular, unless `props.no_augment`
is given, then for any gender beginning with `m`, if a corresponding gender beginning with `f` occurs, analogous genders
beginning with `mf`, `mfbysense` and `mfequiv` are also allowed. For example, if `m-d` (masculine dual) and `f-d`
(feminine dual) both occur, genders `mf-d`, `mfbysense-d` and `mfequiv-d` are also allowed. If a disallowed gender is
given, an error occurs, giving the disallowed gender along with the list of all allowed genders.
]==]
function Headdata:validate_genders(genders, valid_genders, props)
if not genders then
return
end
props = props or {}
local gender_type, no_augment = props.gender_type, props.no_augment
gender_type = gender_type or "headword"
local valid_gender_set = list_to_set(valid_genders)
local augmented_gender_set
if no_augment then
augmented_gender_set = valid_gender_set
else
augmented_gender_set = {}
for g, _ in pairs(valid_gender_set) do
augmented_gender_set[g] = true
if g:find("^m") and not g:find("^mf") and valid_gender_set[g:gsub("^m", "f")] then
augmented_gender_set[g:gsub("^m", "mf")] = true
augmented_gender_set[g:gsub("^m", "mfbysense")] = true
augmented_gender_set[g:gsub("^m", "mfequiv")] = true
end
end
end
validate_items {
items = genders,
field = "spec",
valid_items = augmented_gender_set,
item_type = ("%s gender"):format(gender_type),
}
end
--[==[
Parse an inflection specified in `field`, the name of a parameter holding an inflection. If the parameter is numeric,
the field should be given as a number (as with the `params` structure passed to [[Module:parameters]]), not a string
containing the representation of a number. The field can specify multiple comma-separated terms, and each term can have
associated inline modifiers that will be parsed (unless there is top-level HTML in the parameter, i.e. HTML not
contained inside an inline modifier, e.g. as may be generated by using {{tl|l}} or similar template inside a parameter).
This is a wrapper around the top-level `parse_term_with_modifiers()` function. `props` is an optional structure
containing additional properties, including all additional properties documented for the top-level
`parse_term_with_modifiers()` function.
If the parameter in `field` is unspecified, the return value of this function will be an empty list, not {nil}, so it
is always safe to iterate over the return value.
By default, the allowed modifiers are the same as for `parse_term_with_modifiers()`, except that (normally) the
`<tr:...>` modifier will be allowed if `include_tr` was specified in the original call to `process_headword()`; likewise
for the `<ts:...>` modifier if `include_ts` was specified and the `<sc:...>` modifier if `include_sc` was specified. If
If you pass in your own `include_mods` list of additional allowed modifiers, it will (normally) automatically be
augmented with {"tr"}, {"ts"} and/or {"sc"} if `include_tr`, `include_ts` and/or `include_sc` was specified when calling
`process_headword()`. To disable automatic augmentation of these modifiers (whether or not you specify an `include_mods`
property), specify {no_augment_include_mods = true} in `props`.
]==]
function Headdata:parse_inflection(field, props)
local val = self.process_props.args[field]
if not val then
return {}
end
props = props and shallow_copy(props) or {}
local include_mods = props.include_mods
local data = self.process_props.data
if not props.no_augment_include_mods and (data.include_tr or data.include_ts or data.include_sc) then
include_mods = include_mods and shallow_copy(include_mods) or {}
if data.include_tr then
insert_if_not(include_mods, "tr")
end
if data.include_ts then
insert_if_not(include_mods, "ts")
end
if data.include_sc then
insert_if_not(include_mods, "sc")
end
end
props.val = val
props.paramname = field
props.splitchar = props.splitchar or ","
props.include_mods = include_mods
return export.parse_term_with_modifiers(props) or {}
end
--[==[
Insert previously-parsed terms into the `inflections` of the headword `data` structure. This is a wrapper around
the top-level `insert_inflection()` function. `terms` is the list of parsed terms. (If {nil}, nothing happens unless
`request` is set in `props`.) `label` is the the label that the inflections are given; any parts of the label surrounded
in `<<...>>` are linked to the glossary. (If the contents of `<<...>>` contain a `|` in them, they are a two-part link.)
`props` is an optional structure containing additional properties, including all additional properties documented for
the top-level `insert_inflection()` function.
Unless `no_auto_cats` is given in `props`, certain labels automatically trigger the insertion of additional
categories in specific circumstances. This is controlled by the `inflection_to_cats` structure in
[[Module:headword utilities]]. For example, if the part of speech is {"nouns"} or {"proper nouns"} and the label (after
removing any links and `<<...>>` glossary specs) is {"plural"}, an additional category
<code><var>lang</var> countable nouns</code> will be added if a plural value is given (i.e. the value is not {"-"}). If
the value is {"-"} (which indicates that there is no plural and triggers the insertion of the fixed inflection label
{"no plural"}), <code><var>lang</var> uncountable nouns</code> will be inserted instead, and if both {"-"} and a value
are given (which triggers the insertion of the {"usually no plural"} fixed inflection label), both categories are added.
Similar categories are inserted when a comparative is given (with a label {"comparative"}), and if the label is
{"female equivalent"} or {"male equivalent"} and the value is not {"-"}, a category such as
<code><var>lang</var> nouns with other-gender equivalents</code> is inserted.
]==]
function Headdata:insert_inflection(terms, label, props)
props = props and shallow_copy(props) or {}
if not props.no_auto_cats then
local bare_label = label
if bare_label:find("[[", nil, true) then
bare_label = require(links_module).remove_links(bare_label)
end
if bare_label:find("<<", nil, true) then
bare_label = bare_label:gsub("<<.-|(.-)>>", "%1"):gsub("<<(.-)>>", "%1")
end
local cats = inflection_to_cats[bare_label]
if cats then
if not cats.filter_plpos or cats.filter_plpos(self:get_canonicalized_plpos()) then
if props.cats == nil then
props.cats = self:canonicalize_categories(cats.cats)
end
if props.usually_no_cats == nil then
props.usually_no_cats = self:canonicalize_categories(cats.usually_no_cats)
end
if props.no_cats == nil then
props.no_cats = self:canonicalize_categories(cats.no_cats)
end
end
end
end
props.headdata = self
props.terms = terms
props.label = label
return export.insert_inflection(props)
end
--[==[
Insert a "fixed" inflection (a label without associated values) into the `inflections` table of the headword `data`
structure, labeled according to `label` (which can have glossary links in it specified using `<<...>>`, exactly as for
`:insert_inflection()`). An example label (from {{tl|mn-noun}} in [[Module:mn-headword]]) is {"hidden-g declension"},
specifying that the noun belongs to the hidden-''g'' declension. This is a direct wrapper around the top-level function
`insert_fixed_inflection()`; see that function for more details on optional `props`.
]==]
function Headdata:insert_fixed_inflection(label, props)
props = props and shallow_copy(props) or {}
props.headdata = self
props.label = label
export.insert_fixed_inflection(props)
end
--[==[
Parse the inflection(s) specified in `field` and insert them into the `inflections` table of the headword `data`
structure, labeled according to `label`. This is equivalent to calling {terms = data:parse_inflection(field, props)}
followed by {return data:insert_inflection(terms, label, props)} and behaves the same as the combination of those two
functions. See their documentation for more details.
]==]
function Headdata:parse_and_insert_inflection(field, label, props)
local terms = self:parse_inflection(field, props)
return self:insert_inflection(terms, label, props)
end
--[==[
Generate an inflection that may be specified explicitly or defaulted (which involves looping over the specified or
defaulted heads and determining the script of each one, since the formation of the default depends on the script).
`data` is the data object passed into the POS handler. `terms` is the list of terms to process. Those where the term
itself is not `+` will be returned unchanged, while those where the term is `+` will be handled by generating the
appropriate inflections from the headwords using `make_inflection` (which is passed three arguments, `head`, `tr` and
`sccode`, i.e. the script code of `head`) and should return two values, term and translit, either of which can be
nil. A nil head will be ignored, and otherwise the decorations specified on the `+` term will be combined with the
decorations specified on the head. The return value is a list of inflections where no requests for the default
inflection remain.
]==]
function Headdata:resolve_special(terms, handle_special, props)
props = props or {}
local infls = {}
local is_special = props.is_special or function(_data, infl) return infl.term == "+" end
for _, termobj in ipairs(terms) do
if not is_special(self, termobj) then
insert(infls, termobj)
else
for _, headobj in ipairs(self.heads) do
local head = headobj.term or self.pagename
local head_no_links
if props.with_links then
head = head:find("%[") and head or require(headword_module).add_multiword_links(head, not headobj.term)
head_no_links = require(links_module).remove_links(head)
else
head = require(links_module).remove_links(head)
head_no_links = head
end
local newterms = handle_special {
head = head,
tr = headobj.tr,
infl = termobj,
sc = self.lang:findBestScript(head_no_links),
}
if newterms then
newterms = export.canonicalize_termobj_list(newterms, "term", "resolve_special")
for _, newterm in ipairs(newterms) do
if not props.no_combine_handle_special_retval_with_origin then
export.combine_termobj_decorations(newterm, termobj)
end
if not props.no_combine_handle_special_retval_with_head then
export.combine_termobj_decorations(newterm, headobj)
end
insert(infls, newterm)
end
end
end
end
end
return infls
end
--[==[
Add the current page to a tracking page named `Wiktionary:Tracking/``lang``-headword/``page```, where ``lang`` is the
language code of the current language. For example, if the current language is `mak` and `page` is {"redundant-lon"},
the current page will get added to the tracking page `Wiktionary:Tracking/mak-headword/redundant-lon`. All pages added
to that tracking page can be seen by going to [[Special:WhatLinksHere/Wiktionary:Tracking/mak-headword/redundant-lon]].
This is typically used to track issues occurring in user-specified parameters that do not rise to the level of errors
(e.g. redundant parameters, deprecated usages or other dispreferred values).
]==]
function Headdata:track(page)
return require(debug_track_module)(self.langcode .. "-headword/" .. page)
end
local boolean_param = {type = "boolean"}
--[==[
Process an arbitrary headword in an arbitrary language, handling generic and language-specific arguments and calling
`full_headword()` in [[Module:headword]]. This is intended for use in implementing headword modules (e.g.
[[Module:uz-headword]] for Uzbek, [[Module:mn-headword]] for Uzbek, [[Module:gsw-headword]] for Alemannic German, etc.)
and provides a general implementation of such modules. On input, `data` is an object with the following fields:
* `lang`: The language object of the language being handled. '''Required.''' Use the special value {false} to indicate
that the language is specified by the user in {{para|1}}.
* `frame`: The frame object passed into the `show()` function of your module, which implements headword-handling for
all parts of speech in the module, including a generic POS-handling template (e.g. {{tl|uz-head}} or {{tl|mn-head}}),
which allows arbitrary parts of speech to be handled. '''Required.'''
* `pos_functions`: A table listing, for each part of speech requiring special handling, the extra parameters (if any)
that the part of speech accepts, along with how to handle them. See the examples below. '''Required.'''
* `validate_lang`: If {lang = true} is specified, this is a function of one argument (a language object, based on the
language specified in {{para|1}}) that should throw an error if the language object is disallowed. If omitted, all
languages are allowed.
* `numbered_head`: If true, explicit headwords are specified in a numbered param instead of in {{para|head}}. The param
used is usually {{para|1}}, but is {{para|2}} for generic POS templates such as {{tl|mn-head}} or for POS-specific
templates when {lang = true} is specified (e.g. {{tl|arb-noun}}), and is {{para|3}} for generic POS templates when
{lang = true} is spcified (e.g. {{tl|arb-head}}).
* `include_tr`: If true, allow explicit transliterations to be specified. The transliteration(s) for the headword(s)
themselves is/are specified in {{para|tr}} or through the {{cd|<tr:...>}} inline modifier on headwords, and
transliterations of inflections are specified through the {{cd|<tr:...>}} inline modifier. This should generally be
given when a headword for the language may be in a script other than Latin.
* `include_ts`: If true, allow explicit transcriptions to be specified. The transcription(s) for the headword(s)
themselves is/are specified in {{para|ts}} or through the {{cd|<ts:...>}} inline modifier on headwords, and
transcriptions of inflections are specified through the {{cd|<ts:...>}} inline modifier. This should generally only
be given for certain languages where the spelling is radically different from the pronunciation (e.g. in cuneiform
languages such as Hittite and Akkadian, and potentially in Tibetan), and represents a pronunciation-based rendering
(usually not direct IPA).
* `include_sc`: If true, allow an explicit script code to be specified. The overall script code for the headword(s)
themselves can be specified using {{para|sc}}, and per-headword or per-inflection script codes are specified using the
{{cd|<sc:...>}} inline modifier. This should generally be given when a language supports multiple scripts.
* `infls`: An inflections structure specifying extra generic parameters that apply to all parts of speech and how to
handle them. The format is the same as for the `infls` structure in `pos_functions`.
* `augment_params`: A callback function to add extra generic parameters, or modify existing generic parameters in the
`params` structure; but in general, extra generic parameters should be added through the `infls` structure instead.
This callback should not be used to add part-of-speech-specific parameters; those are handled through the appropriate
setting in `pos_functions`. It is passed two single arguments, the `headdata` object and the `params` table to be
augmented. See below for extra fields stored in the `process_props` structure of the `headdata` object. This function
is called after initializing the `params` table and processing the overall `infls` structure, but just before adding
part-of-speech-specific parameters (from `pos_functions`) to `params`. Thus, it can override any generic parameters
but may itself be overridden by a part-of-speech-specific parameter.
* `augment_headdata`: A callback function to modify the `headdata` object passed to `full_headword()` in
[[Module:headword]]. This should not be used to for part-of-speech-specific parameter handling; this is handled
through the appropriate setting in `pos_functions`. It is passed a single argument, the `headdata` object, as for
`augment_params`; but the `process_props` structure and other fields will be more filled out, as this callback is
called later. This can be used, for example, to override the value of a generic setting in `headdata` (e.g.
[[Module:uz-headword]] uses this to mark non-Latin terms as variant forms by setting `headdata.var`, being careful not
to override a value already set by the user). This function is called after initializing the `headdata` table with all
information taken from generic parameters and processing generic parameters specified in the overall `infls`
structure, and just before processing the appropriate part-of-speech-specific `infls` structure in `pos_functions`
(which in turn is followed by any handler function in `pos_functions`). Thus, it can override any value set during
generic parameter processing but may itself be overridden by a part-of-speech-specific parameter or handler.
* `force_cat`: If true, add the headword to the appropriate categories even on non-mainspace pages. This can be used for
testing category handling in sample template calls on userspace test pages or template documentation pages. It should
not be set in production code.
* `enable_auto_translit`: If true, turn on automatic transliteration of inflections at a global level (i.e. applying to
all inflections). This has no effect on headwords, which are automatically transliterated by default if in a non-Latin
script and automatic transliteration is available for the language. You can also set this value for particular
inflections in the `insert_inflection()` function.
The `headdata` headword data structure has an extra field in it called `process_props` that is specific to the
`process_headword()` function, containing various extra properies. As the operation of `process_headword()` proceeds,
this object gets filled out with more fields. For example, once parameter parsing happens, the resulting values are
available in the `args` field of `process_props`. The following fields are found in `process_props` (note that `poscat`,
the canonicalized plural part of speech of the headword being processed, is *not* present here; it's directly on
`headdata`):
* `namespace`: The name of the current namespace; an empty string for the mainspace. This references the namespace of
the actual page and isn't affected by the {{para|pagename}} parameter.
* `indexing_poscat`: The canonicalized part of speech of the headword used to index into `pos_functions`. This is the
same as `poscat` for specific part-of-speech templates such as {{tl|uz-noun}}, but has the value {"head"} for generic
part-of-speech templates such as {{tl|uz-head}}. (Note that `poscat` is directly available on `headdata`.)
* `generic_pos_template`: True if a generic POS templates like {{tl|uz-head}} or {{tl|mn-head}} was used. (This is
signaled by omitting the invocation parameter {{para|1}} to `process_headword`.)
* `lang_in_1`: True if the language code is to be fetched from {{para|1}}.
* `pos_param`: The parameter holding the part of speech, if a generic POS tempalte like {{tl|mn-head}} is being
processed (i.e. `generic_pos_template` is set). In such a case, it will have the value of {1} or {2}, depending on
whether the language code is being fetched from {{para|1}} (see `lang_in_1`). Otherwise it will be {nil}.
* `head_param`: The parameter holding the explicit headword. If `numbered_head` was specified (as for Mongolian headword
templates), this has the value {1}, {2} or {3} depending on whether the language code is being fetched from {{para|1}}
(see `lang_in_1`) and whether a generic POS template like {{tl|mn-head}} is being processed (see
`generic_pos_template`). Otherwise, it has the value {"head"}. Also see the `lang` and `numbered_head` properties in
the `data` structure sent to `process_headword()`.
* `is_suffix`: True if the current term is a suffix. This is set when processing the `suffix`, `nosuffix` and `clitic`
parameters; it is always {false} beforehand (i.e. during `augment_params` and processing of the general `infls`
structure).
* `insert_specs`: This is a table mapping parameter names to the return value of `Headdata:insert_inflection()`, filled
out as parameter values are processed. This lets a given parameter processing function in `infls` gain access to the
result of calling `insert_inflection()` on previous parameters (which indicates the number of items inserted as well
as whether `-` was specified).
The `pos_functions` table contains an entry for each part of speech needing special handling, where the key is the
canonical plural part of speech (e.g. {"adverbs"} or {"proper nouns"}). The value associated with each key is a table
normally containing a field `infls`, listing the extra part-of-speech-specific inflection and other parameters along
with how to handle them. The specs in `infls` are used in three ways:
# to augment the `params` object passed to the `process()` function in [[Module:parameters]], specifying how to parse
the appropriate inflectional parameters;
# to specify how to process any inflectional parameters given and insert them into the `headdata` object passed to
`full_headword()` in [[Module:headword]];
# to generate appropriate documentation for the parameters and other changes made by the headword template (e.g.
inserting categories).
Alternatively, you can separately control the augmentation of the `params` object and the procesing of the resulting
arguments. This is done by specifying two fields in place of `infls`, named `params` and `func`. `params` is a table
containing extra parameters to add to the overall `params` object passed to the `process()` function in
[[Module:parameters]]. `func` is a function of two arguments, normally called `data` (the headword data structure
`headdata`) and `args` (the processed arguments table). However, this alternative method is not normally recommended
because it leads to duplication between the `params and `func` fields and the documentation, which must be manually
specified.
A simple example, as used to handle pronouns for Turoyo, is
{
local valid_genders = {"m", "f", "m-p", "f-p", "p", "?"}
pos_functions["pronouns"] = {
infls = {
{2, type = "genders", validate = valid_genders},
{"f", label = "feminine"},
{"pl", label = "plural"},
},
}
}
The equivalent using `params` and `func` is
{
local valid_genders = {"m", "f", "m-p", "f-p", "p", "?"}
pos_functions["pronouns"] = {
params = {
[2] = {type = "genders"},
f = true,
pl = true,
},
func = function(data, args)
data:validate_genders(args[2], valid_genders)
data.genders = args[2]
data:parse_and_insert_inflection("f", "feminine")
data:parse_and_insert_inflection("pl", "plural")
end
}
}
Note how the version with separate `params and `func` is longer and splits information on the parameters between the
two fields. The `params` structure sets extra user-specifiable parameters {{para|2}} for genders (since the headword is
in {{para|1}}) as well a {{para|f}} and {{para|pl}}, and the `func` handler processes those parameters. Note how this is
done by calling methods on the headword `data` structure. Each such parameter can have multiple comma-separated values,
and each value can have inline modifiers attached to it to specify further properties of the value. The `infls` version
ends up making the same method calls, but does it for you instead of you having to do it yourself.
These methods are implemented through a metatable set on the headword `data` structure, which is removed before calling
`full_headword()` in [[Module:headword]]. The methods access extra information related to headword processing (such as
the `args` table) that is stored in the `process_props` field of the headword `data` strucuture. This field is also
removed prior to calling `full_headword()`.
The methods available on the headword `data` structure are as follows. Each one also has its own documentation.
* {parse_inflection(field, props)}: Parse value(s) specified in `field` (a user-specified parameter in the `args` table)
and return a list of term objects. Optional `props` specifies additional properties controlling the parsing.
* {insert_inflection(terms, label, props)}: Insert the terms in `terms` (a list of term objects as returned by
`parse_inflection()`) into the `inflections` list in the headword `data` structure, giving the inflection the label as
specified in `label`. Optional `props` specifies additional properties controlling the parsing.
* {parse_and_insert_inflection(field, label, props)}: A combination of `parse_inflection()` and `insert_inflection()`,
if no further processing of the parsed values needs to be done before insertion.
* {insert_fixed_inflection(label, props)}: Insert a "fixed" inflection (a label without associated values) into the
`inflections` table. An example (from {{tl|mn-noun}} in [[Module:mn-headword]]) is {"hidden-g declension"}, specifying
that the noun belongs to the hidden-''g'' declension.
* {resolve_special(terms, handle_special, props)}: Resolve "special" indicators as specified by the user in an inflection
parameter. A typical example is {"+"}, requesting a default value. `terms` is the list of parsed term objects and
`handle_special` is a handler function to process special indicators and convert them to their actual values.
* {validate_genders(genders, valid_genders, props)}: Validate that the user-specified genders in `genders` all belong to
the list given in `valid_genders`, throwing an error if not.
* {insert_category(category)}: Insert a category into the `categories` list in the headword `data` structure. `category`
is normally a string naming the category, which will have the language prepended to it and any occurrences of
`{plpos}` in the string replaced with the actual plural part of speech.
]==]
function export.process_headword(data)
local lang, frame, pos_functions, validate_lang, numbered_head, include_tr, include_ts, include_sc, force_cat,
enable_auto_translit, infls, augment_params, augment_headdata =
data.lang, data.frame, data.pos_functions, data.validate_lang, data.numbered_head, data.include_tr,
data.include_ts, data.include_sc, data.force_cat, data.enable_auto_translit, data.infls, data.augment_params,
data.augment_headdata
local iparams = {
[1] = true,
def = true,
}
local iargs = require(parameters_module).process(frame.args, iparams)
local parargs = frame:getParent().args
local langcode
if not lang then
error("Internal error: `data.lang` must be specified; either a language object or `true` for a user-specified language")
end
local lang_in_1
if lang == true then
lang_in_1 = true
langcode = ine(parargs[1])
if langcode then
langcode = mw.text.trim(langcode)
lang = require(languages_module).getByCode(langcode, 1, true)
if validate_lang then
validate_lang(lang)
end
else
error("Language code (see [[WT:Language codes]]) must be specified in 1=")
end
else
langcode = lang:getCode()
if validate_lang then
error("Internal error: `data.validate_lang` must not be specified if a language code is given in `data.lang`")
end
end
local poscat = iargs[1]
local generic_pos_template = not poscat
local pos_param
if generic_pos_template then
pos_param = lang_in_1 and 2 or 1
poscat = ine(parargs[pos_param]) or
mw.title.getCurrentTitle().fullText == ("Template:%s-head"):format(langcode) and "interjection" or
error(("Part of speech must be specified in %s="):format(pos_param))
poscat = require(headword_module).canonicalize_pos(poscat)
end
local head_param = numbered_head and (generic_pos_template and lang_in_1 and 3 or
(generic_pos_template or lang_in_1) and 2 or 1) or "head"
local indexing_poscat = generic_pos_template and "head" or poscat
local namespace = mw.loadData(headword_data_module).page.namespace
-- Partly initialize headdata now for use in generic infls callbacks. Will be further initialized later after
-- processing parameters.
local headdata = {
lang = lang,
langcode = langcode,
langfullcode = lang:getFullCode(),
langname = lang:getCanonicalName(),
langfullname = lang:getFullName(),
process_props = {
namespace = namespace,
data = data,
indexing_poscat = indexing_poscat,
generic_pos_template = generic_pos_template,
lang_in_1 = lang_in_1,
pos_param = pos_param,
head_param = head_param,
is_suffix = false,
insert_specs = {},
},
pos_category = poscat,
orig_poscat = poscat, -- preserve user-specified poscat in case pos_category is changed to 'suffixes'
categories = {},
inflections = {enable_auto_translit = enable_auto_translit},
force_cat_output = force_cat,
no_redundant_head_cat = true,
}
setmetatable(headdata, {__index = Headdata})
local params = {
[head_param] = {template_default = iargs.def},
head2 = {replaced_by = false, instead = ("use comma-separated |%s="):format(head_param)},
id = true,
sort = true,
cat = true,
nolink = boolean_param,
nolinkhead = {type = "boolean", alias_of = "nolink"},
suffix = boolean_param,
nosuffix = boolean_param,
clitic = true,
addlpos = true,
var = {type = "boolean", allow = {"both"}},
json = boolean_param,
pagename = true, -- for testing
}
if include_sc then
params.sc = {type = "script"}
end
if include_tr then
params.tr = true
params.tr2 = {replaced_by = false, instead = "use comma-separated |tr= or <tr:...> inline modifier on head"}
end
if include_ts then
params.ts = true
params.ts2 = {replaced_by = false, instead = "use comma-separated |ts= or <ts:...> inline modifier on head"}
end
if lang_in_1 then
params[1] = {required = true} -- required but ignored as already processed above
end
if generic_pos_template then
params[pos_param] = {required = true} -- required but ignored as already processed above
end
local function resolve_prop(prop, ...)
if type(prop) == "function" then
prop = prop(headdata, ...)
end
return prop
end
local function augment_params_from_infls(infls)
infls = resolve_prop(infls)
for _, infl in ipairs(infls) do
local function interr(txt)
error(("Internal error: %s (coming from infls spec %s)"):format(txt, dump(infl)))
end
local param = infl[1]
if param then
param = resolve_prop(param)
if type(param) ~= "string" and type(param) ~= "number" then
interr(("Parameter name %s must be a string or number"):format(dump(param)))
end
-- We handle defaults as well as validation ourselves.
local typ = resolve_prop(infl.type) or "string"
if typ ~= "genders" and typ ~= "boolean" and typ ~= "string" then
-- FIXME: Handle more types.
interr(('Unrecognized type %s; can only currently handle "genders", "boolean" and "string" (the default)'):format(
dump(typ)))
end
params[param] = {type = typ, required = resolve_prop(infl.required), template_default = resolve_prop(infl.template_default)}
if typ ~= "boolean" and type(param) == "string" then
params[param .. "2"] = {replaced_by = false, instead = ("use comma-separated |%s="):format(param)}
end
end
end
end
if infls then
augment_params_from_infls(infls)
end
if augment_params then
augment_params(headdata, params)
end
if pos_functions[indexing_poscat] then
local pos_infls = pos_functions[indexing_poscat].infls
if pos_infls then
augment_params_from_infls(pos_infls)
end
local pos_params = pos_functions[indexing_poscat].params
if pos_params then
for key, val in pairs(pos_params) do
params[key] = val
end
end
end
local args = require("Module:parameters").process(parargs, params)
local pagename = args.pagename or mw.loadData(headword_data_module).pagename
local sc = args.sc or lang:findBestScript(pagename)
headdata.pagename = pagename
headdata.process_props.args = args
headdata.sc = sc
headdata.id = args.id
headdata.sort = args.sort
-- No redundant script cat unless the user explicitly gave sc=
headdata.no_script_code_cat = not args.sc
headdata.var = args.var
local extra_term_mods = {}
if include_tr then
insert(extra_term_mods, "tr")
end
if include_ts then
insert(extra_term_mods, "ts")
end
if include_sc then
insert(extra_term_mods, "sc")
end
if not extra_term_mods[1] then
extra_term_mods = nil
end
local trs = args.tr and split_on_comma(args.tr) or {}
local num_trs = #trs
local tss = args.ts and split_on_comma(args.ts) or {}
local num_tss = #tss
local heads = args[head_param] and export.parse_term_with_modifiers {
val = args[head_param],
paramname = head_param,
splitchar = ",",
is_head = true,
include_mods = extra_term_mods,
} or {}
local num_heads = #heads
if num_heads > 0 and num_trs > 0 and num_heads ~= num_trs then
error(("%s head%s specified explicitly but %s translit%s; they must match; use '+' to stand for the default head (the pagename) or default automatic translit and '-' to stand for no translit"):format(
num_heads, num_heads > 1 and "s" or "", num_trs, num_trs > 1 and "s" or ""))
end
if num_heads > 0 and num_tss > 0 and num_heads ~= num_tss then
error(("%s head%s specified explicitly but %s transcription%s; they must match; use '+' to stand for the default head (the pagename) and '-' to stand for no transcription"):format(
num_heads, num_heads > 1 and "s" or "", num_tss, num_tss > 1 and "s" or ""))
end
if num_trs > 0 and num_tss > 0 and num_trs ~= num_tss then
error(("%s translit%s specified explicitly but %s transcription%s; they must match; use '+' to stand for default automatic translit and '-' to stand for no translit or transcription"):format(
num_trs, num_trs > 1 and "s" or "", num_tss, num_tss > 1 and "s" or ""))
end
-- Be careful here not to overwrite user_specified_heads if it's empty so we can later check user_specified_heads
-- to see if the user provided any heads.
local max_tr_ts = math.max(num_trs, num_tss)
if num_heads == 0 and max_tr_ts > 0 then
heads = {}
for i = 1, max_tr_ts do
heads[i] = {term = "+"}
end
end
if not heads[1] then
heads = {{term = "+"}}
end
for i, headobj in ipairs(heads) do
if headobj.tr and trs[i] then
if headobj.tr ~= trs[i] then
error(("Saw two different translits '%s' and '%s' for head #%s"):format(
headobj.tr, trs[i], i))
end
else
headobj.tr = headobj.tr or trs[i]
end
if headobj.tr == "+" then
headobj.tr = nil
end
if headobj.ts and tss[i] then
if headobj.ts ~= tss[i] then
error(("Saw two different transcriptions '%s' and '%s' for head #%s"):format(
headobj.ts, tss[i], i))
end
else
headobj.ts = headobj.ts or tss[i]
end
if headobj.ts == "-" then
headobj.ts = nil
end
if headobj.term == "+" then
headobj.term = args.nolink and pagename or nil
if headobj.term and namespace == "Reconstruction" then
headobj.term = "*" .. headobj.term
end
end
end
headdata.heads = heads
local function pagename_is_suffix()
if sc:getCode() == "Latn" then
-- shortcut Latin terms to avoid unnecessarily loading [[Module:affix]]
return pagename:find("^%-") and not pagename:find("%-$")
else
local affix_type, _, _, _ = require(affix_module).parse_term_for_affixes(pagename, lang, sc)
return affix_type == "suffix"
end
end
local clitic_label
if args.clitic then
clitic_label = require(yesno_module)(args.clitic, args.clitic)
end
if clitic_label == true then
clitic_label = "clitic"
end
if clitic_label then
headdata:insert_category("clitics")
headdata:insert_fixed_inflection(clitic_label)
elseif args.suffix or (
not args.nosuffix and pagename_is_suffix() and poscat ~= "suffixes" and poscat ~= "suffix forms"
) then
headdata.process_props.is_suffix = true
local function handle_suffix_pos(pos, is_first)
local form_type = pos:match("^(.*) forms$")
local actual_poscat
if form_type then
headdata:insert_category(("%s suffix forms"):format(form_type))
headdata:insert_fixed_inflection(form_type .. " suffix form")
else
local singular_pos = require(en_utilities_module).singularize(pos)
headdata:insert_category(("%s-forming suffixes"):format(singular_pos))
headdata:insert_fixed_inflection(singular_pos .. "-forming suffix")
end
local postype = require(headword_module).pos_lemma_or_nonlemma(pos)
if not postype then
error(("Unrecognized canonicalized part of speech '%s' in addlpos=, cannot determine whether lemma or non-lemma form"):format(
pos
))
end
actual_poscat = postype == "lemma" and "suffixes" or "suffix forms"
if is_first then
headdata.pos_category = actual_poscat
elseif headdata.pos_category ~= actual_poscat then
error(("Cannot mix suffixes and suffix forms using addlpos=; '%s' is a %s while overall POS '%s' is a %s; use separate POS headers for the two"):
format(pos, actual_poscat, poscat, headdata.pos_category))
end
end
handle_suffix_pos(poscat, true)
if args.addlpos then
for _, addlpos in ipairs(split(args.addlpos, "%s*,%s*")) do
addlpos = require(headword_module).canonicalize_pos(addlpos)
handle_suffix_pos(addlpos, false)
end
end
end
if args.cat then
for _, cat in ipairs(split_on_comma(args.cat)) do
headdata:insert_category(cat)
end
end
local function augment_headdata_from_infls(infls)
infls = resolve_prop(infls)
for _, infl in ipairs(infls) do
local function interr(txt)
error(("Internal error: %s (coming from infls spec %s)"):format(txt, dump(infl)))
end
local function process_labelobjs(labelobjs, originating_term, handle_labelobj)
if labelobjs == nil then
return
end
if type(labelobjs) ~= "string" and type(labelobjs) ~= "table" then
interr(("Wrong type '%s' for label object(s) %s, expected string or table"):format(
type(labelobjs), dump(labelobjs)
))
end
if type(labelobjs) == "string" or type(labelobjs) == "table" and not labelobjs[1] then
labelobjs = {labelobjs}
end
for _, labelobj in ipairs(labelobjs) do
local label, termobj
if type(labelobj) == "string" then
label = labelobj
termobj = originating_term
elseif type(labelobj) ~= "table" then
interr(("Wrong type '%s' for label object %s, expected string or table"):format(
type(labelobj), dump(labelobj)
))
label = labelobj.term
if type(label) ~= "string" then
interr(("Wrong type '%s' for label %s from label object %s, expected string"):format(
type(label), dump(label), dump(labelobj)
))
end
termobj = labelobj
end
handle_labelobj(label, termobj)
end
end
local param = infl[1]
if param then
local vals
-- Fetch the param and make sure it's a string or number.
param = resolve_prop(param)
if type(param) ~= "string" and type(param) ~= "number" then
interr(("Parameter name %s must be a string or number"):format(dump(param)))
end
-- Fetch the type and validate.
local typ = resolve_prop(infl.type)
if typ == nil then
typ = "string"
end
if typ ~= "genders" and typ ~= "boolean" and typ ~= "string" then
-- FIXME: Handle more types.
interr(('Unrecognized type %s; can only currently handle "genders", "boolean" and "string" (the default)'):format(
dump(typ)))
end
-- Fetch the value(s).
if typ == "genders" or typ == "boolean" then
vals = args[param]
elseif typ == "string" then
local parse_inflection_props = resolve_prop(infl.parse_inflection_props)
local include_mods = resolve_prop(infl.include_mods)
local no_augment_include_mods = resolve_prop(infl.no_augment_include_mods)
if include_mods ~= nil or no_augment_include_mods ~= nil then
if parse_inflection_props == nil then
parse_inflection_props = {}
else
parse_inflection_props = shallow_copy(parse_inflection_props)
end
if include_mods ~= nil then
parse_inflection_props.include_mods = include_mods
end
if no_augment_include_mods ~= nil then
parse_inflection_props.no_augment_include_mods = no_augment_include_mods
end
end
vals = headdata:parse_inflection(param, parse_inflection_props)
-- Convert an empty list to nil for consistent checking below.
if not vals[1] then
vals = nil
end
else
interr(("Unrecognized type '%s"):format(typ))
end
-- If value(s) nil, fetch the default.
if vals == nil and infl.default ~= nil then
local default = resolve_prop(infl.default)
if typ == "genders" then
vals = export.canonicalize_termobj_list(default, "spec", "default")
elseif typ == "boolean" then
vals = default
elseif typ == "string" then
vals = export.canonicalize_termobj_list(default, "term", "default")
else
interr(("Unrecognized type '%s"):format(typ))
end
end
-- Resolve "special" values (special signals a string values, such as requesting the default with "+").
if vals ~= nil and infl.resolve_special then
if typ ~= "string" then
interr(("Cannot specify resolve_special= for type %s"):format(dump(typ)))
end
local resolve_special_props = resolve_prop(infl.resolve_special_props, vals)
if infl.is_special ~= nil then
if resolve_special_props == nil then
resolve_special_props = {}
else
resolve_special_props = shallow_copy(resolve_special_props)
end
resolve_special_props.is_special = infl.is_special
end
vals = headdata:resolve_special(vals, infl.resolve_special, resolve_special_props)
end
-- Validate the value(s).
if vals ~= nil and infl.validate ~= nil then
if typ == "boolean" then
interr('Cannot specify validate= when type is "boolean"')
elseif type(infl.validate) == "function" then
infl.validate(headdata, vals)
elseif typ == "genders" then
headdata:validate_genders(vals, infl.validate)
elseif typ == "string" then
validate_items {
items = vals,
field = "term",
valid_items = infl.validate,
item_type = ("values in |%s="):format(param),
}
else
interr(("Unrecognized type '%s"):format(typ))
end
end
-- Run the process_after_parse handler, if it exists.
if vals ~= nil and infl.process_after_parse ~= nil then
local intentionally_nil
vals, intentionally_nil = infl.process_after_parse(headdata, vals)
if vals == nil and not intentionally_nil then
interr("If you return nil from process_after_parse, you must return a second non-nil return " ..
"value to indicate that the nil return value was intentional")
end
end
-- "Implement" the values, if non-falsy (i.e. we don't want to fire on boolean false or empty list).
-- If a fixed label is specified, insert it. Then, depending on the type, attach the values to a label
-- as an inflection, set the `genders` field, or do nothing if boolean (throwing an error if there was
-- no fixed label).
if vals == true or type(vals) == "table" and vals[1] then
if infl.fixed_label and infl.all_fixed_label then
interr("Cannot specify both fixed_label= and all_fixed_label=; specify one or the other")
end
local function check_fixed_label_references_val(label)
if type(label) == "table" and label[1] then
for _, lab in ipairs(label) do
if check_fixed_label_references_val(lab) then
return true
end
end
return false
end
if type(label) == "table" then
if not label.term then
interr(("Fixed label structure %s does not have a value for `.term`"):format(dump(label)))
end
label = label.term
end
if type(label) ~= "string" then
interr(("Wrong type for fixed label %s, should be string"):format(type(label)))
end
return not not label:find("{val}")
end
local fixed_label = infl.fixed_label
local all_fixed_label = infl.all_fixed_label
-- If the value being processed is boolean, there's only one value so treat a fixed_label as an
-- all_fixed_label and output only once; likewise if the caller specified a fixed_label without
-- {val} in it.
if fixed_label and (typ == "boolean" or type(fixed_label) ~= "function" and not
check_fixed_label_references_val(fixed_label)) then
all_fixed_label = fixed_label
fixed_label = nil
end
local inserted_fixed_label
if fixed_label then
if typ == "boolean" then
interr("Boolean fixed_label values should have been converted to all_fixed_label")
end
for _, valobj in ipairs(vals) do
local labelobjs = resolve_prop(fixed_label, valobj)
process_labelobjs(labelobjs, valobj, function(label, termobj)
if label:find("{val}") then
if typ ~= "string" then
interr(('Cannot specify {val} in fixed_label %s when type is "%s"'):format(dump(label), typ))
end
label = label:gsub("{val}", replacement_escape(valobj.term))
end
headdata:insert_fixed_inflection(label, {
originating_term = termobj
})
inserted_fixed_label = true
end)
end
elseif all_fixed_label then
local labelobjs = resolve_prop(all_fixed_label, vals)
process_labelobjs(labelobjs, nil, function(label, termobj)
if label:find("{vals}") then
if typ ~= "string" then
interr(('Cannot specify {vals} in all_fixed_label %s when type is "%s"'):format(dump(label), typ))
end
local formatted_labels = {}
for _, valobj in ipairs(vals) do
insert(formatted_labels, add_decorations(valobj.term, valobj, lang))
end
label = label:gsub("{vals}", replacement_escape(serial_comma_join(formatted_labels)))
end
headdata:insert_fixed_inflection(label, termobj)
inserted_fixed_label = true
end)
end
local inserted_vals
if infl.label ~= nil then
if typ ~= "string" then
interr(("label=%s can only be specified for type 'string', not '%s'"):format(
dump(infl.label), typ
))
end
local label = resolve_prop(infl.label, vals)
if label ~= nil then
local insert_inflection_props = resolve_prop(infl.insert_inflection_props, vals)
local no_auto_cats = resolve_prop(infl.no_auto_cats, vals)
if no_auto_cats ~= nil then
if insert_inflection_props == nil then
insert_inflection_props = {}
else
insert_inflection_props = shallow_copy(insert_inflection_props)
end
insert_inflection_props.no_auto_cats = infl.no_auto_cats
end
local insert_spec = headdata:insert_inflection(vals, label, insert_inflection_props)
headdata.process_props.insert_specs[param] = insert_spec
inserted_vals = true
end
end
if typ == "genders" then
headdata.genders = vals
end
local inserted_cat
if infl.cat then
local allcats = {}
for _, valobj in ipairs(vals) do
local cats = resolve_prop(infl.cat, valobj)
if type(cats) == "string" then
cats = {cats}
end
if cats ~= nil then
for _, cat in ipairs(cats) do
if cat:find("{val}") then
cat = cat:gsub("{val}", replacement_escape(valobj.term))
end
insert_if_not(allcats, cat)
end
end
end
for _, cat in ipairs(allcats) do
headdata:insert_category(cat)
inserted_cat = true
end
end
if typ == "boolean" then
if not inserted_fixed_label and not inserted_cat then
interr(("User set boolean setting for %s= but no fixed label added and no category " ..
"inserted; if you took action in process_after_parse(), make sure to return " ..
"`nil, true`"):format(param))
end
elseif typ == "string" then
if not inserted_vals and not inserted_fixed_label then
interr(("User set value(s) %s for %s= but no inflection inserted and no fixed label " ..
"added; if you took action in process_after_parse(), make sure to return " ..
"`nil, true`"):format(dump(vals), param))
end
end
end
else -- no param specified
if infl.label or infl.all_fixed_label then
interr("Cannot have label= or all_fixed_label= without specifying a param")
end
if infl.fixed_label then
local labelobjs = resolve_prop(infl.fixed_label)
process_labelobjs(labelobjs, nil, function(label, termobj)
if label:find("{val}") then
interr("Cannot specify {val} in a fixed_label= value without specifying a param")
end
headdata:insert_fixed_inflection(label, {
originating_term = termobj
})
end)
end
if infl.cat then
local cats = resolve_prop(infl.cat)
if type(cats) == "string" then
cats = {cats}
end
if cats ~= nil then
for _, cat in ipairs(cats) do
if cat:find("{val}") then
interr("Cannot specify {val} in a cat= value without specifying a param")
end
headdata:insert_category(cat)
end
end
end
end
end
end
if infls then
augment_headdata_from_infls(infls)
end
if augment_headdata then
augment_headdata(headdata, args)
end
if pos_functions[indexing_poscat] then
local pos_infls = pos_functions[indexing_poscat].infls
if pos_infls then
augment_headdata_from_infls(pos_infls)
end
local func = pos_functions[indexing_poscat].func
if func then
func(headdata, args)
end
end
setmetatable(headdata, nil)
if args.json then
return require("Module:JSON").toJSON(headdata)
end
headdata.process_props = nil
return require(headword_module).full_headword(headdata)
end
return export
gqevnj4k9yxd2sb8km66y9rrlezxlk0
Module:affix
828
8054
54921
54860
2026-09-29T00:02:32Z
Deadend0914
7211
54921
Scribunto
text/plain
local export = {}
local debug_force_cat = false -- if set to true, always display categories even on userspace pages
local m_links = require("Module:links")
local m_str_utils = require("Module:string utilities")
local m_table = require("Module:table")
local decorations_module = "Module:decorations"
local en_utilities_module = "Module:en-utilities"
local etymology_module = "Module:etymology"
local scripts_module = "Module:scripts"
local utilities_module = "Module:utilities"
-- Export this so the category code in [[Module:category tree/etymology]] can access it.
export.affix_lang_data_module_prefix = "Module:affix/lang-data/"
local ulen = m_str_utils.len
local rfind = m_str_utils.find
local rmatch = m_str_utils.match
local pluralize = require(en_utilities_module).pluralize
local singularize = require(en_utilities_module).singularize
local u = m_str_utils.char
local ucfirst = m_str_utils.ucfirst
local unpack = unpack or table.unpack -- Lua 5.2 compatibility
function export.affix_variants(canonical, variants)
local mappings = {}
for _, variant in ipairs(variants) do
mappings[variant] = canonical
end
return mappings
end
function export.id_mapping(default, ids)
local mapping = { default = default }
if ids then
for id, target in pairs(ids) do
mapping[id] = target
end
end
return mapping
end
function export.id_mapping_with_affix_variants(base, id_variants)
local mappings = {}
for id, variants in pairs(id_variants) do
for _, variant in ipairs(variants) do
mappings[variant] = export.id_mapping(base, {[id] = base})
end
end
return mappings
end
function export.merge_tables(...)
local result = {}
for i = 1, select('#', ...) do
local t = select(i, ...)
if t then
for k, v in pairs(t) do
result[k] = v
end
end
end
return result
end
-- Export this so the category code in [[Module:category tree/etymology]] can access it.
export.langs_with_lang_specific_data = {
["az"] = true,
["fi"] = true,
["fr"] = true,
["izh"] = true,
["la"] = true,
["sah"] = true,
["tr"] = true,
["trk-pro"] = true,
}
local default_pos = "term"
local function pluralize_pos(pos)
return pluralize(singularize(pos))
end
--[==[ intro:
===About different types of hyphens ("template", "display" and "lookup"):===
* The "template hyphen" is the per-script hyphen character that is used in template calls to indicate that a term is an
affix. This is always a single Unicode char, but there may be multiple possible hyphens for a given script. Normally
this is just the regular hyphen character "-", but for some non-Latin-script languages (currently only right-to-left
languages), it is different.
* The "display hyphen" is the string (which might be an empty string) that is added onto a term as displayed and linked,
to indicate that a term is an affix. Currently this is always either the same as the template hyphen or an empty
string, but the code below is written generally enough to handle arbitrary display hyphens. Specifically:
*# For East Asian languages, the display hyphen is always blank.
*# For Arabic-script languages, either tatweel (ـ) or ZWNJ (zero-width non-joiner) are allowed as template hyphens,
where ZWNJ is supported primarily for Farsi, because some suffixes have non-joining behavior. The display hyphen
corresponding to tatweel is also tatweel, but the display hyphen corresponding to ZWNJ is blank (tatweel is also
the default display hyphen, for calls to {{tl|prefix}}/{{tl|suffix}}/etc. that don't include an explicit hyphen).
* The "lookup hyphen" is the hyphen that is used when looking up language-specific affix mappings. (These mappings are
discussed in more detail below when discussing link affixes.) It depends only on the script of the affix in question.
Most scripts (including East Asian scripts) use a regular hyphen "-" as the lookup hyphen, but Hebrew and Arabic
have their own lookup hyphens (respectively maqqef and tatweel). Note that for Arabic in particular, there are
three possible template hyphens that are recognized (tatweel, ZWNJ and regular hyphen), but mappings must use tatweel.
===About different types of affixes ("template", "display", "link", "lookup" and "category"):===
* A "template affix" is an affix in its source form as it appears in a template call. Generally, a template affix has an
attached template hyphen (see above) to indicate that it is an affix and indicate what type of affix it is (prefix,
suffix, interfix or circumfix), but some of the older-style templates such as {{tl|suffix}}, {{tl|prefix}},
{{tl|confix}}, etc. have "positional" affixes where the presence of the affix in a certain position (e.g. the second
or third parameter) indicates that it is a certain type of affix, whether or not it has an attached template hyphen.
* A "display affix" is the corresponding affix as it is actually displayed to the user. The display affix may differ
from the template affix for various reasons:
*# The display affix may be specified explicitly using the {{para|alt<var>N</var>}} parameter, the `<alt:...>` inline
modifier or a piped link of the form e.g. `<nowiki>[[-kas|-käs]]</nowiki>` (here indicating that the affix should
display as `-käs` but be linked as `-kas`). Here, the template affix is arguably the entire piped link, while the
display affix is `-käs`.
*# Even in the absence of {{para|alt<var>N</var>}} parameters, `<alt:...>` inline modifiers and piped links, certain
languages have differences between the "template hyphen" specified in the template (which always needs to be
specified somehow or other in templates like {{tl|affix}}, to indicate that the term is an affix and what type of
affix it is) and the display hyphen (see above), with corresponding differences between template and display
affixes.
* A (regular) "link affix" is the affix that is linked to when the affix is shown to the user. The link affix is usually
the same as the display affix, but will differ in one of three circumstances:
*# The display and link affixes are explicitly made different using {{para|alt<var>N</var>}} parameters, `<alt:...>`
inline modifiers or piped links, as described above under "display affix".
*# For certain languages, certain affixes are mapped to canonical form using language-specific mappings. For example,
in Finnish, the adjective-forming suffix {{m|fi|-kas}} appears as {{m|fi|-käs}} after front vowels, but logically
both forms are the same suffix and should be linked and categorized the same. Similarly, in Latin, the negative and
intensive prefixes spelled {{m|la|in-}} (etymologically two distinct prefixes) appear variously as {{m|la|il-}},
{{m|la|im-}} or {{m|la|ir-}} before certain consonants. Mappings are supplied in [[Module:affix/lang-data/LANGCODE]]
to convert Finnish {{m|fi|-käs}} to {{m|fi|-kas}} for linking and categorization purposes. Note that the affixes in
the mappings use "lookup hyphens" to indicate the different types of affixes, which is usually the same as the
template hyphen but differs for Arabic scripts, because there are multiple possible template hyphens recognized but
only one lookup hyphen (tatweel). The form of the affix as used to look up in the mapping tables is called the
"lookup affix"; see below.
* A "stripped link affix" is a link affix that has been passed through the language's `stripDiacritics()` function, which
may strip certain diacritics: e.g. macrons in Latin and Old English (indicating length); acute and grave accents in
Russian and various other Slavic languages (indicating stress); vowel diacritics in most Arabic-script languages; and
also tatweel in some Arabic-script languages (currently, for example, Persian, Arabic and Urdu strip tatweel, but
Ottoman Turkish does not). Stripped link affixes are currently what are used in category names.
* A "lookup affix" is the form of the affix as it is looked up in the language-specific lookup mappings described above
under link affixes. There are actually two lookup stages:
*# First, the affix is looked up in a modified display form (specifically, the same as the display affix but using
lookup hyphens). Note that this lookup does not occur if an explicit display form is given using
{{para|alt<var>N</var>}} or an `<alt:...>` inline modifier, or if the template affix contains a piped or embedded
link.
*# If no entry is found, the affix is then looked up in a modified link form (specifically, the modified display
form passed through the language's `stripDiacritics()` function, which strips out certain diacritics, but with the
lookup hyphen re-added if it was stripped out, as in the case of tatweel in many Arabic-script languages).
The reason for this double lookup procedure is to allow for mappings that are sensitive to the extra diacritics, but
also allow for mappings that are not sensitive in this fashion (e.g. Russian {{m|ru|-ливый}} occurs both stressed and
unstressed, but is the same prefix either way).
* A "category affix" is the affix as it appears in categories such as [[:Category:Finnish terms suffixed with -kas|
Category:Finnish terms suffixed with ''-kas'']]. The category affix is currently always the same as the stripped link
affix. This means that for Arabic-script languages, it may or may not have a tatweel, even if the correponding display
affix and regular link affix have a tatweel. As mentioned above, stripDiacritics() strips tatweel for Arabic, Persian
and Urdu, but not for Ottoman Turkish. Hence affix categories for Arabic, Persian and Urdu will be missing the
tatweel, but affix categories for Ottoman Turkish will have it. An additional complication is that if the template
affix contains a ZWNJ, the display (and hence the link and category affixes) will have no hyphen attached in any case.
]==]
-----------------------------------------------------------------------------------------
-- Template and display hyphens --
-----------------------------------------------------------------------------------------
--[=[
Per-script template hyphens. The template hyphen is what appears in the {{affix}}/{{prefix}}/{{suffix}}/etc. template
(in the wikicode). See above.
They key below is a script code, after removing a hyphen and anything preceding. Hence, script codes like 'mnc-Mong'
and 'xwo-Mong' will match 'Mong'.
The value below is a string consisting of one or more hyphen characters. If there is more than one character, the
default hyphen must come last and a non-default function must be specified for the script in display_hyphens[] so
the correct display hyphen will be specified when no template hyphen is given (in {{suffix}}/{{prefix}}/etc.).
Script detection is normally done when linking, but we need to do it earlier. However, under most circumstances we
don't need to do script detection. Specifically, we only need to do script detection for a given language if
(a) the language has multiple scripts; and
(b) at least one of those scripts is listed below or in display_hyphens.
]=]
local ZWNJ = u(0x200C) -- zero-width non-joiner
local template_hyphens = {
-- This covers all Arabic scripts. See above.
["Arab"] = "ـ" .. ZWNJ .. "-", -- tatweel + zero-width non-joiner + regular hyphen
["Aran"] = "ـ" .. ZWNJ .. "-", -- tatweel + zero-width non-joiner + regular hyphen
["Hebr"] = "־", -- Hebrew-specific hyphen termed "maqqef"
["Mong"] = "᠊",
-- FIXME! What about the following right-to-left scripts?
-- Adlm (Adlam)
-- Armi (Imperial Aramaic)
-- Avst (Avestan)
-- Cprt (Cypriot)
-- Khar (Kharoshthi)
-- Mand (Mandaic/Mandaean)
-- Mani (Manichaean)
-- Mend (Mende/Mende Kikakui)
-- Narb (Old North Arabian)
-- Nbat (Nabataean/Nabatean)
-- Nkoo (N'Ko)
-- Orkh (Orkhon runes)
-- Phli (Inscriptional Pahlavi)
-- Phlp (Psalter Pahlavi)
-- Phlv (Book Pahlavi)
-- Phnx (Phoenician)
-- Prti (Inscriptional Parthian)
-- Rohg (Hanifi Rohingya)
-- Samr (Samaritan)
-- Sarb (Old South Arabian)
-- Sogd (Sogdian)
-- Sogo (Old Sogdian)
-- Syrc (Syriac)
-- Thaa (Thaana)
}
-- Hyphens used when looking up an affix in a lang-specific affix mapping. Defaults to regular hyphen (-). The keys
-- are script codes, after removing a hyphen and anything preceding. Hence, script codes like 'mnc-Mong' and 'xwo-Mong'
-- will match 'Mong'. The value should be a single character.
local lookup_hyphens = {
["Hebr"] = "־",
-- This covers all Arabic scripts. See above.
["Arab"] = "ـ",
["Aran"] = "ـ",
}
-- Default display-hyphen function.
local function default_display_hyphen(script, hyph)
if not hyph then
return template_hyphens[script] or "-"
end
return hyph
end
local function arab_get_display_hyphen(_script, hyph)
if not hyph then
return "ـ" -- tatweel
elseif hyph == ZWNJ then
return ""
else
return hyph
end
end
local function no_display_hyphen(_script, _hyph)
return ""
end
-- Per-script function to return the correct display hyphen given the script and template hyphen. The function should
-- also handle the case where the passed-in template hyphen is nil, corresponding to the situation in
-- {{prefix}}/{{suffix}}/etc. where no template hyphen is specified. The key is the script code after removing a hyphen
-- and anything preceding, so 'mnc-Mong', 'xwo-Mong' etc. will match 'Mong'.
local display_hyphens = {
-- This covers all Arabic scripts. See above.
["Arab"] = arab_get_display_hyphen,
["Aran"] = arab_get_display_hyphen,
["Bopo"] = no_display_hyphen,
["Hani"] = no_display_hyphen,
["Hans"] = no_display_hyphen,
["Hant"] = no_display_hyphen,
-- The following is a mixture of several scripts. Hopefully the specs here are correct!
["Jpan"] = no_display_hyphen,
["Jurc"] = no_display_hyphen,
["Kitl"] = no_display_hyphen,
["Kits"] = no_display_hyphen,
["Laoo"] = no_display_hyphen,
["Nshu"] = no_display_hyphen,
["Shui"] = no_display_hyphen,
["Tang"] = no_display_hyphen,
["Thaa"] = no_display_hyphen,
["Thai"] = no_display_hyphen,
["Tibt"] = no_display_hyphen,
}
-----------------------------------------------------------------------------------------
-- Basic Utility functions --
-----------------------------------------------------------------------------------------
local function glossary_link(entry, text)
text = text or entry
return "[[Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end
local function track(page)
if type(page) == "table" then
for i, pg in ipairs(page) do
page[i] = "affix/" .. pg
end
else
page = "affix/" .. page
end
require("Module:debug/track")(page)
end
local function ine(val)
return val ~= "" and val or nil
end
-----------------------------------------------------------------------------------------
-- Compound types --
-----------------------------------------------------------------------------------------
local function make_compound_type(typ, alttext)
return {
text = glossary_link(typ, alttext) .. " compound",
cat = typ .. " compounds",
}
end
-- Make a compound type entry with a simple rather than glossary link.
-- These should be replaced with a glossary link when the entry in the glossary
-- is created.
local function make_non_glossary_compound_type(typ, alttext)
local link = alttext and "[[" .. typ .. "|" .. alttext .. "]]" or "[[" .. typ .. "]]"
return {
text = link .. " compound",
cat = typ .. " compounds",
}
end
local function make_raw_compound_type(typ, alttext)
return {
text = glossary_link(typ, alttext),
cat = pluralize(typ),
}
end
local function make_borrowing_type(typ, alttext)
return {
text = glossary_link(typ, alttext),
borrowing_type = pluralize(typ),
}
end
export.etymology_types = {
["adapted borrowing"] = make_borrowing_type("adapted borrowing"),
["adap"] = "adapted borrowing",
["abor"] = "adapted borrowing",
["alliterative"] = make_non_glossary_compound_type("alliterative"),
["allit"] = "alliterative",
["antonymous"] = make_non_glossary_compound_type("antonymous"),
["ant"] = "antonymous",
["bahuvrihi"] = make_compound_type("bahuvrihi", "bahuvrīhi"),
["bahu"] = "bahuvrihi",
["bv"] = "bahuvrihi",
["coordinative"] = make_compound_type("coordinative"),
["coord"] = "coordinative",
["descriptive"] = make_compound_type("descriptive"),
["desc"] = "descriptive",
["determinative"] = make_compound_type("determinative"),
["det"] = "determinative",
["dvandva"] = make_compound_type("dvandva"),
["dva"] = "dvandva",
["dvigu"] = make_compound_type("dvigu"),
["dvi"] = "dvigu",
["endocentric"] = make_compound_type("endocentric"),
["endo"] = "endocentric",
["exocentric"] = make_compound_type("exocentric"),
["exo"] = "exocentric",
["izafet I"] = make_compound_type("izafet I"),
["iz1"] = "izafet I",
["izafet II"] = make_compound_type("izafet II"),
["iz2"] = "izafet II",
["izafet III"] = make_compound_type("izafet III"),
["iz3"] = "izafet III",
["karmadharaya"] = make_compound_type("karmadharaya", "karmadhāraya"),
["karma"] = "karmadharaya",
["kd"] = "karmadharaya",
["kenning"] = make_raw_compound_type("kenning"),
["ken"] = "kenning",
["rhyming"] = make_non_glossary_compound_type("rhyming"),
["rhy"] = "rhyming",
["synonymous"] = make_non_glossary_compound_type("synonymous"),
["syn"] = "synonymous",
["tatpurusa"] = make_compound_type("tatpurusa", "tatpuruṣa"),
["tat"] = "tatpurusa",
["tp"] = "tatpurusa",
}
local function process_etymology_type(typ, nocap, notext, has_parts)
local text_sections = {}
local categories = {}
local borrowing_type
if typ then
local typdata = export.etymology_types[typ]
if type(typdata) == "string" then
typdata = export.etymology_types[typdata]
end
if not typdata then
error("Internal error: Unrecognized type '" .. typ .. "'")
end
local text = typdata.text
if not nocap then
text = ucfirst(text)
end
local cat = typdata.cat
borrowing_type = typdata.borrowing_type
local oftext = typdata.oftext or " of"
if not notext then
table.insert(text_sections, text)
if has_parts then
table.insert(text_sections, oftext)
table.insert(text_sections, " ")
end
end
if cat then
table.insert(categories, cat)
end
end
return text_sections, categories, borrowing_type
end
-----------------------------------------------------------------------------------------
-- Utility functions --
-----------------------------------------------------------------------------------------
-- Iterate an array up to the greatest integer index found.
local function ipairs_with_gaps(t)
local indices = m_table.numKeys(t)
local max_index = #indices > 0 and math.max(unpack(indices)) or 0
local i = 0
return function()
if i < max_index then
i = i + 1
return i, t[i]
end
end
end
export.ipairs_with_gaps = ipairs_with_gaps
--[==[
Join formatted parts (in `parts_formatted`) together with any overall {{para|lit}} spec (in `lit`) plus categories,
which are formatted by prepending the language name as found in `lang`. The value of an entry in `categories` can be
either a string (which is formatted using `sort_key`) or a table of the form `{ {cat=<var>category</var>,
sort_key=<var>sort_key</var>, sort_base=<var>sort_base</var>}`, specifying the sort key and sort base to use when
formatting the category. If `nocat` is given, no categories are added; otherwise, `force_cat` causes categories to be
added even on userspace pages.
]==]
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
function export.join_formatted_parts(data)
local cattext
local lang = data.data.lang
local force_cat = data.data.force_cat or debug_force_cat
if data.data.nocat then
cattext = ""
else
for i, cat in ipairs(data.categories) do
if type(cat) == "table" then
data.categories[i] = require(utilities_module).format_categories(lang:getFullName() .. " " .. cat_word(lang, cat.cat),
lang, cat.sort_key, cat.sort_base, force_cat)
else
data.categories[i] = require(utilities_module).format_categories(lang:getFullName() .. " " .. cat_word(lang, cat), lang,
data.data.sort_key, nil, force_cat)
end
end
cattext = table.concat(data.categories)
end
local result = table.concat(data.parts_formatted, not data.separator_already_added and " +‎ " or nil) ..
(data.data.lit and ", literally " .. m_links.mark(data.data.lit, "gloss") or "")
local q = data.data.q
local qq = data.data.qq
local l = data.data.l
local ll = data.data.ll
if q and q[1] or qq and qq[1] or l and l[1] or ll and ll[1] then
result = require(decorations_module).format_decorations {
lang = lang,
text = result,
q = q,
qq = qq,
l = l,
ll = ll,
}
end
return result .. cattext
end
-- Remove links and call lang:stripDiacritics(term).
local function strip_diacritics_no_links(lang, term)
return lang:stripDiacritics(m_links.remove_links(term))
end
--[=[
Convert a raw part as passed into an entry point into a part ready for linking. `lang` and `sc` are the overall
language and script objects. This uses the overall language and script objects as defaults for the part and parses off
any fragment from the term. We need to do the latter so that fragments don't end up in categories and so that we
correctly do affix mapping even in the presence of fragments.
]=]
local function canonicalize_part(part, lang, sc)
if not part then
return
end
-- Save the original (user-specified, part-specific) value of `lang`. If such a value is specified, we don't insert
-- a '*fixed with' category, and we format the part using format_derived() in [[Module:etymology]] rather than
-- full_link() in [[Module:links]].
part.part_lang = part.lang
part.lang = part.lang or lang
part.sc = part.sc or sc
local term = part.term
if not term then
return
elseif not part.fragment then
part.term, part.fragment = m_links.get_fragment(term)
else
part.term = m_links.get_fragment(term)
end
end
--[==[
Construct a single linked part based on the information in `part`, for use by `show_affix()` and other entry points.
This should be called after `canonicalize_part()` is called on the part. This is a thin wrapper around `full_link()` in
[[Module:links]] unless `part.part_lang` is specified (indicating that a part-specific language was given), in which
case `format_derived()` in [[Module:etymology]] is called to display a term in a language other than the language of
the overall term (specified in `data.lang`). `data` contains the entire object passed into the entry point and is used
to access information for constructing the categories added by `format_derived()`.
]==]
function export.link_term(part, data, include_separator)
local result
if part.part_lang then
result = require(etymology_module).format_derived {
lang = data.lang,
terms = {part},
sources = {part.lang},
sort_key = data.sort_key,
nocat = data.nocat,
template_name = "affix",
decorations_on_outside = true,
borrowing_type = data.borrowing_type,
force_cat = data.force_cat or debug_force_cat,
}
else
result = m_links.full_link(part, "term")
end
if include_separator and part.separator then
return part.separator .. result
else
return result
end
end
local function canonicalize_script_code(scode)
-- Convert 'mnc-Mong', 'xwo-Mong' etc. to 'Mong'.
return (scode:gsub("^.*%-", ""))
end
-----------------------------------------------------------------------------------------
-- Affix-handling functions --
-----------------------------------------------------------------------------------------
-- Figure out the appropriate script for the given affix and language (unless the script is explicitly passed in), and
-- return the values of template_hyphens[], display_hyphens[] and lookup_hyphens[] for that script, substituting
-- default values as appropriate. Four values are returned:
-- DETECTED_SCRIPT, TEMPLATE_HYPHEN, DISPLAY_HYPHEN, LOOKUP_HYPHEN
local function detect_script_and_hyphens(text, lang, sc)
local scode
-- 1. If the script is explicitly passed in, use it.
if sc then
scode = sc:getCode()
else
local possible_script_codes = lang:getScriptCodes()
-- YUCK! `possible_script_codes` comes from loadData() so #possible_scripts doesn't work (always returns 0).
local num_possible_script_codes = m_table.length(possible_script_codes)
if num_possible_script_codes == 0 then
-- This shouldn't happen; if the language has no script codes,
-- the list {"None"} should be returned.
error("Something is majorly wrong! Language " .. lang:getCanonicalName() .. " has no script codes.")
end
if num_possible_script_codes == 1 then
-- 2. If the language has only one possible script, use it.
scode = possible_script_codes[1]
else
-- 3. Check if any of the possible scripts for the language have non-default values for template_hyphens[]
-- or display_hyphens[]. If so, we need to do script detection on the text. If not, just use "Latn",
-- which may not be technically correct but produces the right results because Latn has all default
-- values for template_hyphens[] and display_hyphens[].
local may_have_nondefault_hyphen = false
for _, script_code in ipairs(possible_script_codes) do
script_code = canonicalize_script_code(script_code)
if template_hyphens[script_code] or display_hyphens[script_code] then
may_have_nondefault_hyphen = true
break
end
end
if not may_have_nondefault_hyphen then
scode = "Latn"
else
scode = lang:findBestScript(text):getCode()
end
end
end
scode = canonicalize_script_code(scode)
local template_hyphen = template_hyphens[scode] or "-"
local lookup_hyphen = lookup_hyphens[scode] or "-"
local display_hyphen = display_hyphens[scode] or default_display_hyphen
return scode, template_hyphen, display_hyphen, lookup_hyphen
end
--[=[
Given a template affix `term` and an affix type `affix_type`, change the relevant template hyphen(s) in the affix to
the display or lookup hyphen specified in `new_hyphen`, or add them if they are missing. `new_hyphen` can be a string,
specifying a fixed hyphen, or a function of two arguments (the script code `scode` and the discovered template hyphen,
or nil of no relevant template hyphen is present). `thyph_re` is a Lua pattern (which must be enclosed in parens) that
matches the possible template hyphens. Note that not all template hyphens present in the affix are changed, but only
the "relevant" ones (e.g. for a prefix, a relevant template hyphen is one coming at the end of the affix).
]=]
local function reconstruct_term_per_hyphens(term, affix_type, scode, thyph_re, new_hyphen)
local function get_hyphen(hyph)
if type(new_hyphen) == "string" then
return new_hyphen
end
return new_hyphen(scode, hyph)
end
if affix_type == "non-affix" then
return term
elseif affix_type == "circumfix" then
local before, before_hyphen, after_hyphen, after = rmatch(term, "^(.*)" .. thyph_re .. " " .. thyph_re
.. "(.*)$")
if not before or ulen(term) <= 3 then
-- Unlike with other types of affixes, don't try to add hyphens in the middle of the term to convert it to
-- a circumfix. Also, if the term is just hyphen + space + hyphen, return it.
return term
end
return before .. get_hyphen(before_hyphen) .. " " .. get_hyphen(after_hyphen) .. after
elseif affix_type == "infix" or affix_type == "interfix" then
local before_hyphen, middle, after_hyphen = rmatch(term, "^" .. thyph_re .. "(.*)" .. thyph_re .. "$")
if before_hyphen and ulen(term) <= 1 then
-- If the term is just a hyphen, return it.
return term
end
return get_hyphen(before_hyphen) .. (middle or term) .. get_hyphen(after_hyphen)
elseif affix_type == "prefix" then
local middle, after_hyphen = rmatch(term, "^(.*)" .. thyph_re .. "$")
if middle and ulen(term) <= 1 then
-- If the term is just a hyphen, return it.
return term
end
return (middle or term) .. get_hyphen(after_hyphen)
elseif affix_type == "suffix" then
local before_hyphen, middle = rmatch(term, "^" .. thyph_re .. "(.*)$")
if before_hyphen and ulen(term) <= 1 then
-- If the term is just a hyphen, return it.
return term
end
return get_hyphen(before_hyphen) .. (middle or term)
else
error(("Internal error: Unrecognized affix type '%s'"):format(affix_type))
end
end
--[=[
Look up a mapping from a given affix variant to the canonical form used in categories and links. The lookup tables are
language-specific according to `lang`, and may be ID-specific according to `affix_id`. The affixes as they appear in the
lookup tables (both the variant and the canonical form) are in "lookup affix" format (approximately speaking, they use a
regular hyphen for most scripts, but a tatweel for Arabic-script entries and a maqqef for Hebrew-script entries), but
the passed-in `affix` param is in "template affix" format (which differs from the lookup affix for Arabic-script
entries, because more types of hyphens are allowed in template affixes; see the comments at the top of the file). The
remaining parameters to this function are used to convert from template affixes to lookup affixes; see the
reconstruct_term_per_hyphens() function above.
If the affix contains brackets, no lookup is done. Otherwise, a two-stage process is used, first looking up the affix
directly and then stripping diacritics and looking it up again. The reason for this is documented above in the comments
at the top of the file (specifically, the comments describing lookup affixes).
The value of a mapping can either be a string (do the mapping regardless of affix ID) or a table indexed by affix ID
(where the special value `false` indicates no affix ID). The values of entries in this table can also be strings, or
tables with keys `affix` and `id` (again, use `false` to indicate no ID). This allows an affix mapping to map from one
ID to another (for example, this is used in English to map the [[an-]] prefix with no ID to the [[a-]] prefix with the
ID 'not').
The Given a template affix `term` and an affix type `affix_type`, change the relevant template hyphen(s) in the affix to
the display or lookup hyphen specified in `new_hyphen`, or add them if they are missing. `new_hyphen` can be a string,
specifying a fixed hyphen, or a function of two arguments (the script code `scode` and the discovered template hyphen,
or nil of no relevant template hyphen is present). `thyph_re` is a Lua pattern (which must be enclosed in parens) that
matches the possible template hyphens. Note that not all template hyphens present in the affix are changed, but only
the "relevant" ones (e.g. for a prefix, a relevant template hyphen is one coming at the end of the affix).
]=]
local function lookup_affix_mapping(affix, affix_type, lang, scode, thyph_re, lookup_hyph, affix_id)
local function do_lookup(afx)
-- Ensure that the affix uses lookup hyphens regardless of whether it used a different type of hyphens before
-- or no hyphens.
local lookup_affix = reconstruct_term_per_hyphens(afx, affix_type, scode, thyph_re, lookup_hyph)
local function do_lookup_for_langcode(langcode)
if export.langs_with_lang_specific_data[langcode] then
local langdata = mw.loadData(export.affix_lang_data_module_prefix .. langcode)
if langdata.affix_mappings then
local mapping = langdata.affix_mappings[lookup_affix]
if mapping then
if type(mapping) == "table" then
mapping = mapping[affix_id] or mapping.default or mapping[affix_id or false]
if mapping then
return mapping
end
else
return mapping
end
end
end
end
end
-- If `lang` is an etymology-only language, look for a mapping both for it and its full parent.
local langcode = lang:getCode()
local mapping = do_lookup_for_langcode(langcode)
if mapping then
return mapping
end
local full_langcode = lang:getFullCode()
if full_langcode ~= langcode then
mapping = do_lookup_for_langcode(full_langcode)
if mapping then
return mapping
end
end
return nil
end
if affix:find("%[%[") then
return nil
end
return do_lookup(affix) or do_lookup(lang:stripDiacritics(affix)) or nil
end
--[==[
For a given template term in a given language (see the definition of "template affix" near the top of the file),
possibly in an explicitly specified script `sc` (but usually nil), return the term's affix type ({"prefix"},
{"interfix"}, {"suffix"}, {"circumfix"} or {"non-affix"}) along with the corresponding link and display affixes
(see definitions near the top of the file); also the corresponding lookup affix (if `return_lookup_affix` is specified).
The term passed in should already have any fragment (after the # sign) parsed off of it. Four values are returned:
`affix_type`, `link_term`, `display_term` and `lookup_term`. The affix type can be passed in instead of autodetected; in
this case, the template term need not have any attached hyphens, and the appropriate hyphens will be added in the
appropriate places. If `do_affix_mapping` is specified, look up the affix in the lang-specific affix mappings, as
described in the comment at the top of the file; otherwise, the link and display terms will always be the same. (They
will be the same in any case if the template term has a bracketed link in it or is not an affix.) If
`return_lookup_affix` is given, the fourth return value contains the term with appropriate lookup hyphens in the
appropriate places; otherwise, it is the same as the display term. (This functionality is used in
[[Module:category tree/affixes and compounds]] to convert link affixes into lookup affixes so that they can be looked up
in the affix mapping tables.)
Exported because used by [[Module:headword utilities]] to determine the affix type of a given pagename.
]==]
function export.parse_term_for_affixes(term, lang, sc, affix_type, do_affix_mapping, return_lookup_affix, affix_id)
if not term then
return "non-affix", nil, nil, nil
end
if term == "^" then
-- Indicates a null term to emulate the behavior of {{suffix|foo||bar}}.
term = ""
return "non-affix", term, term, term
end
if term:find("^%^") then
-- HACK! ^ at the beginning of Korean languages has a special meaning, triggering capitalization of the
-- transliteration. Don't interpret it as "force non-affix" for those languages.
local langcode = lang:getCode()
if langcode ~= "ko" and langcode ~= "okm" and langcode ~= "jje" then
-- Formerly we allowed ^ to force non-affix type; this is now handled using an inline modifier
-- <naf>, <root>, etc. Throw an error for the moment when the old way is encountered.
error("Use of ^ to force non-affix status is no longer supported; use an inline modifier <naf> or <root> " ..
"after the component")
end
end
-- Remove an asterisk if the morpheme is reconstructed and add it back at the end.
local reconstructed = ""
if term:find("^%*") then
reconstructed = "*"
term = term:gsub("^%*", "")
end
local scode, thyph, dhyph, lhyph = detect_script_and_hyphens(term, lang, sc)
thyph = "([" .. thyph .. "])"
if not affix_type then
if rfind(term, thyph .. " " .. thyph) then
affix_type = "circumfix"
else
local has_beginning_hyphen = rfind(term, "^" .. thyph)
local has_ending_hyphen = rfind(term, thyph .. "$")
if has_beginning_hyphen and has_ending_hyphen then
affix_type = "interfix"
elseif has_ending_hyphen then
affix_type = "prefix"
elseif has_beginning_hyphen then
affix_type = "suffix"
else
affix_type = "non-affix"
end
end
end
local link_term, display_term, lookup_term
if affix_type == "non-affix" then
link_term = term
display_term = term
lookup_term = term
else
display_term = reconstruct_term_per_hyphens(term, affix_type, scode, thyph, dhyph)
if do_affix_mapping then
link_term = lookup_affix_mapping(term, affix_type, lang, scode, thyph, lhyph, affix_id)
-- The return value of lookup_affix_mapping() may be an affix mapping with lookup hyphens if a mapping
-- was found, otherwise nil if a mapping was not found. We need to convert to display hyphens in
-- either case, but in the latter case we can reuse the display term, which has already been converted.
if link_term then
link_term = reconstruct_term_per_hyphens(link_term, affix_type, scode, thyph, dhyph)
else
link_term = display_term
end
else
link_term = display_term
end
if return_lookup_affix then
lookup_term = reconstruct_term_per_hyphens(term, affix_type, scode, thyph, lhyph)
else
lookup_term = display_term
end
end
link_term = reconstructed .. link_term
display_term = reconstructed .. display_term
lookup_term = reconstructed .. lookup_term
return affix_type, link_term, display_term, lookup_term
end
--[==[
Add a hyphen to a term in the appropriate place, based on the specified affix type, stripping off any existing hyphens
in that place. For example, if `affix_type` == {"prefix"}, we'll add a hyphen onto the end if it's not already there (or
is of the wrong type). Three values are returned: the link term, display term and lookup term. This function is a thin
wrapper around `parse_term_for_affixes`; see the comments above that function for more information. Note that this
function is exposed externally because it is called by [[Module:category tree/affixes and compounds]]; see the comment
in `parse_term_for_affixes` for more information.
]==]
function export.make_affix(term, lang, sc, affix_type, do_affix_mapping, return_lookup_affix, affix_id)
if not (affix_type == "prefix" or affix_type == "suffix" or affix_type == "circumfix" or affix_type == "infix" or
affix_type == "interfix" or affix_type == "non-affix") then
error("Internal error: Invalid affix type " .. (affix_type or "(nil)"))
end
local _, link_term, display_term, lookup_term = export.parse_term_for_affixes(term, lang, sc, affix_type,
do_affix_mapping, return_lookup_affix, affix_id)
return link_term, display_term, lookup_term
end
-----------------------------------------------------------------------------------------
-- Main entry points --
-----------------------------------------------------------------------------------------
--[==[
Core categorization logic for affixes. This is shared between show_affix(), show_compound_like() and
get_affix_categories_only(). Returns the categories array and other metadata needed for formatting.
]==]
local function generate_affix_categories(data)
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
local text_sections, categories, borrowing_type =
process_etymology_type(data.type, data.surface_analysis or data.nocap, data.notext, #data.parts > 0)
data.borrowing_type = borrowing_type
-- Process each part
local whole_words = 0
local is_affix_or_compound = false
-- Canonicalize and generate links for all the parts first; then do categorization in a separate step, because when
-- processing the first part for categorization, we may access the second part and need it already canonicalized.
for i, part in ipairs_with_gaps(data.parts) do
part = part or {}
data.parts[i] = part
canonicalize_part(part, data.lang, data.sc)
-- Determine affix type and get link and display terms (see text at top of file). Store them in the part
-- (in fields that won't clash with fields used by full_link() in [[Module:links]] or link_term()), so they
-- can be used in the loop below when categorizing.
part.affix_type, part.affix_link_term, part.affix_display_term = export.parse_term_for_affixes(part.term,
part.lang, part.sc, part.type, not part.alt, nil, part.id)
-- If link_term is an empty string, either a bare ^ was specified or an empty term was used along with inline
-- modifiers. The intention in either case is not to link the term.
part.term = ine(part.affix_link_term)
-- If part.alt would be the same as part.term, make it nil, so that it isn't erroneously tracked as being
-- redundant alt text.
part.alt = part.alt or (part.affix_display_term ~= part.affix_link_term and part.affix_display_term) or nil
end
if not data.noaffixcat then
-- Now do categorization.
for i, part in ipairs_with_gaps(data.parts) do
local affix_type = part.affix_type
if affix_type ~= "non-affix" then
is_affix_or_compound = true
-- Make a sort key. For the first part, use the second part as the sort key; the intention is that if the
-- term has a prefix, sorting by the prefix won't be very useful so we sort by what follows, which is
-- presumably the root.
local part_sort_base = nil
local part_sort = part.sort or data.sort_key
if i == 1 and data.parts[2] and data.parts[2].term then
local part2 = data.parts[2]
-- If the second-part link term is empty, the user requested an unlinked term; avoid a wikitext error
-- by using the alt value if available.
part_sort_base = ine(part2.affix_link_term) or ine(part2.alt)
if part_sort_base then
part_sort_base = strip_diacritics_no_links(part2.lang, part_sort_base)
end
end
if part.pos and rfind(part.pos, "patronym") then
table.insert(categories, {cat = "patronymics", sort_key = part_sort, sort_base = part_sort_base})
end
if data.pos ~= "terms" and part.pos and rfind(part.pos, "diminutive") then
table.insert(categories, {cat = "diminutive " .. data.pos, sort_key = part_sort,
sort_base = part_sort_base})
end
-- Don't add a '*fixed with' category if the link term is empty or is in a different language.
if ine(part.affix_link_term) and not part.part_lang then
table.insert(categories, {cat = data.pos .. " " .. affix_type .. "ed with " ..
strip_diacritics_no_links(part.lang, part.affix_link_term) ..
(part.id and " (" .. part.id .. ")" or ""),
sort_key = part_sort, sort_base = part_sort_base})
end
else
whole_words = whole_words + 1
if whole_words == 2 then
is_affix_or_compound = true
table.insert(categories, "compound " .. data.pos)
end
end
end
-- Make sure there was either an affix or a compound (two or more non-affix terms).
if not is_affix_or_compound and not data.allow_no_affixes_or_compounds then
error("The parameters did not include any affixes, and the term is not a compound. Please provide at least one affix.")
end
end
return text_sections, categories, borrowing_type
end
--[==[
Implementation of {{tl|affix}} and {{tl|surface analysis}}. `data` contains all the information describing the affixes to
be displayed, and contains the following:
* `.lang` ('''required'''): Overall language object. Different from term-specific language objects (see `.parts` below).
* `.sc`: Overall script object (usually omitted). Different from term-specific script objects.
* `.parts` ('''required'''): List of objects describing the affixes to show. The general format of each object is as would
be passed to `full_link()`, except that the `.lang` field should be missing unless the term is of a language
different from the overall `.lang` value (in such a case, the language name is shown along with the term and
an additional "derived from" category is added). '''WARNING''': The data in `.parts` will be destructively
modified.
* `.pos`: Overall part of speech (used in categories, defaults to {"terms"}). Different from term-specific part of speech.
* `.sort_key`: Overall sort key. Normally omitted except e.g. in Japanese.
* `.type`: Type of compound, if the parts in `.parts` describe a compound. Strictly optional, and if supplied, the
compound type is displayed before the parts (normally capitalized, unless `.nocap` is given).
* `.nocap`: Don't capitalize the first letter of text displayed before the parts (relevant only if `.type` or
`.surface_analysis` is given).
* `.notext`: Don't display any text before the parts (relevant only if `.type` or `.surface_analysis` is given).
* `.nocat`: Disable all categorization.
* `.noaffixcat`: Disable affix (and compound) categorization. Relevant for e.g. blends, which may otherwise
be incorrectly categorized as compound terms.
* `.lit`: Overall literal definition. Different from term-specific literal definitions.
* `.force_cat`: Always display categories, even on userspace pages.
* `.surface_analysis`: Implement {{surface analysis}}; adds `By surface analysis, ` before the parts.
'''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`.
]==]
function export.show_affix(data)
local text_sections, categories, _ = generate_affix_categories(data)
-- Process each part for display
local parts_formatted = {}
for i, part in ipairs_with_gaps(data.parts) do
-- Make a link for the part
table.insert(parts_formatted, export.link_term(part, data, "include_separator"))
end
if data.surface_analysis then
local text = "by " .. glossary_link("surface analysis") .. ", "
if not data.nocap then
text = ucfirst(text)
end
table.insert(text_sections, 1, text)
end
table.insert(text_sections, export.join_formatted_parts { data = data, parts_formatted = parts_formatted,
categories = categories, separator_already_added = true })
return table.concat(text_sections)
end
--[==[
Get only the categories that would be generated by show_affix(), without any text output or formatting.
This is used by Module:etymon to get affix categorization.
Returns an array of category objects, where
each entry is either a string (simple category name) or a table with keys `cat`, `sort_key`,
and `sort_base` for more complex categorization.
`data` should have the same structure as passed to show_affix():
* `.lang` (required): Overall language object
* `.parts` (required): Array of affix part objects with `.term`, `.lang`, `.id`, etc.
* `.pos`: Part of speech (defaults to "terms")
* `.sort_key`: Overall sort key for categories
'''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`.
]==]
function export.get_affix_categories_only(data)
local _, categories, _ = generate_affix_categories(data)
return categories
end
function export.show_surface_analysis(data)
data.surface_analysis = true
data.allow_no_affixes_or_compounds = true
return export.show_affix(data)
end
--[==[
Implementation of {{tl|compound}}.
'''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`.
]==]
function export.show_compound(data)
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
local text_sections, categories, borrowing_type =
process_etymology_type(data.type, data.nocap, data.notext, #data.parts > 0)
data.borrowing_type = borrowing_type
local parts_formatted = {}
table.insert(categories, "compound " .. data.pos)
-- Make links out of all the parts
local whole_words = 0
for i, part in ipairs(data.parts) do
canonicalize_part(part, data.lang, data.sc)
-- Determine affix type and get link and display terms (see text at top of file).
local affix_type, link_term, display_term = export.parse_term_for_affixes(part.term, part.lang, part.sc,
part.type, not part.alt, nil, part.id)
-- If the term is an interfix or the type was explicitly given, recognize it as such (which means e.g. that we
-- will display the term without hyphens for East Asian languages). Otherwise, ignore the fact that it looks
-- like an affix and display as specified in the template (but pay attention to the detected affix type for
-- certain tracking purposes).
if affix_type == "interfix" or (part.type and part.type ~= "non-affix") then
-- If link_term is an empty string, either a bare ^ was specified or an empty term was used along with
-- inline modifiers. The intention in either case is not to link the term. Don't add a '*fixed with'
-- category in this case, or if the term is in a different language.
-- If part.alt would be the same as part.term, make it nil, so that it isn't erroneously tracked as being
-- redundant alt text.
if link_term and link_term ~= "" and not part.part_lang then
table.insert(categories, {cat = data.pos .. " " .. affix_type .. "ed with " ..
strip_diacritics_no_links(part.lang, link_term), sort_key = part.sort or data.sort_key})
end
part.term = link_term ~= "" and link_term or nil
part.alt = part.alt or (display_term ~= link_term and display_term) or nil
else
if affix_type ~= "non-affix" then
local langcode = data.lang:getCode()
-- If `data.lang` is an etymology-only language, track both using its code and its full parent's code.
track { affix_type, affix_type .. "/lang/" .. langcode }
local full_langcode = data.lang:getFullCode()
if langcode ~= full_langcode then
track(affix_type .. "/lang/" .. full_langcode)
end
else
whole_words = whole_words + 1
end
end
table.insert(parts_formatted, export.link_term(part, data, "include_separator"))
end
if whole_words == 1 then
track("one whole word")
elseif whole_words == 0 then
track("looks like confix")
end
table.insert(text_sections, export.join_formatted_parts { data = data, parts_formatted = parts_formatted,
categories = categories, separator_already_added = true })
return table.concat(text_sections)
end
--[==[
Implementation of {{tl|blend}}, {{tl|univerbation}} and similar "compound-like" templates.
'''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`.
]==]
function export.show_compound_like(data)
data.allow_no_affixes_or_compounds = true
local text_sections, categories, _ = generate_affix_categories(data)
if data.cat then
table.insert(categories, data.cat)
end
-- Process each part for display
local parts_formatted = {}
for i, part in ipairs_with_gaps(data.parts) do
-- Make a link for the part
table.insert(parts_formatted, export.link_term(part, data, "include_separator"))
end
if #data.parts > 0 and data.oftext then
table.insert(text_sections, 1, " " .. data.oftext .. " ")
end
if data.text then
table.insert(text_sections, 1, data.text)
end
table.insert(text_sections, export.join_formatted_parts { data = data, parts_formatted = parts_formatted,
categories = categories, separator_already_added = true })
return table.concat(text_sections)
end
--[==[
Make `part` (a structure holding information on an affix part) into an affix of type `affix_type`, and apply any
relevant affix mappings. For example, if the desired affix type is "suffix", this will (in general) add a hyphen onto
the beginning of the term, alt, tr and ts components of the part if not already present. The hyphen that's added is the
"display hyphen" (see above) and may be script-specific. (In the case of East Asian scripts, the display hyphen is an
empty string whereas the template hyphen is the regular hyphen, meaning that any regular hyphen at the beginning of the
part will be effectively removed.) `lang` and `sc` hold overall language and script objects.
Note that this also applies any language-specific affix mappings, so that e.g. if the language is Finnish and the user
specified [[-käs]] in the affix and didn't specify an `.alt` value, `part.term` will contain [[-kas]] and `part.alt` will
contain [[-käs]].
This function is used by the "legacy" templates ({{tl|prefix}}, {{tl|suffix}}, {{tl|confix}}, etc.) where the nature of
the affix is specified by the template itself rather than auto-determined from the affix, as is the case with
{{tl|affix}}.
'''WARNING''': This destructively modifies `part`.
]==]
local function make_part_into_affix(part, lang, sc, affix_type)
canonicalize_part(part, lang, sc)
local link_term, display_term = export.make_affix(part.term, part.lang, part.sc, affix_type, not part.alt, nil, part.id)
part.term = link_term
-- When we don't specify `do_affix_mapping` to make_affix(), link and display terms (first and second retvals of
-- make_affix()) are the same.
-- If part.alt would be the same as part.term, make it nil, so that it isn't erroneously tracked as being
-- redundant alt text.
part.alt = part.alt and export.make_affix(part.alt, part.lang, part.sc, affix_type) or (display_term ~= link_term and display_term) or nil
local Latn = require(scripts_module).getByCode("Latn")
part.tr = export.make_affix(part.tr, part.lang, Latn, affix_type)
part.ts = export.make_affix(part.ts, part.lang, Latn, affix_type)
end
local function track_wrong_affix_type(template, part, expected_affix_type)
if part and not part.type then
local affix_type = export.parse_term_for_affixes(part.term, part.lang, part.sc)
if affix_type ~= expected_affix_type then
local part_name = expected_affix_type or "base"
local langcode = part.lang:getCode()
local full_langcode = part.lang:getFullCode()
require("Module:debug/track") {
template,
template .. "/" .. part_name,
template .. "/" .. part_name .. "/" .. (affix_type or "none"),
template .. "/" .. part_name .. "/" .. (affix_type or "none") .. "/lang/" .. langcode
}
-- If `part.lang` is an etymology-only language, track both using its code and its full parent's code.
if full_langcode ~= langcode then
require("Module:debug/track")(
template .. "/" .. part_name .. "/" .. (affix_type or "none") .. "/lang/" .. full_langcode
)
end
end
end
end
local function insert_affix_category(categories, pos, affix_type, part, sort_key, sort_base)
-- Don't add a '*fixed with' category if the link term is empty or is in a different language.
if part.term and not part.part_lang then
local cat = pos .. " " .. affix_type .. "ed with " .. strip_diacritics_no_links(part.lang, part.term) ..
(part.id and " (" .. part.id .. ")" or "")
if sort_key or sort_base then
table.insert(categories, {cat = cat, sort_key = sort_key, sort_base = sort_base})
else
table.insert(categories, cat)
end
end
end
--[==[
Implementation of {{tl|circumfix}}.
'''WARNING''': This destructively modifies both `data` and `.prefix`, `.base` and `.suffix`.
]==]
function export.show_circumfix(data)
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
canonicalize_part(data.base, data.lang, data.sc)
-- Hyphenate the affixes and apply any affix mappings.
make_part_into_affix(data.prefix, data.lang, data.sc, "prefix")
make_part_into_affix(data.suffix, data.lang, data.sc, "suffix")
track_wrong_affix_type("circumfix", data.prefix, "prefix")
track_wrong_affix_type("circumfix", data.base, nil)
track_wrong_affix_type("circumfix", data.suffix, "suffix")
-- Create circumfix term.
local circumfix = nil
if data.prefix.term and data.suffix.term then
circumfix = data.prefix.term .. " " .. data.suffix.term
data.prefix.alt = data.prefix.alt or data.prefix.term
data.suffix.alt = data.suffix.alt or data.suffix.term
data.prefix.term = circumfix
data.suffix.term = circumfix
end
-- Make links out of all the parts.
local parts_formatted = {}
local categories = {}
local sort_base
if data.base.term then
sort_base = strip_diacritics_no_links(data.base.lang, data.base.term)
end
table.insert(parts_formatted, export.link_term(data.prefix, data))
table.insert(parts_formatted, export.link_term(data.base, data))
table.insert(parts_formatted, export.link_term(data.suffix, data))
-- Insert the categories, but don't add a '*fixed with' category if the link term is in a different language.
if not data.prefix.part_lang then
table.insert(categories, {cat=data.pos .. " circumfixed with " .. strip_diacritics_no_links(data.prefix.lang,
circumfix), sort_key=data.sort_key, sort_base=sort_base})
end
return export.join_formatted_parts { data = data, parts_formatted = parts_formatted, categories = categories }
end
--[==[
Implementation of {{tl|confix}}.
'''WARNING''': This destructively modifies both `data` and `.prefix`, `.base` and `.suffix`.
]==]
function export.show_confix(data)
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
canonicalize_part(data.base, data.lang, data.sc)
-- Hyphenate the affixes and apply any affix mappings.
make_part_into_affix(data.prefix, data.lang, data.sc, "prefix")
make_part_into_affix(data.suffix, data.lang, data.sc, "suffix")
track_wrong_affix_type("confix", data.prefix, "prefix")
track_wrong_affix_type("confix", data.base, nil)
track_wrong_affix_type("confix", data.suffix, "suffix")
-- Make links out of all the parts.
local parts_formatted = {}
local prefix_sort_base
if data.base and data.base.term then
prefix_sort_base = strip_diacritics_no_links(data.base.lang, data.base.term)
elseif data.suffix.term then
prefix_sort_base = strip_diacritics_no_links(data.suffix.lang, data.suffix.term)
end
-- Insert the categories and parts.
local categories = {}
table.insert(parts_formatted, export.link_term(data.prefix, data))
insert_affix_category(categories, data.pos, "prefix", data.prefix, data.sort_key, prefix_sort_base)
if data.base then
table.insert(parts_formatted, export.link_term(data.base, data))
end
table.insert(parts_formatted, export.link_term(data.suffix, data))
-- FIXME, should we be specifying a sort base here?
insert_affix_category(categories, data.pos, "suffix", data.suffix)
return export.join_formatted_parts { data = data, parts_formatted = parts_formatted, categories = categories }
end
--[==[
Implementation of {{tl|infix}}.
'''WARNING''': This destructively modifies both `data` and `.base` and `.infix`.
]==]
function export.show_infix(data)
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
canonicalize_part(data.base, data.lang, data.sc)
-- Hyphenate the affixes and apply any affix mappings.
make_part_into_affix(data.infix, data.lang, data.sc, "infix")
track_wrong_affix_type("infix", data.base, nil)
track_wrong_affix_type("infix", data.infix, "infix")
-- Make links out of all the parts.
local parts_formatted = {}
local categories = {}
table.insert(parts_formatted, export.link_term(data.base, data))
table.insert(parts_formatted, export.link_term(data.infix, data))
-- Insert the categories.
-- FIXME, should we be specifying a sort base here?
insert_affix_category(categories, data.pos, "infix", data.infix)
return export.join_formatted_parts { data = data, parts_formatted = parts_formatted, categories = categories }
end
--[==[
Implementation of {{tl|prefix}}.
'''WARNING''': This destructively modifies both `data` and the structures within `.prefixes`, as well as `.base`.
]==]
function export.show_prefix(data)
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
canonicalize_part(data.base, data.lang, data.sc)
-- Hyphenate the affixes and apply any affix mappings.
for i, prefix in ipairs(data.prefixes) do
make_part_into_affix(prefix, data.lang, data.sc, "prefix")
end
for i, prefix in ipairs(data.prefixes) do
track_wrong_affix_type("prefix", prefix, "prefix")
end
track_wrong_affix_type("prefix", data.base, nil)
-- Make links out of all the parts.
local parts_formatted = {}
local first_sort_base = nil
local categories = {}
if data.prefixes[2] then
first_sort_base = ine(data.prefixes[2].term) or ine(data.prefixes[2].alt)
if first_sort_base then
first_sort_base = strip_diacritics_no_links(data.prefixes[2].lang, first_sort_base)
end
elseif data.base then
first_sort_base = ine(data.base.term) or ine(data.base.alt)
if first_sort_base then
first_sort_base = strip_diacritics_no_links(data.base.lang, first_sort_base)
end
end
for i, prefix in ipairs(data.prefixes) do
table.insert(parts_formatted, export.link_term(prefix, data))
insert_affix_category(categories, data.pos, "prefix", prefix, data.sort_key, i == 1 and first_sort_base or nil)
end
if data.base then
table.insert(parts_formatted, export.link_term(data.base, data))
else
table.insert(parts_formatted, "")
end
return export.join_formatted_parts { data = data, parts_formatted = parts_formatted, categories = categories }
end
--[==[
Implementation of {{tl|suffix}}.
'''WARNING''': This destructively modifies both `data` and the structures within `.suffixes`, as well as `.base`.
]==]
function export.show_suffix(data)
local categories = {}
data.pos = data.pos or default_pos
data.pos = pluralize_pos(data.pos)
canonicalize_part(data.base, data.lang, data.sc)
-- Hyphenate the affixes and apply any affix mappings.
for i, suffix in ipairs(data.suffixes) do
make_part_into_affix(suffix, data.lang, data.sc, "suffix")
end
track_wrong_affix_type("suffix", data.base, nil)
for i, suffix in ipairs(data.suffixes) do
track_wrong_affix_type("suffix", suffix, "suffix")
end
-- Make links out of all the parts.
local parts_formatted = {}
if data.base then
table.insert(parts_formatted, export.link_term(data.base, data))
else
table.insert(parts_formatted, "")
end
for i, suffix in ipairs(data.suffixes) do
table.insert(parts_formatted, export.link_term(suffix, data))
end
-- Insert the categories.
for i, suffix in ipairs(data.suffixes) do
-- FIXME, should we be specifying a sort base here?
insert_affix_category(categories, data.pos, "suffix", suffix)
if suffix.pos and rfind(suffix.pos, "patronym") then
table.insert(categories, "patronymics")
end
end
return export.join_formatted_parts { data = data, parts_formatted = parts_formatted, categories = categories }
end
return export
4jetzdivz19atozyv52j2nrae70fe1o
Module:en-headword
828
8056
54894
54866
2026-09-28T21:04:49Z
Deadend0914
7211
54894
Scribunto
text/plain
local export = {}
local pos_functions = {}
--[==[
Author from 2020 on: mostly Benwing2, with significant contributions from Theknightwho. Based on a prior version by Rua
(by now mostly rewritten), with contributions from Erutuon and others (see history for full attribution).
]==]
local force_cat = false -- for testing; if true, categories appear in non-mainspace pages
local require = require
local require_when_needed = require("Module:require when needed")
local en_utilities_module = "Module:en-utilities"
local headword_utilities_module = "Module:headword utilities"
local headword_module = "Module:headword"
local inflection_utilities_module = "Module:inflection utilities"
local parse_utilities_module = "Module:parse utilities"
local JSON_module = "Module:JSON"
local labels_module = "Module:labels"
local links_module = "Module:links"
local parameters_module = "Module:parameters"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local yesno_module = "Module:yesno"
local iut = require_when_needed(inflection_utilities_module)
local put = require_when_needed(parse_utilities_module)
local m_headword_utilities = require_when_needed(headword_utilities_module)
local add_links_to_multiword_term = require_when_needed(headword_utilities_module, "add_links_to_multiword_term")
local add_suffix = require_when_needed(en_utilities_module, "add_suffix")
local apply_link_modifiers = require_when_needed(headword_utilities_module, "apply_link_modifiers")
local concat = table.concat
local deepEquals = require_when_needed(table_module, "deepEquals")
local dump = mw.dumpObject
local format_categories = require_when_needed(utilities_module, "format_categories")
local full_headword = require_when_needed(headword_module, "full_headword")
local get_label_info = require_when_needed(labels_module, "get_label_info")
local get_link_page = require_when_needed(links_module, "get_link_page")
local glossary_link = require_when_needed(headword_utilities_module, "glossary_link")
local insert = table.insert
local insertIfNot = require_when_needed(table_module, "insertIfNot")
local ipairs = ipairs
local is_regular_plural = require_when_needed(en_utilities_module, "is_regular_plural")
local list_to_set = require_when_needed(table_module, "listToSet")
local pairs = pairs
local process_params = require_when_needed(parameters_module, "process")
local remove = table.remove
local remove_links = require_when_needed(links_module, "remove_links")
local replacement_escape = require_when_needed(string_utilities_module, "replacement_escape")
local shallowCopy = require_when_needed(table_module, "shallowCopy")
local singularize = require_when_needed(en_utilities_module, "singularize")
local split = require_when_needed(string_utilities_module, "split")
local toJSON = require_when_needed(JSON_module, "toJSON")
local toNFD = mw.ustring.toNFD
local type = type
local ulen = require_when_needed(string_utilities_module, "len")
local ulower = require_when_needed(string_utilities_module, "lower")
local umatch = require_when_needed(string_utilities_module, "match")
local u = require_when_needed(string_utilities_module, "char")
local ugsub = require_when_needed(string_utilities_module, "gsub")
local lang = require("Module:languages").getByCode("en")
local langname = lang:getCanonicalName()
local list_param = {list = true, disallow_holes = true}
local list_allow_holes = {list = true, allow_holes = true}
local boolean_param = {type = "boolean"}
local function ine(val)
if val == "" then return nil else return val end
end
local function track(page)
require("Module:debug/track")("en-headword/" .. page)
return true
end
------------------------------------------- UTILITY FUNCTIONS ------------------------------------------
-- Parse and return an inflection not requiring additional processing. The raw arguments come from `args[field]`, which
-- is parsed for inline modifiers.
local function parse_inflection(args, field, is_head)
local argfield = field
if type(argfield) == "table" then
argfield = argfield[1]
end
return m_headword_utilities.parse_term_list_with_modifiers {
paramname = field,
forms = args[argfield],
splitchar = ",",
is_head = is_head,
}
end
-- Insert the parsed inflections in `terms` (as parsed by `parse_inflection`) into `data.inflections`, with label
-- `label` and optional accelerator spec `accel`.
local function insert_inflection(data, terms, label, accel, no_label)
for _, termobj in ipairs(terms) do
m_headword_utilities.remove_termobj_field_modifiers(termobj)
end
m_headword_utilities.insert_inflection {
headdata = data,
terms = terms,
label = label,
no_label = no_label,
accel = accel and {form = accel} or nil,
}
end
-- Insert a fixed label `label` into the inflections for `data`. If `originating_term` is supplied, copy the decorations
-- from it into the fixed label.
local function insert_fixed_inflection(data, label, originating_term)
m_headword_utilities.insert_fixed_inflection {
headdata = data,
originating_term = originating_term,
label = label,
}
end
-- Parse and insert an inflection not requiring additional processing into `data.inflections`. The raw arguments come
-- from `args[field]`, which is parsed for inline modifiers. `label` is the label that the inflections are given;
-- `accel` is the accelerator form, or nil.
local function parse_and_insert_inflection(data, args, field, label, accel)
m_headword_utilities.parse_and_insert_inflection {
headdata = data,
forms = args[field],
paramname = field,
splitchar = ",",
label = label,
accel = accel and {form = accel} or nil,
}
end
-- These functions are used directly in the <> format as well as in the utility functions #2 below.
local function compute_double_last_cons_stem(term)
local last_cons = term:match("([bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])$")
if not last_cons then
error("Verb stem '" .. term .. "' must end in a consonant to use ++")
end
return term .. last_cons
end
local function compute_plusplus_s_form(term, default_s_form)
if term:find("[szx]$") then
-- regas -> regasses, derez -> derezzes
return compute_double_last_cons_stem(term) .. "es"
else
return default_s_form
end
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local iparams = {
[1] = true,
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local parargs = frame:getParent().args
local poscat = iargs[1]
local pos_in_1 = not poscat
if pos_in_1 then
poscat = ine(parargs[1]) or
mw.title.getCurrentTitle().fullText == "Template:en-head" and "interjection" or
error("Part of speech must be specified in 1=")
poscat = require(headword_module).canonicalize_pos(poscat)
end
local indexing_poscat = pos_in_1 and "head" or poscat
local params = {
["head"] = list_param,
["id"] = true,
["json"] = boolean_param,
["sort"] = true,
["splithyph"] = boolean_param,
["nosplithyph"] = boolean_param,
["hyphspace"] = boolean_param,
["nolink"] = boolean_param,
["nolinkhead"] = {type = "boolean_param", alias_of = "nolink"},
["suffix"] = boolean_param,
["nosuffix"] = boolean_param,
["nomultiwordcat"] = boolean_param,
["abbr"] = list_param,
["the"] = true,
["def"] = {alias_of = "the"},
["pagename"] = true, -- for testing
}
if pos_in_1 then
params[1] = {required = true} -- required but ignored as already processed above
end
local pos_data = pos_functions[indexing_poscat]
local pos_func
if pos_data then
local pos_params = pos_data.params
if pos_params then
for key, val in pairs(pos_params) do
params[key] = val
end
end
pos_func = pos_data.func
end
local args = process_params(parargs, params)
-- Account for unsupported titles, e.g. 'C|N>K' instead of 'Unsupported titles/C through N to K'.
local pagename = args.pagename or mw.loadData("Module:headword/data").pagename
local user_specified_heads = parse_inflection(args, "head", "is_head")
local heads = user_specified_heads
local autohead
if args.nolink or not pagename:find("[ '%-]") then
autohead = pagename
else
local en_no_split_apostrophe_words = list_to_set {
"one's",
"someone's",
"he's",
"she's",
"it's",
}
local en_include_hyphen_prefixes = list_to_set {
-- We don't include things that are also words even though they are often (perhaps mostly) prefixes, e.g.
-- "be", "counter", "cross", "extra", "half", "mid", "over", "pan", "under".
"acro",
"acousto",
"Afro",
"agro",
"anarcho",
"angio",
"Anglo",
"ante",
"anti",
"arch",
"auto",
"bi",
"bio",
"cis",
"co",
"cryo",
"crypto",
"de",
"demi",
"eco",
"electro",
"Euro",
"ex",
"Greco",
"hemi",
"hydro",
"hyper",
"hypo",
"infra",
"Indo",
"inter",
"intra",
"Judeo",
"macro",
"meta",
"micro",
"mini",
"multi",
"neo",
"neuro",
"non",
"para",
"peri",
"post",
"pre",
"pro",
"proto",
"pseudo",
"re",
"semi",
"sub",
"super",
"trans",
"un",
"vice",
}
local function is_english(term)
local title = mw.title.new(term)
if title and title.exists then
local content = title:getContent()
if content and content:find("==English==\n") then
return true
end
end
return false
end
local function en_split_hyphen_when_space(word)
if not word:find("-", nil, true) then
return nil
end
if args.hyphspace then
return "[[" .. word:gsub("%-+", " ") .. "|" .. word .. "]]"
end
if args.nosplithyph then
return "[[" .. word .. "]]"
end
if not args.splithyph then
local space_word = word:gsub("%-+", " ")
if is_english(space_word) then
return "[[" .. space_word .. "|" .. word .. "]]"
end
if is_english(word) then
return "[[" .. word .. "]]"
end
end
return nil
end
local function en_split_apostrophe(word)
local base = word:match("^(.*)'s$")
if base then
return "[[" .. base .. "]][[-'s|'s]]"
end
-- Only treat final apostrophe as possessive if preceded by something that looks like a plural ending in /z/.
-- In particular we don't want to do it for words like [[truckin']].
base = word:match("^(.*[sxz])'$")
if base then
if base:find("s$") then
local sg = singularize(base)
if is_english(sg) then
return "[[" .. sg .. "|" .. base .. "]][[-'|']]"
end
end
return "[[" .. base .. "]][[-'|']]"
end
return "[[" .. word .. "]]"
end
autohead = add_links_to_multiword_term(pagename, {
split_hyphen_when_space = en_split_hyphen_when_space,
split_apostrophe = en_split_apostrophe,
no_split_apostrophe_words = en_no_split_apostrophe_words,
include_hyphen_prefixes = en_include_hyphen_prefixes,
})
end
if not heads[1] then
heads = {{term = autohead}}
else
for _, headobj in ipairs(heads) do
local head = headobj.term
if head:find("^~") then
head = apply_link_modifiers(autohead, head:sub(2), lang)
headobj.term = head
elseif head:find("^[!?]$") then
-- If explicit head= just consists of ! or ?, add it to the end of the default head.
headobj.term = autohead .. head
end
if head == autohead then
track("redundant-head")
end
end
end
-- handle the=/def=
if args.the == "~" then
local newheads = {}
for _, headobj in ipairs(heads) do
local barehead = shallowCopy(headobj)
insert(newheads, barehead)
headobj.term = "the " .. headobj.term
insert(newheads, headobj)
end
heads = newheads
elseif args.the then
local the = require(yesno_module)(args.the)
if the then
for _, headobj in ipairs(heads) do
headobj.term = "the " .. headobj.term
end
end
end
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = heads,
user_specified_heads = user_specified_heads,
-- We use our own splitting algorithm so the redundant head cat will be inaccurate.
no_redundant_head_cat = true,
inflections = {},
nomultiwordcat = args.nomultiwordcat,
sort_key = args.sort,
pagename = pagename,
id = args.id,
force_cat_output = force_cat,
}
local function inscat(cat)
insert(data.categories, langname .. " " .. cat)
end
local is_suffix = false
if args.suffix or not args.nosuffix and pagename:find("^%-") and not pagename:find("^%-%-") and poscat ~= "suffix forms" then
is_suffix = true
data.pos_category = "suffixes"
local singular_poscat = singularize(poscat)
inscat(singular_poscat .. "-maciende geendunga")
insert(data.inflections, {label = singular_poscat .. "-maciende geendung"})
end
if pos_func then
pos_func(args, data, is_suffix)
end
local extra_categories = {}
if pagename:find("[Qq]") then
-- Check for q not followed by u. We want to exclude things like [[13q deletion syndrome]] and [[BFOQ]] that
-- don't have a lowercase letter on either side, as well as things like [[& seq.]] and [[acq.]] that are
-- abbreviations for words containing a following u.
--
-- Approximate range of combining diacritics; we want to remove them so the checks below for
-- a lowercase letter next to the q aren't tripped up by diacritics on the letter.
local u300 = u(0x0300)
local u36F = u(0x036F)
local pagename_no_diacritics = ugsub(toNFD(pagename), "[" .. u300 .. "-" .. u36F .. "]", "")
if pagename_no_diacritics:find("[Qq][a-tv-z]") or pagename_no_diacritics:find("[a-z]q[^u.]") or
pagename_no_diacritics:find("[a-z]q$") then
inscat("words containing Q not followed by U")
end
end
-- toNFD performs decomposition, so letters that decompose to an ASCII
-- vowel and a diacritic, such as é, are counted as vowels and do not do not
-- need to be included in the pattern.
if not umatch(ulower(toNFD(pagename)), "[aeiouyæœøəªºαεηιουω]") then
inscat("words spelled without vowels")
end
if pagename:find("yre$") then
inscat('word endiende in "-yre"')
end
if not pagename:find(" ") and ulen(pagename) >= 25 then
insert(extra_categories, "Lange " .. langname .. " word")
end
if pagename:find("^[^aeiou ]*a[^aeiou ]*e[^aeiou ]*i[^aeiou ]*o[^aeiou ]*u[^aeiou ]*$") then
inscat("words that use all vowels in alphabetical order")
end
parse_and_insert_inflection(data, args, "abbr", "abbreviation")
if args.json then
return toJSON(data)
end
return full_headword(data)
.. (extra_categories[1]
and format_categories(extra_categories, lang, args.sort)
or "")
end
local function make_default_witmetendlic(word)
if word == "good" or word == "well" then
return {"better"}
elseif word == "bad" or word == "badly" then
return {"worse"}
elseif word == "far" then
return {"further", "farther"}
else
return {add_suffix(word, "r")}
end
end
local function make_default_superlative(word)
if word == "good" or word == "well" then
return {"best"}
elseif word == "bad" or word == "badly" then
return {"worst"}
elseif word == "far" then
return {"furthest", "farthest"}
else
return {add_suffix(word, "st.superlative")}
end
end
-- This function does the common work between adjectives and adverbs.
local function process_witmetendlic_args(data, args, plpos)
local pagename = data.pagename
local comps = parse_inflection(args, 1)
local sups = parse_inflection(args, "sup")
local outcomps, outsups
if args.componly then
if comps[1] then
error("Ne cann specify witmetendlic word of witmetendlic-only " .. plpos)
end
insert(data.inflections, {label = glossary_link("witmetendlic") .. " form only"})
insert(data.categories, langname .. " witmetendlic-only " .. plpos)
-- Set to empty list so we don't get any comparatives output, but process superlatives if specified.
outcomps = {}
if not sups[1] then
-- Set to empty list so we don't get any superlatives output unless explicitly given.
outsups = {}
end
elseif args.suponly then
if comps[1] or sups[1] then
error("Can't specify witmetendlice or oferstigendlice word of or superlative-only " .. plpos)
end
insert(data.inflections, {label = glossary_link("oferstigendlic") .. " form only"})
insert(data.categories, langname .. " oferstigendlic-only " .. plpos)
return
end
-- If the first parameter is ?, then don't show anything, just return.
if comps[1] and comps[1].term == "?" then
if comps[2] then
error("Ne cann specify additional witmetendlice word along with '?'")
end
if sups[1] then
error("Ne cann specify oferstigendlice word along with '?' for the witmetendlic")
end
return
end
if comps[1] and comps[1].term == "-" then
local hyphencomp = remove(comps, 1) -- Remove the "-" but retain for decorations.
-- Not (generally) comparable; may occasionally have a comparative
if comps[1] then
insert_fixed_inflection(data, "naht generally <<witmetendlic>>", hyphencomp)
elseif not sups[1] then
insert_fixed_inflection(data, "naht <<witmetendlic>>", hyphencomp)
insert(data.categories, langname .. " unwitmetendlic " .. plpos)
return
else
-- No comparative, but a superlative. insert_inflection() will correctly generate 'no comparative' if we
-- pass in "-" as the value.
outcomps = {hyphencomp}
end
elseif not comps[1] then
comps = {{term = "more"}}
end
if not outcomps then -- not if we set `outcomps` to "-" above or processed a comparative-only term
outcomps = {}
-- Go over each parameter given and create a comparative and superlative form.
for _, compobj in ipairs(comps) do
local comp = compobj.term
if comp == "-" then
error("Witmetendlic of '-' only allowed as first witmetendlic")
end
if comp == "+" then
comp = "+more"
elseif comp == "more" and pagename ~= "many" and pagename ~= "much" then
comp = "+more"
elseif comp == "further" and pagename ~= "far" then
comp = "+further"
elseif comp == "better" and pagename ~= "good" and pagename ~= "well" then
comp = "+better"
elseif comp:find("~") then
comp = comp:gsub("~", replacement_escape(pagename))
end
compobj.origterm = comp
if comp == "+more" then
comp = "more [[" .. pagename .. "]]"
elseif comp == "+further" then
comp = {"further [[" .. pagename .. "]]", "farther [[" .. pagename .. "]]"}
elseif comp == "+better" then
comp = "better [[" .. pagename .. "]]"
elseif comp == "er" then
-- Add -er.
comp = add_suffix(pagename, "r")
elseif comp == "ier" then
if pagename:sub(-1) ~= "y" then
error("Can't specify 'ier' witmetendlic unless the term ends with 'y': " .. pagename)
end
comp = pagename:gsub("e?y$", "ier")
elseif comp:find("^%+") then
local special = m_headword_utilities.get_special_indicator(comp, "noerror")
if special then
comp = m_headword_utilities.handle_multiword(pagename, special, make_default_witmetendlic)
end
end
if type(comp) == "table" and not comp[2] then
comp = comp[1]
end
if type(comp) == "table" then
for i = 1, #comp - 1 do
local outobj = shallowCopy(compobj)
outobj.term = comp[i]
insert(outcomps, outobj)
end
compobj.term = comp[#comp]
insert(outcomps, compobj)
else
compobj.term = comp
insert(outcomps, compobj)
end
end
end
if sups[1] and sups[1].term == "-" then
if sups[2] then
error("Can't specify '-' as superlative followed by further values")
end
-- No superlative. insert_inflection() will correctly generate 'no superlative' if we pass in "-" as the value.
outsups = sups
else
if not sups[1] then
sups = {{term = "+"}}
end
end
-- `outsups` will be set if we set `outsups` to "-" above or processed a comparative-only term without superlatives.
if not outsups then
outsups = {}
local function process_sup(sup, special, supobj, compobj)
if special then
sup = m_headword_utilities.handle_multiword(pagename, special, make_default_superlative)
elseif sup == "-" or sup == "+" then
error(("Internal error: Oferstigendlic value of '%s' should have been handled earlier"):format(sup))
elseif sup == "+most" then
sup = "most [[" .. pagename .. "]]"
elseif sup == "+furthest" then
sup = {"furthest [[" .. pagename .. "]]", "farthest [[" .. pagename .. "]]"}
elseif sup == "+best" then
sup = "best [[" .. pagename .. "]]"
elseif sup == "est" then
-- Add -est.
sup = add_suffix(pagename, "st.oferstigendlic")
elseif sup == "iest" then
if pagename:sub(-1) ~= "y" then
error("Can't specify 'iest' oferstigendlic unless the term ends with 'y': " .. pagename)
end
sup = pagename:gsub("e?y$", "iest")
end
if type(sup) == "table" and not sup[2] then
sup = sup[1]
end
if compobj then
supobj = shallowCopy(supobj)
supobj = m_headword_utilities.combine_termobj_decorations(supobj, compobj)
end
if type(sup) == "table" then
for i = 1, #sup - 1 do
local outobj = shallowCopy(supobj)
outobj.term = sup[i]
insert(outsups, outobj)
end
supobj.term = sup[#sup]
insert(outsups, supobj)
else
supobj.term = sup
insert(outsups, supobj)
end
end
for _, supobj in ipairs(sups) do
local sup = supobj.term
if sup == "-" then
error("Oferstigendlic of '-' only allowed as first oferstigendlic word")
end
if sup == "+" then
if not comps[1] then
error("Oferstigendlic of '+' can't be specified when there are no witmetendlice")
end
for _, compobj in ipairs(comps) do
local comp = compobj.origterm
local special
if comp == "+more" then
sup = "+most"
elseif comp == "+further" then
sup = "+furthest"
elseif comp == "+better" then
sup = "+best"
elseif comp == "er" then
sup = "est"
elseif comp == "ier" then
sup = "iest"
else
if comp:find("^%+") then
special = m_headword_utilities.get_special_indicator(comp, "noerror")
end
if not special then
-- If the full comparative was given, then derive the superlative by replacing -er with
-- -est.
if comp:sub(-2) == "er" then
sup = comp:sub(1, -3) .. "est"
else
error(("The oferstigendlic word cannot be derived automatically from witmetendlic '%s' because it doesn't end in -er"):format(comp))
end
end
end
process_sup(sup, special, supobj, compobj)
end
else
local special = m_headword_utilities.get_special_indicator(sup, "noerror")
-- Do some work here rather than in process_sup() so we don't end up double-processing a term with a '~'
-- in it or a term that happens to be 'most' or similar after substitution of ~ in the comparative.
if not special then
if sup == "most" and pagename ~= "many" and pagename ~= "much" then
sup = "+most"
elseif sup == "furthest" and pagename ~= "far" then
sup = "+furthest"
elseif sup == "best" and pagename ~= "good" and pagename ~= "well" then
sup = "+best"
elseif sup:find("~") then
sup = sup:gsub("~", replacement_escape(pagename))
end
end
process_sup(sup, special, supobj)
end
end
end
insert_inflection(data, outcomps, "<<witmetendlic>>", "witmetendlic")
insert_inflection(data, outsups, "<<oferstigendlic>>", "oferstigendlic")
end
pos_functions["adjectives"] = {
params = {
[1] = list_param,
["comp_qual"] = {list = "comp\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the witmetendlic value",
},
["sup"] = list_param,
["sup_qual"] = {list = "sup\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the oferstigendlic value",
},
["componly"] = boolean_param,
["suponly"] = boolean_param,
},
func = function(args, data)
-- Process the comparatives and superlatives.
process_witmetendlic_args(data, args, "adjectives")
end,
}
pos_functions["adverbs"] = {
params = {
[1] = list_param,
["comp_qual"] = {list = "comp\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the witmetendlic value",
},
["sup"] = list_param,
["sup_qual"] = {list = "sup\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the oferstigendlic value",
},
["componly"] = boolean_param,
["suponly"] = boolean_param,
},
func = function(args, data)
-- Process the comparatives and superlatives.
process_witmetendlic_args(data, args, "adverbs")
end,
}
local function escape(str)
return (str:gsub("\\([:#])", "\\\\%1")
:gsub("[:#]", "\\%0"))
end
local function canonicalize_plural(pl, pagename, pos)
if pl == "+" then
return escape(add_suffix(pagename, "s.plural", pos))
elseif pl == "++" then
return escape(compute_plusplus_s_form(pagename, add_suffix(pagename, "s.plural", pos)))
elseif pl == "*" then
return escape(pagename)
elseif pl == "ies" then
if pagename:sub(-1) == "y" then
return escape(pagename:gsub("e?y$", pl))
end
error("Ne cann nemnet 'ies' manigfeald on laes se word endat wit 'y'.")
elseif pl == "s" or pl == "es" or pl == "'s" then
return escape(pagename .. pl)
end
end
local function do_naman(args, data, pos)
local pagename = data.pagename
pos = pos or "nama"
local plurals = parse_inflection(args, 1)
local function insert_plurale_tantum_inflections(is_plural_only, originating_label)
if args.sg[1] then
insert_fixed_inflection(data, "gewunelice manigfeald", originating_label)
parse_and_insert_inflection(data, args, "anf", "anfeald")
elseif is_plural_only then
insert_fixed_inflection(data, "manigfeald anlic", originating_label)
end
if args.attr[1] then
parse_and_insert_inflection(data, args, "attr", "attributive")
end
end
local function first_pl_term()
return plurals[1] and plurals[1].term or nil
end
if first_pl_term() == "p" then
-- plurale tantum
if plurals[2] then
error("With plurale tantum noun, can't specify more than one manigfeald")
end
data.genders = {"p"} -- this should auto-insert the correct 'pluralia tantum' category
insert_plurale_tantum_inflections("manigfealdic anlic", plurals[1])
return
end
local function inscat(cat)
insert(data.categories, langname .. " " .. cat)
end
local need_default_plural = pos == "nama"
if first_pl_term() == "sp" then
-- construed as singular or plural
sp = remove(plurals, 1) -- Remove the "sp" but retain it for its decorations.
inscat("naman macat eallswa anfealdic otte manigfealdic")
data.genders = {"s", "p"} -- this should auto-insert the correct 'pluralia tantum' category
insert_plurale_tantum_inflections(nil, sp)
need_default_plural = false
elseif first_pl_term() == "-" then
-- Uncountable noun; may occasionally have a plural
local hyphpl = remove(plurals, 1) -- Remove the "-" but retain for decorations.
inscat("untellende naman")
-- If plural forms were given explicitly, then show "usually"
if plurals[1] then
insert_fixed_inflection(data, "gewunelice <<untellende>>", hyphpl)
else
insert_fixed_inflection(data, "<<untellende>>", hyphpl)
end
need_default_plural = false
elseif first_pl_term() == "#" then
-- Usually tellende (e.g., "grilled cheese")
local hashpl = remove(plurals, 1) -- Remove the "#" but retain for decorations.
insert_fixed_inflection(data, "gewunelice <<tellende>>", hashpl)
inscat("untellende naman")
inscat("tellende naman")
-- If no plural was given, add a default one now
if not plurals[1] then
plurals[1] = {term = escape(add_suffix(pagename, "s.plural", pos))}
end
elseif first_pl_term() == "~" then
-- Mixed countable/uncountable noun, always has a plural
local tildepl = remove(plurals, 1) -- Remove the "~" but retain for decorations.
insert_fixed_inflection(data, "<<tellende>> and <<untellende>>", tildepl)
inscat("untellende naman")
inscat("tellende naman")
-- If no plural was given, add a default one now
if not plurals[1] then
plurals[1] = {term = escape(add_suffix(pagename, "s.plural", pos))}
end
end
-- Plural is unknown
if first_pl_term() == "?" then
local questionpl = remove(plurals, 1) -- Remove the "?" but retain for decorations.
-- insert_fixed_inflection(data, "manigfeald unknown or uncertain", questionpl)
inscat("naman with unknown or uncertain manigfealde")
if plurals[1] then
error("Can't specify explicit manigfealde along with '?' for unknown/uncertain manigfeald")
end
return
end
-- Plural is not attested
if first_pl_term() == "!" then
local exclampl = remove(plurals, 1) -- Remove the "!" but retain for decorations.
insert_fixed_inflection(data, "manigfeald ne weahte", exclampl)
inscat("naman with ne weahte manigfealde word")
if plurals[1] then
error("Can't specify explicit manigfealde along with '!' for ne weahte manigfeald")
end
return
end
-- If no plural was given, maybe add a default one, otherwise (when "-" was given or proper noun) return.
if not plurals[1] then
if not need_default_plural then
inscat("untellende naman")
return
end
plurals[1] = {term = escape(add_suffix(pagename, "s.plural", pos))}
end
-- There are plural forms to show, so show them.
inscat("tellende naman")
local irregular, indeclinable
for i, pl in ipairs(plurals) do
local canon_pl = canonicalize_plural(pl.term, pagename, pos)
if canon_pl then
pl.term = canon_pl
end
local pl_term = get_link_page(pl.term, lang)
if not (pagename:find(" ") or is_regular_plural(pl_term, pagename)) then
irregular = true
if pl_term == pagename then
indeclinable = true
end
end
end
if irregular then
inscat("naman with ungewunelic manigfealde")
end
if indeclinable then
inscat("undeclinigendlic naman")
end
insert_inflection(data, plurals, "manigfeald", "mnf")
end
-- Return the parameters to be used for nouns and proper nouns. Currently the same.
local nama_params = {
[1] = list_param,
["pl\1qual"] = {list = true, allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the manigfeald",
},
-- The following four only used for pluralia tantum (1=p)
["sg"] = list_param,
["attr"] = list_param,
}
pos_functions["naman"] = {
params = nama_params,
func = do_naman,
}
pos_functions["āgennaman"] = {
params = nama_params,
func = function(args, data)
return do_naman(args, data, "āgennama")
end,
}
local function base_default_verb_forms(verb)
return escape(add_suffix(verb, "s.verb")), escape(add_suffix(verb, "ing")), escape(add_suffix(verb, "d"))
end
local function default_verb_forms(verb)
local full_s_form, full_ing_form, full_ed_form = base_default_verb_forms(verb)
if verb:find(" ") then
local first, rest = verb:match("^(.-)( .*)$")
local first_s_form, first_ing_form, first_ed_form = base_default_verb_forms(first)
return full_s_form, full_ing_form, full_ed_form, first_s_form .. rest, first_ing_form .. rest,
first_ed_form .. rest, first, rest
else
return full_s_form, full_ing_form, full_ed_form, nil, nil, nil, nil, nil
end
end
local function compute_double_last_cons_stem_of_split_verb(verb, ending)
local first, rest = verb:match("^(.-)( .*)$")
if not first then
error("Verb '" .. verb .. "' must have a space in it to use **")
end
local last_cons = first:match("([bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])$")
if not last_cons then
error("First word '" .. first .. "' must end in a consonant to use **")
end
return first .. last_cons .. ending .. rest
end
local function check_non_nil_star_form(form, pagename)
if form == nil then
error("Verb '" .. pagename .. "' must have a space in it to use *, **, *l, *! or *'")
end
return form
end
local function sub_tilde(form, pagename)
if not form then
return nil
end
if form:find("~") then
form = form:gsub("~", replacement_escape(pagename))
end
return form
end
local deprecated_qual_replaced_by_inline_modifier = {
list = true, allow_holes = true, replaced_by = false,
instead = "use an inline modifier <q:...> or <l:...> on the value"
}
pos_functions["verbs"] = {
params = {
[1] = {list = "pres_3sg", disallow_holes = true},
["pres_3sg\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
[2] = {list = "pres_ptc", disallow_holes = true},
["pres_ptc\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
[3] = {list = "past", disallow_holes = true},
["past\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
[4] = {list = "past_ptc", allow_holes = true},
["past_ptc\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
["noautolinkverb"] = boolean_param,
["angle_bracket"] = boolean_param,
},
func = function(args, data)
-- Get parameters
local par1s
local par2s = parse_inflection(args, {2, "pres_ptc"})
local par3s = parse_inflection(args, {3, "past"})
local par4s = parse_inflection(args, {4, "past_ptc"})
local pres_3sgs, pres_ptcs, pasts, past_ptcs
local pagename = data.pagename
------------------------------------------- UTILITY FUNCTIONS #2 ------------------------------------------
-- These functions are used in both in the separate-parameter format and in the override params such as past_ptc2=.
local full_default_s, full_default_ing, full_default_ed, split_default_s, split_default_ing, split_default_ed
local lemma
local function set_lemma_and_default_forms(the_lemma)
lemma = the_lemma
full_default_s, full_default_ing, full_default_ed, split_default_s, split_default_ing, split_default_ed,
lemma_first, lemma_rest = default_verb_forms(the_lemma)
end
local function canonicalize_s_form(form)
if form == "+" then
error("Internal error: Should not see '+' here")
elseif form == "^" then
return full_default_s
elseif form == "*" then
return check_non_nil_star_form(split_default_s, lemma)
elseif form == "++" then
return compute_plusplus_s_form(lemma, full_default_s)
elseif form == "**" then
if lemma:find("^[^ ]*[szx] ") then
return compute_double_last_cons_stem_of_split_verb(lemma, "es")
else
return check_non_nil_star_form(split_default_s, lemma)
end
elseif form == "+!" then
return lemma .. "s"
elseif form == "*!" then
return check_non_nil_star_form(lemma_first) .. "s" .. lemma_rest
elseif form == "+'" then
return lemma .. "'s"
elseif form == "*'" then
return check_non_nil_star_form(lemma_first) .. "'s" .. lemma_rest
elseif form == "+l" then
if lemma:find("[szx]$") then
return {{term = full_default_s, l = {"US"}},
{term = compute_plusplus_s_form(lemma, full_default_s), l = {"UK"}}}
else
return compute_plusplus_s_form(lemma, full_default_s)
end
elseif form == "*l" then
if lemma:find("^[^ ]*[szx] ") then
return {{term = check_non_nil_star_form(split_default_s, lemma), l = {"US"}},
{term = compute_double_last_cons_stem_of_split_verb(lemma, "es"), l = {"UK"}}}
else
return check_non_nil_star_form(split_default_s, lemma)
end
else
return sub_tilde(form, lemma)
end
end
local function canonicalize_ing_form(form)
if form == "+" then
error("Internal error: Should not see '+' here")
elseif form == "^" then
return full_default_ing
elseif form == "*" then
return check_non_nil_star_form(split_default_ing, lemma)
elseif form == "++" then
return compute_double_last_cons_stem(lemma) .. "ing"
elseif form == "**" then
return compute_double_last_cons_stem_of_split_verb(lemma, "ing")
elseif form == "+!" then
return lemma .. "ing"
elseif form == "*!" then
return check_non_nil_star_form(lemma_first) .. "ing" .. lemma_rest
elseif form == "+'" then
return lemma .. "'ing"
elseif form == "*'" then
return check_non_nil_star_form(lemma_first) .. "'ing" .. lemma_rest
elseif form == "+l" then
return {{term = full_default_ing, l = {"US"}},
{term = compute_double_last_cons_stem(lemma) .. "ing", l = {"UK"}}}
elseif form == "*l" then
return {{term = check_non_nil_star_form(split_default_ing, lemma), l = {"US"}},
{term = compute_double_last_cons_stem_of_split_verb(lemma, "ing"), l = {"UK"}}}
else
return sub_tilde(form, lemma)
end
end
local function canonicalize_ed_form(form)
if form == "+" then
error("Internal error: Should not see '+' here")
elseif form == "^" then
return full_default_ed
elseif form == "*" then
return check_non_nil_star_form(split_default_ed, lemma)
elseif form == "++" then
return compute_double_last_cons_stem(lemma) .. "ed"
elseif form == "+!" then
return lemma .. "ed"
elseif form == "*!" then
return check_non_nil_star_form(lemma_first) .. "ed" .. lemma_rest
elseif form == "+'" then
return {{term = lemma .. "'d"}, {term = lemma .. "'ed"}}
elseif form == "*'" then
return {{term = check_non_nil_star_form(lemma_first) .. "'d" .. lemma_rest},
{term = check_non_nil_star_form(lemma_first) .. "'ed" .. lemma_rest}}
elseif form == "**" then
return compute_double_last_cons_stem_of_split_verb(lemma, "ed")
elseif form == "+l" then
return {{term = full_default_ed, l = {"US"}},
{term = compute_double_last_cons_stem(lemma) .. "ed", l = {"UK"}}}
elseif form == "*l" then
return {{term = check_non_nil_star_form(split_default_ed, lemma), l = {"US"}},
{term = compute_double_last_cons_stem_of_split_verb(lemma, "ed"), l = {"UK"}}}
else
return sub_tilde(form, lemma)
end
end
-- FIXME: options should be "+", "*", "++", "**", "+n", "*n", "++n" and "**n", but not "n"
local function canonicalize_en_form(form)
if form == "n" then
track("n4")
return add_suffix(lemma, "n")
end
return canonicalize_ed_form(form)
end
--------------------------------- MAIN PARSING/CONJUGATING CODE --------------------------------
local is_angle_bracket = args.angle_bracket
if is_angle_bracket then
if par2s[1] or par3s[1] or par4s[1] then
error("Can't specify explicit values for 2=, 3= or 4= along with the angle-bracket format")
end
elseif is_angle_bracket == nil and not par2s[1] and not par3s[1] and not par4s[1] and not args[1][2] and
args[1][1] and args[1][1]:find("<") then
if put.term_contains_top_level_html(args[1][1]) then
-- Often, term_contains_top_level_html() returns true on the angle-bracket format, which would
-- make the pcall() below succeed but leave the angle brackets as-is. Check for this and only do the
-- pcall() if term_contains_top_level_html() returns false.
is_angle_bracket = true
else
-- If it's ambiguous whether it's an angle-bracket format or separate params with an inline modifier,
-- try to parse as the latter. If an error occurs, treat as the former.
local ok
ok, par1s = pcall(parse_inflection, args, {1, "pres_3sg"})
if not ok then
par1s = nil
is_angle_bracket = true
end
end
end
if is_angle_bracket then
-------------------------- ANGLE-BRACKET FORMAT --------------------------
-- (0) Expand multiword term with angle brackets just on the first word.
local arg11 = args[1][1]
if arg11:find("^<.*>$") and pagename:find(" ") then
local first, rest = pagename:match("^(.-)( .*)$")
arg11 = first .. arg11 .. rest
end
-- (1) Parse the indicator specs inside of angle brackets.
local function parse_indicator_spec(angle_bracket_spec)
local inside = angle_bracket_spec:match("^<(.*)>$")
assert(inside)
local segments = put.parse_balanced_segment_run(inside, "[", "]")
local comma_separated_groups = put.split_alternating_runs(segments, ",")
if #comma_separated_groups > 4 then
error("Too many comma-separated parts in indicator spec, expected at most 4: " ..
angle_bracket_spec)
end
local function fetch_footnotes(separated_group)
local footnotes
for j = 2, #separated_group - 1, 2 do
if separated_group[j + 1] ~= "" then
error("Extraneous text after bracketed footnotes: '" .. concat(separated_group) .. "'")
end
if not footnotes then
footnotes = {}
end
insert(footnotes, separated_group[j])
end
return footnotes
end
local function fetch_specs(comma_separated_group)
if not comma_separated_group then
return {{term = "+"}}
end
local specs = {}
local colon_separated_groups = put.split_alternating_runs(comma_separated_group, ":")
for _, colon_separated_group in ipairs(colon_separated_groups) do
local form = colon_separated_group[1]
if form == "*" or form == "**" or form == "*l" or form == "*!" or form == "*'" then
error("*, **, *l, *! and *' not allowed inside of indicator specs: " .. angle_bracket_spec)
end
if form == "" then
form = "+"
end
local termobj = {
term = form
}
local footnotes = fetch_footnotes(colon_separated_group)
if footnotes then
for _, footnote in ipairs(footnotes) do
m_headword_utilities.add_footnote_to_termobj(termobj, footnote)
end
end
insert(specs, termobj)
end
return specs
end
local s_specs = fetch_specs(comma_separated_groups[1])
local ing_specs = fetch_specs(comma_separated_groups[2])
local ed_specs = fetch_specs(comma_separated_groups[3])
local en_specs = fetch_specs(comma_separated_groups[4])
return {
forms = {},
s_specs = s_specs,
ing_specs = ing_specs,
ed_specs = ed_specs,
en_specs = en_specs,
}
end
local parse_props = {
parse_indicator_spec = parse_indicator_spec,
}
local alternant_multiword_spec = iut.parse_inflected_text(arg11, parse_props)
-- (2) Check for user-specified brackets; remove any links from the lemma, but remember the original
-- form so we can use it below in the 'lemma_linked' form.
-- Check to see if there are brackets in the pre-text or post-text. If so, use the linked lemma (with the
-- verb autolinked unless noautolinkverb is given). Otherwise, use the default headword algorithm.
local function check_bracket(val)
if val:find("%[%[") then
alternant_multiword_spec.saw_bracket = true
end
end
for _, alternant_or_word_spec in ipairs(alternant_multiword_spec.alternant_or_word_specs) do
check_bracket(alternant_or_word_spec.before_text)
if alternant_or_word_spec.alternants then
for _, multiword_spec in ipairs(alternant_or_word_spec.alternants) do
for _, word_spec in ipairs(multiword_spec.word_specs) do
check_bracket(word_spec.before_text)
end
check_bracket(multiword_spec.post_text)
end
end
end
check_bracket(alternant_multiword_spec.post_text)
iut.map_word_specs(alternant_multiword_spec, function(base)
if base.lemma == "" then
base.lemma = pagename
end
base.orig_lemma = base.lemma
base.lemma = remove_links(base.lemma)
if args.noautolinkverb or base.orig_lemma:find("%[%[") then
base.linked_lemma = base.orig_lemma
else
base.linked_lemma = "[[" .. base.orig_lemma .. "]]"
end
end)
-- (3) Conjugate the verbs according to the indicator specs parsed above.
local all_verb_slots = {
lemma = "ungeendigendlic",
lemma_linked = "ungeendigendlic",
s_form = "3|s|pres",
ing_form = "pres|ptcp",
ed_form = "past",
en_form = "past|ptcp",
}
local function conjugate_verb(base)
local function process_specs(slot, specs, canon_func, default_values, default_already_formobj)
local function insert_termobj_into_slot(termobj)
local formobj = m_headword_utilities.convert_termobj_to_formobj(termobj)
-- If the form is -, don't insert any forms, which will result in there being no overall forms
-- (in fact it will be nil). We check for that down below and substitute a single "-" as the
-- form, which in turn gets turned into special labels like "no present participle".
if formobj.form == "-" then
if formobj.footnotes then
error("Unable to preserve footnotes specified on missing form '-': FIXME: " ..
dump(formobj.footnotes))
end
else
iut.insert_form(base.forms, slot, formobj)
end
end
local function canonicalize_and_insert(arg)
local canon_arg = canon_func(arg)
if type(canon_arg) == "string" then
arg.term = canon_arg
insert_termobj_into_slot(arg)
else
for _, canon in ipairs(canon_arg) do
m_headword_utilities.combine_termobj_decorations(canon, arg)
insert_termobj_into_slot(canon)
end
end
end
for _, arg in ipairs(specs) do
if arg.term == "+" then
if default_values then -- will be nil if past tense specified as - and no past ptc given
for _, val in ipairs(default_values) do
val = shallowCopy(val)
if default_already_formobj then
local argformobj = m_headword_utilities.convert_termobj_to_formobj(arg)
val.footnotes = iut.combine_footnotes(val.footnotes, argformobj.footnotes)
iut.insert_form(base.forms, slot, val)
else
m_headword_utilities.combine_termobj_decorations(val, arg)
canonicalize_and_insert(val)
end
end
end
else
canonicalize_and_insert(arg)
end
end
end
set_lemma_and_default_forms(base.lemma)
local all_part_default_specs = {}
local function process_and_canonicalize_s_form(arg)
local form = arg.term
if form == "+" then
error("Internal error: '+' should have been converted to '^' by now")
end
if form == "*" or form == "**" or form == "*l" or form == "*!" or form == "*'" then
error(("Internal error: '%s' should have already thrown an error"):format(form))
end
if form == "^" or form == "++" or form == "+l" or form == "+!" or form == "+'" then
insert(all_part_default_specs, shallowCopy(arg))
end
return canonicalize_s_form(form)
end
process_specs("s_form", base.s_specs, process_and_canonicalize_s_form, {{term = "^"}})
if not all_part_default_specs[1] then
all_part_default_specs[1] = {term = "^"}
end
process_specs("ing_form", base.ing_specs, function(arg) return canonicalize_ing_form(arg.term) end,
all_part_default_specs)
process_specs("ed_form", base.ed_specs, function(arg) return canonicalize_ed_form(arg.term) end,
all_part_default_specs)
process_specs("en_form", base.en_specs, function(arg) return canonicalize_en_form(arg.term) end,
base.forms.ed_form, "default already formobj")
iut.insert_form(base.forms, "lemma", {form = base.lemma})
-- Add linked version of lemma for use in head=. We write this in a general fashion in case
-- there are multiple lemma forms (which isn't possible currently at this level, although it's
-- possible overall using the ((...,...)) notation).
iut.insert_forms(base.forms, "lemma_linked", iut.map_forms(base.forms.lemma, function(form)
if form == base.lemma and base.linked_lemma:find("%[%[") then
return base.linked_lemma
else
return form
end
end))
end
local inflect_props = {
slot_table = all_verb_slots,
inflect_word_spec = conjugate_verb,
}
iut.inflect_multiword_or_alternant_multiword_spec(alternant_multiword_spec, inflect_props)
-- (4) Fetch the forms and put the conjugated lemmas in data.heads if not explicitly given.
local function fetch_termobjs(slot)
local forms = alternant_multiword_spec.forms[slot]
-- See above. This should only occur if the user explicitly used - for a spec.
if not forms or not forms[1] then
return {{term = "-"}}
end
local termobjs = {}
for _, formobj in ipairs(forms) do
insert(termobjs, m_headword_utilities.convert_formobj_to_termobj(formobj))
end
return termobjs
end
pres_3sgs = fetch_termobjs("s_form")
pres_ptcs = fetch_termobjs("ing_form")
pasts = fetch_termobjs("ed_form")
past_ptcs = fetch_termobjs("en_form")
-- Use the "linked" form of the lemma as the head if no head= explicitly given and the user specified
-- brackets in one of the lemmas. Otherwise we use the default headword-linking algorithm.
if not data.user_specified_heads[1] and alternant_multiword_spec.saw_bracket then
data.heads = {}
for _, lemma_obj in ipairs(alternant_multiword_spec.forms.lemma_linked) do
insert(data.heads, m_headword_utilities.convert_formobj_to_termobj(lemma_obj))
end
end
else
-------------------------- SEPARATE-PARAM FORMAT --------------------------
set_lemma_and_default_forms(pagename)
par1s = par1s or parse_inflection(args, {1, "pres_3sg"})
pres_3sgs = {}
pres_ptcs = {}
pasts = {}
past_ptcs = {}
if not par1s[1] then
par1s = {{term = "+"}}
end
if not par2s[1] then
par2s = {{term = "+"}}
end
if not par3s[1] then
par3s = {{term = "+"}}
end
if not par4s[1] then
par4s = {{term = "+"}}
end
local function process_argument(args, dest, canon_func, default_values, default_already_canonicalized)
local function canonicalize_and_insert(arg)
local canon_arg = canon_func(arg)
if type(canon_arg) == "string" then
arg.term = canon_arg
m_headword_utilities.insert_termobj_combining_duplicates(dest, arg)
else
for _, canon in ipairs(canon_arg) do
m_headword_utilities.combine_termobj_decorations(canon, arg)
m_headword_utilities.insert_termobj_combining_duplicates(dest, canon)
end
end
end
for _, arg in ipairs(args) do
if arg.term == "+" then
for _, val in ipairs(default_values) do
val = shallowCopy(val)
m_headword_utilities.combine_termobj_decorations(val, arg)
if default_already_canonicalized then
m_headword_utilities.insert_termobj_combining_duplicates(dest, val)
else
canonicalize_and_insert(val)
end
end
else
canonicalize_and_insert(arg)
end
end
end
local all_part_default_specs = {}
local function process_and_canonicalize_s_form(arg)
local form = arg.term
if form == "+" then
error("Internal error: '+' should have been converted to '^' by now")
end
if form == "^" or form == "++" or form == "+l" or form == "+!" or form == "+'" or
form == "*" or form == "**" or form == "*l" or form == "*!" or form == "*'" then
insert(all_part_default_specs, shallowCopy(arg))
end
return canonicalize_s_form(form)
end
process_argument(par1s, pres_3sgs, process_and_canonicalize_s_form, {{term = "^"}})
if not all_part_default_specs[1] then
all_part_default_specs[1] = {term = "^"}
end
process_argument(par2s, pres_ptcs, function(arg) return canonicalize_ing_form(arg.term) end,
all_part_default_specs)
process_argument(par3s, pasts, function(arg) return canonicalize_ed_form(arg.term) end,
all_part_default_specs)
process_argument(par4s, past_ptcs, function(arg) return canonicalize_en_form(arg.term) end,
pasts, "default already canonicalized")
end
------------------------------------------- INSERT INFLECTIONS ------------------------------------------
insert_inflection(data, pres_3sgs, "third-person singular simple present", "s-verb-form")
insert_inflection(data, pres_ptcs, "present participle", "ing-form")
if deepEquals(pasts, past_ptcs) then
insert_inflection(data, pasts, "simple past and past participle", "ed-form",
"no simple past or past participle")
else
insert_inflection(data, pasts, "simple past", "spast")
insert_inflection(data, past_ptcs, "past participle", "past|part")
end
if pagename:find(" ") then
-- Check for placeholder "it"
local words = split(pagename, " ")
for _, word in ipairs(words) do
if word == "it" or word == "its" or word == "it's" then
insert(data.categories, langname .. ' terms with placeholder "it"')
break
end
end
-- Check for phrasal verbs
local phrasal_adverbs = list_to_set{
-- NOTE: This should only contain common phrasal adverbs, not random words like [[low]],
-- [[adrift]], etc.
"aback",
"about",
"above",
"across",
"after",
"against",
"ahead",
"along",
"apart",
"around",
"as",
"aside",
"at",
"away",
"back",
"before",
"behind",
"below",
"between",
"beyond",
"by",
"down",
"for",
"forth",
"from",
"in",
"into",
"of",
"off",
"on",
"onto",
"out",
"over",
"past",
"round",
"through",
"to",
"together",
"towards",
"under",
"up",
"upon",
"with",
"without",
}
local allowed_non_adverb_words = list_to_set{
"it",
"one",
"oneself",
"someone",
}
local base = pagename
local seen_adverbs = {}
-- Only consider a verb to be phrasal if it consists of a single base verb followed exclusively by either
-- adverbs from `phrasal_adverbs` or placeholder words from `allowed_non_adverb_words`, where at
-- least one following word is from `phrasal_adverbs` (hence [[can it]] is not a phrasal verb).
while true do
local prev, word = base:match("^(.+) (.-)$")
if not prev then
break
end
if phrasal_adverbs[word] then
insert(seen_adverbs, word)
elseif allowed_non_adverb_words[word] then
-- do nothing
else
break
end
base = prev
end
if not base:find(" ") and seen_adverbs[1] then
insert(data.categories, langname .. " phrasal verbs")
for i = #seen_adverbs, 1, -1 do
insert(data.categories, langname .. ' phrasal verbs formed with "' .. seen_adverbs[i] ..
'"')
end
end
end
end,
}
-----------------------------------------------------------------------------------------
-- Suffix forms --
-----------------------------------------------------------------------------------------
pos_functions["geendung fiellas"] = {
params = {
[1] = {required = true, list = true, disallow_holes = true},
},
func = function(args, data, is_suffix)
local suffix_type = {}
for _, typ in ipairs(args[1]) do
insert(suffix_type, typ .. "-maciende geendung")
end
insert(data.inflections, {label = "unfrumcenned fiell of " .. m_table.serialCommaJoin(suffix_type, {conj = "or"})})
end,
}
return export
3tjbcqhz0bk2kwj1jlbp3ypeiq5z0rl
54895
54894
2026-09-28T21:08:00Z
Deadend0914
7211
54895
Scribunto
text/plain
local export = {}
local pos_functions = {}
--[==[
Author from 2020 on: mostly Benwing2, with significant contributions from Theknightwho. Based on a prior version by Rua
(by now mostly rewritten), with contributions from Erutuon and others (see history for full attribution).
]==]
local force_cat = false -- for testing; if true, categories appear in non-mainspace pages
local require = require
local require_when_needed = require("Module:require when needed")
local en_utilities_module = "Module:en-utilities"
local headword_utilities_module = "Module:headword utilities"
local headword_module = "Module:headword"
local inflection_utilities_module = "Module:inflection utilities"
local parse_utilities_module = "Module:parse utilities"
local JSON_module = "Module:JSON"
local labels_module = "Module:labels"
local links_module = "Module:links"
local parameters_module = "Module:parameters"
local string_utilities_module = "Module:string utilities"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local yesno_module = "Module:yesno"
local iut = require_when_needed(inflection_utilities_module)
local put = require_when_needed(parse_utilities_module)
local m_headword_utilities = require_when_needed(headword_utilities_module)
local add_links_to_multiword_term = require_when_needed(headword_utilities_module, "add_links_to_multiword_term")
local add_suffix = require_when_needed(en_utilities_module, "add_suffix")
local apply_link_modifiers = require_when_needed(headword_utilities_module, "apply_link_modifiers")
local concat = table.concat
local deepEquals = require_when_needed(table_module, "deepEquals")
local dump = mw.dumpObject
local format_categories = require_when_needed(utilities_module, "format_categories")
local full_headword = require_when_needed(headword_module, "full_headword")
local get_label_info = require_when_needed(labels_module, "get_label_info")
local get_link_page = require_when_needed(links_module, "get_link_page")
local glossary_link = require_when_needed(headword_utilities_module, "glossary_link")
local insert = table.insert
local insertIfNot = require_when_needed(table_module, "insertIfNot")
local ipairs = ipairs
local is_regular_plural = require_when_needed(en_utilities_module, "is_regular_plural")
local list_to_set = require_when_needed(table_module, "listToSet")
local pairs = pairs
local process_params = require_when_needed(parameters_module, "process")
local remove = table.remove
local remove_links = require_when_needed(links_module, "remove_links")
local replacement_escape = require_when_needed(string_utilities_module, "replacement_escape")
local shallowCopy = require_when_needed(table_module, "shallowCopy")
local singularize = require_when_needed(en_utilities_module, "singularize")
local split = require_when_needed(string_utilities_module, "split")
local toJSON = require_when_needed(JSON_module, "toJSON")
local toNFD = mw.ustring.toNFD
local type = type
local ulen = require_when_needed(string_utilities_module, "len")
local ulower = require_when_needed(string_utilities_module, "lower")
local umatch = require_when_needed(string_utilities_module, "match")
local u = require_when_needed(string_utilities_module, "char")
local ugsub = require_when_needed(string_utilities_module, "gsub")
local lang = require("Module:languages").getByCode("en")
local langname = lang:getCanonicalName()
local list_param = {list = true, disallow_holes = true}
local list_allow_holes = {list = true, allow_holes = true}
local boolean_param = {type = "boolean"}
local function ine(val)
if val == "" then return nil else return val end
end
local function track(page)
require("Module:debug/track")("en-headword/" .. page)
return true
end
------------------------------------------- UTILITY FUNCTIONS ------------------------------------------
-- Parse and return an inflection not requiring additional processing. The raw arguments come from `args[field]`, which
-- is parsed for inline modifiers.
local function parse_inflection(args, field, is_head)
local argfield = field
if type(argfield) == "table" then
argfield = argfield[1]
end
return m_headword_utilities.parse_term_list_with_modifiers {
paramname = field,
forms = args[argfield],
splitchar = ",",
is_head = is_head,
}
end
-- Insert the parsed inflections in `terms` (as parsed by `parse_inflection`) into `data.inflections`, with label
-- `label` and optional accelerator spec `accel`.
local function insert_inflection(data, terms, label, accel, no_label)
for _, termobj in ipairs(terms) do
m_headword_utilities.remove_termobj_field_modifiers(termobj)
end
m_headword_utilities.insert_inflection {
headdata = data,
terms = terms,
label = label,
no_label = no_label,
accel = accel and {form = accel} or nil,
}
end
-- Insert a fixed label `label` into the inflections for `data`. If `originating_term` is supplied, copy the decorations
-- from it into the fixed label.
local function insert_fixed_inflection(data, label, originating_term)
m_headword_utilities.insert_fixed_inflection {
headdata = data,
originating_term = originating_term,
label = label,
}
end
-- Parse and insert an inflection not requiring additional processing into `data.inflections`. The raw arguments come
-- from `args[field]`, which is parsed for inline modifiers. `label` is the label that the inflections are given;
-- `accel` is the accelerator form, or nil.
local function parse_and_insert_inflection(data, args, field, label, accel)
m_headword_utilities.parse_and_insert_inflection {
headdata = data,
forms = args[field],
paramname = field,
splitchar = ",",
label = label,
accel = accel and {form = accel} or nil,
}
end
-- These functions are used directly in the <> format as well as in the utility functions #2 below.
local function compute_double_last_cons_stem(term)
local last_cons = term:match("([bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])$")
if not last_cons then
error("Verb stem '" .. term .. "' must end in a consonant to use ++")
end
return term .. last_cons
end
local function compute_plusplus_s_form(term, default_s_form)
if term:find("[szx]$") then
-- regas -> regasses, derez -> derezzes
return compute_double_last_cons_stem(term) .. "es"
else
return default_s_form
end
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local iparams = {
[1] = true,
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local parargs = frame:getParent().args
local poscat = iargs[1]
local pos_in_1 = not poscat
if pos_in_1 then
poscat = ine(parargs[1]) or
mw.title.getCurrentTitle().fullText == "Template:en-head" and "interjection" or
error("Part of speech must be specified in 1=")
poscat = require(headword_module).canonicalize_pos(poscat)
end
local indexing_poscat = pos_in_1 and "head" or poscat
local params = {
["head"] = list_param,
["id"] = true,
["json"] = boolean_param,
["sort"] = true,
["splithyph"] = boolean_param,
["nosplithyph"] = boolean_param,
["hyphspace"] = boolean_param,
["nolink"] = boolean_param,
["nolinkhead"] = {type = "boolean_param", alias_of = "nolink"},
["suffix"] = boolean_param,
["nosuffix"] = boolean_param,
["nomultiwordcat"] = boolean_param,
["abbr"] = list_param,
["the"] = true,
["def"] = {alias_of = "the"},
["pagename"] = true, -- for testing
}
if pos_in_1 then
params[1] = {required = true} -- required but ignored as already processed above
end
local pos_data = pos_functions[indexing_poscat]
local pos_func
if pos_data then
local pos_params = pos_data.params
if pos_params then
for key, val in pairs(pos_params) do
params[key] = val
end
end
pos_func = pos_data.func
end
local args = process_params(parargs, params)
-- Account for unsupported titles, e.g. 'C|N>K' instead of 'Unsupported titles/C through N to K'.
local pagename = args.pagename or mw.loadData("Module:headword/data").pagename
local user_specified_heads = parse_inflection(args, "head", "is_head")
local heads = user_specified_heads
local autohead
if args.nolink or not pagename:find("[ '%-]") then
autohead = pagename
else
local en_no_split_apostrophe_words = list_to_set {
"one's",
"someone's",
"he's",
"she's",
"it's",
}
local en_include_hyphen_prefixes = list_to_set {
-- We don't include things that are also words even though they are often (perhaps mostly) prefixes, e.g.
-- "be", "counter", "cross", "extra", "half", "mid", "over", "pan", "under".
"acro",
"acousto",
"Afro",
"agro",
"anarcho",
"angio",
"Anglo",
"ante",
"anti",
"arch",
"auto",
"bi",
"bio",
"cis",
"co",
"cryo",
"crypto",
"de",
"demi",
"eco",
"electro",
"Euro",
"ex",
"Greco",
"hemi",
"hydro",
"hyper",
"hypo",
"infra",
"Indo",
"inter",
"intra",
"Judeo",
"macro",
"meta",
"micro",
"mini",
"multi",
"neo",
"neuro",
"non",
"para",
"peri",
"post",
"pre",
"pro",
"proto",
"pseudo",
"re",
"semi",
"sub",
"super",
"trans",
"un",
"vice",
}
local function is_english(term)
local title = mw.title.new(term)
if title and title.exists then
local content = title:getContent()
if content and content:find("==English==\n") then
return true
end
end
return false
end
local function en_split_hyphen_when_space(word)
if not word:find("-", nil, true) then
return nil
end
if args.hyphspace then
return "[[" .. word:gsub("%-+", " ") .. "|" .. word .. "]]"
end
if args.nosplithyph then
return "[[" .. word .. "]]"
end
if not args.splithyph then
local space_word = word:gsub("%-+", " ")
if is_english(space_word) then
return "[[" .. space_word .. "|" .. word .. "]]"
end
if is_english(word) then
return "[[" .. word .. "]]"
end
end
return nil
end
local function en_split_apostrophe(word)
local base = word:match("^(.*)'s$")
if base then
return "[[" .. base .. "]][[-'s|'s]]"
end
-- Only treat final apostrophe as possessive if preceded by something that looks like a plural ending in /z/.
-- In particular we don't want to do it for words like [[truckin']].
base = word:match("^(.*[sxz])'$")
if base then
if base:find("s$") then
local sg = singularize(base)
if is_english(sg) then
return "[[" .. sg .. "|" .. base .. "]][[-'|']]"
end
end
return "[[" .. base .. "]][[-'|']]"
end
return "[[" .. word .. "]]"
end
autohead = add_links_to_multiword_term(pagename, {
split_hyphen_when_space = en_split_hyphen_when_space,
split_apostrophe = en_split_apostrophe,
no_split_apostrophe_words = en_no_split_apostrophe_words,
include_hyphen_prefixes = en_include_hyphen_prefixes,
})
end
if not heads[1] then
heads = {{term = autohead}}
else
for _, headobj in ipairs(heads) do
local head = headobj.term
if head:find("^~") then
head = apply_link_modifiers(autohead, head:sub(2), lang)
headobj.term = head
elseif head:find("^[!?]$") then
-- If explicit head= just consists of ! or ?, add it to the end of the default head.
headobj.term = autohead .. head
end
if head == autohead then
track("redundant-head")
end
end
end
-- handle the=/def=
if args.the == "~" then
local newheads = {}
for _, headobj in ipairs(heads) do
local barehead = shallowCopy(headobj)
insert(newheads, barehead)
headobj.term = "the " .. headobj.term
insert(newheads, headobj)
end
heads = newheads
elseif args.the then
local the = require(yesno_module)(args.the)
if the then
for _, headobj in ipairs(heads) do
headobj.term = "the " .. headobj.term
end
end
end
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = heads,
user_specified_heads = user_specified_heads,
-- We use our own splitting algorithm so the redundant head cat will be inaccurate.
no_redundant_head_cat = true,
inflections = {},
nomultiwordcat = args.nomultiwordcat,
sort_key = args.sort,
pagename = pagename,
id = args.id,
force_cat_output = force_cat,
}
local function inscat(cat)
insert(data.categories, langname .. " " .. cat)
end
local is_suffix = false
if args.suffix or not args.nosuffix and pagename:find("^%-") and not pagename:find("^%-%-") and poscat ~= "suffix forms" then
is_suffix = true
data.pos_category = "suffixes"
local singular_poscat = singularize(poscat)
inscat(singular_poscat .. "-forming suffixes")
insert(data.inflections, {label = singular_poscat .. "-forming suffix"})
end
if pos_func then
pos_func(args, data, is_suffix)
end
local extra_categories = {}
if pagename:find("[Qq]") then
-- Check for q not followed by u. We want to exclude things like [[13q deletion syndrome]] and [[BFOQ]] that
-- don't have a lowercase letter on either side, as well as things like [[& seq.]] and [[acq.]] that are
-- abbreviations for words containing a following u.
--
-- Approximate range of combining diacritics; we want to remove them so the checks below for
-- a lowercase letter next to the q aren't tripped up by diacritics on the letter.
local u300 = u(0x0300)
local u36F = u(0x036F)
local pagename_no_diacritics = ugsub(toNFD(pagename), "[" .. u300 .. "-" .. u36F .. "]", "")
if pagename_no_diacritics:find("[Qq][a-tv-z]") or pagename_no_diacritics:find("[a-z]q[^u.]") or
pagename_no_diacritics:find("[a-z]q$") then
inscat("words containing Q not followed by U")
end
end
-- toNFD performs decomposition, so letters that decompose to an ASCII
-- vowel and a diacritic, such as é, are counted as vowels and do not do not
-- need to be included in the pattern.
if not umatch(ulower(toNFD(pagename)), "[aeiouyæœøəªºαεηιουω]") then
inscat("words spelled without vowels")
end
if pagename:find("yre$") then
inscat('words ending in "-yre"')
end
if not pagename:find(" ") and ulen(pagename) >= 25 then
insert(extra_categories, "Long " .. langname .. " words")
end
if pagename:find("^[^aeiou ]*a[^aeiou ]*e[^aeiou ]*i[^aeiou ]*o[^aeiou ]*u[^aeiou ]*$") then
inscat("words that use all vowels in alphabetical order")
end
parse_and_insert_inflection(data, args, "abbr", "abbreviation")
if args.json then
return toJSON(data)
end
return full_headword(data)
.. (extra_categories[1]
and format_categories(extra_categories, lang, args.sort)
or "")
end
local function make_default_comparative(word)
if word == "good" or word == "well" then
return {"better"}
elseif word == "bad" or word == "badly" then
return {"worse"}
elseif word == "far" then
return {"further", "farther"}
else
return {add_suffix(word, "r")}
end
end
local function make_default_superlative(word)
if word == "good" or word == "well" then
return {"best"}
elseif word == "bad" or word == "badly" then
return {"worst"}
elseif word == "far" then
return {"furthest", "farthest"}
else
return {add_suffix(word, "st.superlative")}
end
end
-- This function does the common work between adjectives and adverbs.
local function process_comparative_args(data, args, plpos)
local pagename = data.pagename
local comps = parse_inflection(args, 1)
local sups = parse_inflection(args, "sup")
local outcomps, outsups
if args.componly then
if comps[1] then
error("Can't specify comparatives of comparative-only " .. plpos)
end
insert(data.inflections, {label = glossary_link("comparative") .. " form only"})
insert(data.categories, langname .. " comparative-only " .. plpos)
-- Set to empty list so we don't get any comparatives output, but process superlatives if specified.
outcomps = {}
if not sups[1] then
-- Set to empty list so we don't get any superlatives output unless explicitly given.
outsups = {}
end
elseif args.suponly then
if comps[1] or sups[1] then
error("Can't specify comparatives or superlatives of or superlative-only " .. plpos)
end
insert(data.inflections, {label = glossary_link("superlative") .. " form only"})
insert(data.categories, langname .. " superlative-only " .. plpos)
return
end
-- If the first parameter is ?, then don't show anything, just return.
if comps[1] and comps[1].term == "?" then
if comps[2] then
error("Can't specify additional comparatives along with '?'")
end
if sups[1] then
error("Can't specify superlatives along with '?' for the comparative")
end
return
end
if comps[1] and comps[1].term == "-" then
local hyphencomp = remove(comps, 1) -- Remove the "-" but retain for decorations.
-- Not (generally) comparable; may occasionally have a comparative
if comps[1] then
insert_fixed_inflection(data, "not generally <<comparable>>", hyphencomp)
elseif not sups[1] then
insert_fixed_inflection(data, "not <<comparable>>", hyphencomp)
insert(data.categories, langname .. " uncomparable " .. plpos)
return
else
-- No comparative, but a superlative. insert_inflection() will correctly generate 'no comparative' if we
-- pass in "-" as the value.
outcomps = {hyphencomp}
end
elseif not comps[1] then
comps = {{term = "more"}}
end
if not outcomps then -- not if we set `outcomps` to "-" above or processed a comparative-only term
outcomps = {}
-- Go over each parameter given and create a comparative and superlative form.
for _, compobj in ipairs(comps) do
local comp = compobj.term
if comp == "-" then
error("Comparative of '-' only allowed as first comparative")
end
if comp == "+" then
comp = "+more"
elseif comp == "more" and pagename ~= "many" and pagename ~= "much" then
comp = "+more"
elseif comp == "further" and pagename ~= "far" then
comp = "+further"
elseif comp == "better" and pagename ~= "good" and pagename ~= "well" then
comp = "+better"
elseif comp:find("~") then
comp = comp:gsub("~", replacement_escape(pagename))
end
compobj.origterm = comp
if comp == "+more" then
comp = "more [[" .. pagename .. "]]"
elseif comp == "+further" then
comp = {"further [[" .. pagename .. "]]", "farther [[" .. pagename .. "]]"}
elseif comp == "+better" then
comp = "better [[" .. pagename .. "]]"
elseif comp == "er" then
-- Add -er.
comp = add_suffix(pagename, "r")
elseif comp == "ier" then
if pagename:sub(-1) ~= "y" then
error("Can't specify 'ier' comparative unless the term ends with 'y': " .. pagename)
end
comp = pagename:gsub("e?y$", "ier")
elseif comp:find("^%+") then
local special = m_headword_utilities.get_special_indicator(comp, "noerror")
if special then
comp = m_headword_utilities.handle_multiword(pagename, special, make_default_comparative)
end
end
if type(comp) == "table" and not comp[2] then
comp = comp[1]
end
if type(comp) == "table" then
for i = 1, #comp - 1 do
local outobj = shallowCopy(compobj)
outobj.term = comp[i]
insert(outcomps, outobj)
end
compobj.term = comp[#comp]
insert(outcomps, compobj)
else
compobj.term = comp
insert(outcomps, compobj)
end
end
end
if sups[1] and sups[1].term == "-" then
if sups[2] then
error("Can't specify '-' as superlative followed by further values")
end
-- No superlative. insert_inflection() will correctly generate 'no superlative' if we pass in "-" as the value.
outsups = sups
else
if not sups[1] then
sups = {{term = "+"}}
end
end
-- `outsups` will be set if we set `outsups` to "-" above or processed a comparative-only term without superlatives.
if not outsups then
outsups = {}
local function process_sup(sup, special, supobj, compobj)
if special then
sup = m_headword_utilities.handle_multiword(pagename, special, make_default_superlative)
elseif sup == "-" or sup == "+" then
error(("Internal error: Superlative value of '%s' should have been handled earlier"):format(sup))
elseif sup == "+most" then
sup = "most [[" .. pagename .. "]]"
elseif sup == "+furthest" then
sup = {"furthest [[" .. pagename .. "]]", "farthest [[" .. pagename .. "]]"}
elseif sup == "+best" then
sup = "best [[" .. pagename .. "]]"
elseif sup == "est" then
-- Add -est.
sup = add_suffix(pagename, "st.superlative")
elseif sup == "iest" then
if pagename:sub(-1) ~= "y" then
error("Can't specify 'iest' superlative unless the term ends with 'y': " .. pagename)
end
sup = pagename:gsub("e?y$", "iest")
end
if type(sup) == "table" and not sup[2] then
sup = sup[1]
end
if compobj then
supobj = shallowCopy(supobj)
supobj = m_headword_utilities.combine_termobj_decorations(supobj, compobj)
end
if type(sup) == "table" then
for i = 1, #sup - 1 do
local outobj = shallowCopy(supobj)
outobj.term = sup[i]
insert(outsups, outobj)
end
supobj.term = sup[#sup]
insert(outsups, supobj)
else
supobj.term = sup
insert(outsups, supobj)
end
end
for _, supobj in ipairs(sups) do
local sup = supobj.term
if sup == "-" then
error("Superlative of '-' only allowed as first superlative")
end
if sup == "+" then
if not comps[1] then
error("Superlative of '+' can't be specified when there are no comparatives")
end
for _, compobj in ipairs(comps) do
local comp = compobj.origterm
local special
if comp == "+more" then
sup = "+most"
elseif comp == "+further" then
sup = "+furthest"
elseif comp == "+better" then
sup = "+best"
elseif comp == "er" then
sup = "est"
elseif comp == "ier" then
sup = "iest"
else
if comp:find("^%+") then
special = m_headword_utilities.get_special_indicator(comp, "noerror")
end
if not special then
-- If the full comparative was given, then derive the superlative by replacing -er with
-- -est.
if comp:sub(-2) == "er" then
sup = comp:sub(1, -3) .. "est"
else
error(("The superlative cannot be derived automatically from comparative '%s' because it doesn't end in -er"):format(comp))
end
end
end
process_sup(sup, special, supobj, compobj)
end
else
local special = m_headword_utilities.get_special_indicator(sup, "noerror")
-- Do some work here rather than in process_sup() so we don't end up double-processing a term with a '~'
-- in it or a term that happens to be 'most' or similar after substitution of ~ in the comparative.
if not special then
if sup == "most" and pagename ~= "many" and pagename ~= "much" then
sup = "+most"
elseif sup == "furthest" and pagename ~= "far" then
sup = "+furthest"
elseif sup == "best" and pagename ~= "good" and pagename ~= "well" then
sup = "+best"
elseif sup:find("~") then
sup = sup:gsub("~", replacement_escape(pagename))
end
end
process_sup(sup, special, supobj)
end
end
end
insert_inflection(data, outcomps, "<<comparative>>", "comparative")
insert_inflection(data, outsups, "<<superlative>>", "superlative")
end
pos_functions["adjectives"] = {
params = {
[1] = list_param,
["comp_qual"] = {list = "comp\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the comparative value",
},
["sup"] = list_param,
["sup_qual"] = {list = "sup\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the superlative value",
},
["componly"] = boolean_param,
["suponly"] = boolean_param,
},
func = function(args, data)
-- Process the comparatives and superlatives.
process_comparative_args(data, args, "adjectives")
end,
}
pos_functions["adverbs"] = {
params = {
[1] = list_param,
["comp_qual"] = {list = "comp\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the comparative value",
},
["sup"] = list_param,
["sup_qual"] = {list = "sup\1_qual", allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the superlative value",
},
["componly"] = boolean_param,
["suponly"] = boolean_param,
},
func = function(args, data)
-- Process the comparatives and superlatives.
process_comparative_args(data, args, "adverbs")
end,
}
local function escape(str)
return (str:gsub("\\([:#])", "\\\\%1")
:gsub("[:#]", "\\%0"))
end
local function canonicalize_plural(pl, pagename, pos)
if pl == "+" then
return escape(add_suffix(pagename, "s.plural", pos))
elseif pl == "++" then
return escape(compute_plusplus_s_form(pagename, add_suffix(pagename, "s.plural", pos)))
elseif pl == "*" then
return escape(pagename)
elseif pl == "ies" then
if pagename:sub(-1) == "y" then
return escape(pagename:gsub("e?y$", pl))
end
error("Can't specify 'ies' plural unless the term ends with 'y'.")
elseif pl == "s" or pl == "es" or pl == "'s" then
return escape(pagename .. pl)
end
end
local function do_nouns(args, data, pos)
local pagename = data.pagename
pos = pos or "noun"
local plurals = parse_inflection(args, 1)
local function insert_plurale_tantum_inflections(is_plural_only, originating_label)
if args.sg[1] then
insert_fixed_inflection(data, "normally plural", originating_label)
parse_and_insert_inflection(data, args, "sg", "singular")
elseif is_plural_only then
insert_fixed_inflection(data, "plural only", originating_label)
end
if args.attr[1] then
parse_and_insert_inflection(data, args, "attr", "attributive")
end
end
local function first_pl_term()
return plurals[1] and plurals[1].term or nil
end
if first_pl_term() == "p" then
-- plurale tantum
if plurals[2] then
error("With plurale tantum noun, can't specify more than one plural")
end
data.genders = {"p"} -- this should auto-insert the correct 'pluralia tantum' category
insert_plurale_tantum_inflections("plural only", plurals[1])
return
end
local function inscat(cat)
insert(data.categories, langname .. " " .. cat)
end
local need_default_plural = pos == "noun"
if first_pl_term() == "sp" then
-- construed as singular or plural
sp = remove(plurals, 1) -- Remove the "sp" but retain it for its decorations.
inscat("nouns construed as singular or plural")
data.genders = {"s", "p"} -- this should auto-insert the correct 'pluralia tantum' category
insert_plurale_tantum_inflections(nil, sp)
need_default_plural = false
elseif first_pl_term() == "-" then
-- Uncountable noun; may occasionally have a plural
local hyphpl = remove(plurals, 1) -- Remove the "-" but retain for decorations.
inscat("uncountable nouns")
-- If plural forms were given explicitly, then show "usually"
if plurals[1] then
insert_fixed_inflection(data, "usually <<uncountable>>", hyphpl)
else
insert_fixed_inflection(data, "<<uncountable>>", hyphpl)
end
need_default_plural = false
elseif first_pl_term() == "#" then
-- Usually countable (e.g., "grilled cheese")
local hashpl = remove(plurals, 1) -- Remove the "#" but retain for decorations.
insert_fixed_inflection(data, "usually <<countable>>", hashpl)
inscat("uncountable nouns")
inscat("countable nouns")
-- If no plural was given, add a default one now
if not plurals[1] then
plurals[1] = {term = escape(add_suffix(pagename, "s.plural", pos))}
end
elseif first_pl_term() == "~" then
-- Mixed countable/uncountable noun, always has a plural
local tildepl = remove(plurals, 1) -- Remove the "~" but retain for decorations.
insert_fixed_inflection(data, "<<countable>> and <<uncountable>>", tildepl)
inscat("uncountable nouns")
inscat("countable nouns")
-- If no plural was given, add a default one now
if not plurals[1] then
plurals[1] = {term = escape(add_suffix(pagename, "s.plural", pos))}
end
end
-- Plural is unknown
if first_pl_term() == "?" then
local questionpl = remove(plurals, 1) -- Remove the "?" but retain for decorations.
-- Not desired; see [[Wiktionary:Tea_room/2021/August#"Plural unknown or uncertain"]]
-- insert_fixed_inflection(data, "plural unknown or uncertain", questionpl)
inscat("nouns with unknown or uncertain plurals")
if plurals[1] then
error("Can't specify explicit plurals along with '?' for unknown/uncertain plural")
end
return
end
-- Plural is not attested
if first_pl_term() == "!" then
local exclampl = remove(plurals, 1) -- Remove the "!" but retain for decorations.
insert_fixed_inflection(data, "plural not attested", exclampl)
inscat("nouns with unattested plurals")
if plurals[1] then
error("Can't specify explicit plurals along with '!' for unattested plural")
end
return
end
-- If no plural was given, maybe add a default one, otherwise (when "-" was given or proper noun) return.
if not plurals[1] then
if not need_default_plural then
inscat("uncountable nouns")
return
end
plurals[1] = {term = escape(add_suffix(pagename, "s.plural", pos))}
end
-- There are plural forms to show, so show them.
inscat("countable nouns")
local irregular, indeclinable
for i, pl in ipairs(plurals) do
local canon_pl = canonicalize_plural(pl.term, pagename, pos)
if canon_pl then
pl.term = canon_pl
end
local pl_term = get_link_page(pl.term, lang)
if not (pagename:find(" ") or is_regular_plural(pl_term, pagename)) then
irregular = true
if pl_term == pagename then
indeclinable = true
end
end
end
if irregular then
inscat("nouns with irregular plurals")
end
if indeclinable then
inscat("indeclinable nouns")
end
insert_inflection(data, plurals, "plural", "p")
end
-- Return the parameters to be used for nouns and proper nouns. Currently the same.
local noun_params = {
[1] = list_param,
["pl\1qual"] = {list = true, allow_holes = true, replaced_by = false,
instead = "use <l:...> or <q:...> inline modifier on the plural",
},
-- The following four only used for pluralia tantum (1=p)
["sg"] = list_param,
["attr"] = list_param,
}
pos_functions["nouns"] = {
params = noun_params,
func = do_nouns,
}
pos_functions["proper nouns"] = {
params = noun_params,
func = function(args, data)
return do_nouns(args, data, "proper noun")
end,
}
local function base_default_verb_forms(verb)
return escape(add_suffix(verb, "s.verb")), escape(add_suffix(verb, "ing")), escape(add_suffix(verb, "d"))
end
local function default_verb_forms(verb)
local full_s_form, full_ing_form, full_ed_form = base_default_verb_forms(verb)
if verb:find(" ") then
local first, rest = verb:match("^(.-)( .*)$")
local first_s_form, first_ing_form, first_ed_form = base_default_verb_forms(first)
return full_s_form, full_ing_form, full_ed_form, first_s_form .. rest, first_ing_form .. rest,
first_ed_form .. rest, first, rest
else
return full_s_form, full_ing_form, full_ed_form, nil, nil, nil, nil, nil
end
end
local function compute_double_last_cons_stem_of_split_verb(verb, ending)
local first, rest = verb:match("^(.-)( .*)$")
if not first then
error("Verb '" .. verb .. "' must have a space in it to use **")
end
local last_cons = first:match("([bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ])$")
if not last_cons then
error("First word '" .. first .. "' must end in a consonant to use **")
end
return first .. last_cons .. ending .. rest
end
local function check_non_nil_star_form(form, pagename)
if form == nil then
error("Verb '" .. pagename .. "' must have a space in it to use *, **, *l, *! or *'")
end
return form
end
local function sub_tilde(form, pagename)
if not form then
return nil
end
if form:find("~") then
form = form:gsub("~", replacement_escape(pagename))
end
return form
end
local deprecated_qual_replaced_by_inline_modifier = {
list = true, allow_holes = true, replaced_by = false,
instead = "use an inline modifier <q:...> or <l:...> on the value"
}
pos_functions["verbs"] = {
params = {
[1] = {list = "pres_3sg", disallow_holes = true},
["pres_3sg\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
[2] = {list = "pres_ptc", disallow_holes = true},
["pres_ptc\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
[3] = {list = "past", disallow_holes = true},
["past\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
[4] = {list = "past_ptc", allow_holes = true},
["past_ptc\1_qual"] = deprecated_qual_replaced_by_inline_modifier,
["noautolinkverb"] = boolean_param,
["angle_bracket"] = boolean_param,
},
func = function(args, data)
-- Get parameters
local par1s
local par2s = parse_inflection(args, {2, "pres_ptc"})
local par3s = parse_inflection(args, {3, "past"})
local par4s = parse_inflection(args, {4, "past_ptc"})
local pres_3sgs, pres_ptcs, pasts, past_ptcs
local pagename = data.pagename
------------------------------------------- UTILITY FUNCTIONS #2 ------------------------------------------
-- These functions are used in both in the separate-parameter format and in the override params such as past_ptc2=.
local full_default_s, full_default_ing, full_default_ed, split_default_s, split_default_ing, split_default_ed
local lemma
local function set_lemma_and_default_forms(the_lemma)
lemma = the_lemma
full_default_s, full_default_ing, full_default_ed, split_default_s, split_default_ing, split_default_ed,
lemma_first, lemma_rest = default_verb_forms(the_lemma)
end
local function canonicalize_s_form(form)
if form == "+" then
error("Internal error: Should not see '+' here")
elseif form == "^" then
return full_default_s
elseif form == "*" then
return check_non_nil_star_form(split_default_s, lemma)
elseif form == "++" then
return compute_plusplus_s_form(lemma, full_default_s)
elseif form == "**" then
if lemma:find("^[^ ]*[szx] ") then
return compute_double_last_cons_stem_of_split_verb(lemma, "es")
else
return check_non_nil_star_form(split_default_s, lemma)
end
elseif form == "+!" then
return lemma .. "s"
elseif form == "*!" then
return check_non_nil_star_form(lemma_first) .. "s" .. lemma_rest
elseif form == "+'" then
return lemma .. "'s"
elseif form == "*'" then
return check_non_nil_star_form(lemma_first) .. "'s" .. lemma_rest
elseif form == "+l" then
if lemma:find("[szx]$") then
return {{term = full_default_s, l = {"US"}},
{term = compute_plusplus_s_form(lemma, full_default_s), l = {"UK"}}}
else
return compute_plusplus_s_form(lemma, full_default_s)
end
elseif form == "*l" then
if lemma:find("^[^ ]*[szx] ") then
return {{term = check_non_nil_star_form(split_default_s, lemma), l = {"US"}},
{term = compute_double_last_cons_stem_of_split_verb(lemma, "es"), l = {"UK"}}}
else
return check_non_nil_star_form(split_default_s, lemma)
end
else
return sub_tilde(form, lemma)
end
end
local function canonicalize_ing_form(form)
if form == "+" then
error("Internal error: Should not see '+' here")
elseif form == "^" then
return full_default_ing
elseif form == "*" then
return check_non_nil_star_form(split_default_ing, lemma)
elseif form == "++" then
return compute_double_last_cons_stem(lemma) .. "ing"
elseif form == "**" then
return compute_double_last_cons_stem_of_split_verb(lemma, "ing")
elseif form == "+!" then
return lemma .. "ing"
elseif form == "*!" then
return check_non_nil_star_form(lemma_first) .. "ing" .. lemma_rest
elseif form == "+'" then
return lemma .. "'ing"
elseif form == "*'" then
return check_non_nil_star_form(lemma_first) .. "'ing" .. lemma_rest
elseif form == "+l" then
return {{term = full_default_ing, l = {"US"}},
{term = compute_double_last_cons_stem(lemma) .. "ing", l = {"UK"}}}
elseif form == "*l" then
return {{term = check_non_nil_star_form(split_default_ing, lemma), l = {"US"}},
{term = compute_double_last_cons_stem_of_split_verb(lemma, "ing"), l = {"UK"}}}
else
return sub_tilde(form, lemma)
end
end
local function canonicalize_ed_form(form)
if form == "+" then
error("Internal error: Should not see '+' here")
elseif form == "^" then
return full_default_ed
elseif form == "*" then
return check_non_nil_star_form(split_default_ed, lemma)
elseif form == "++" then
return compute_double_last_cons_stem(lemma) .. "ed"
elseif form == "+!" then
return lemma .. "ed"
elseif form == "*!" then
return check_non_nil_star_form(lemma_first) .. "ed" .. lemma_rest
elseif form == "+'" then
return {{term = lemma .. "'d"}, {term = lemma .. "'ed"}}
elseif form == "*'" then
return {{term = check_non_nil_star_form(lemma_first) .. "'d" .. lemma_rest},
{term = check_non_nil_star_form(lemma_first) .. "'ed" .. lemma_rest}}
elseif form == "**" then
return compute_double_last_cons_stem_of_split_verb(lemma, "ed")
elseif form == "+l" then
return {{term = full_default_ed, l = {"US"}},
{term = compute_double_last_cons_stem(lemma) .. "ed", l = {"UK"}}}
elseif form == "*l" then
return {{term = check_non_nil_star_form(split_default_ed, lemma), l = {"US"}},
{term = compute_double_last_cons_stem_of_split_verb(lemma, "ed"), l = {"UK"}}}
else
return sub_tilde(form, lemma)
end
end
-- FIXME: options should be "+", "*", "++", "**", "+n", "*n", "++n" and "**n", but not "n"
local function canonicalize_en_form(form)
if form == "n" then
track("n4")
return add_suffix(lemma, "n")
end
return canonicalize_ed_form(form)
end
--------------------------------- MAIN PARSING/CONJUGATING CODE --------------------------------
local is_angle_bracket = args.angle_bracket
if is_angle_bracket then
if par2s[1] or par3s[1] or par4s[1] then
error("Can't specify explicit values for 2=, 3= or 4= along with the angle-bracket format")
end
elseif is_angle_bracket == nil and not par2s[1] and not par3s[1] and not par4s[1] and not args[1][2] and
args[1][1] and args[1][1]:find("<") then
if put.term_contains_top_level_html(args[1][1]) then
-- Often, term_contains_top_level_html() returns true on the angle-bracket format, which would
-- make the pcall() below succeed but leave the angle brackets as-is. Check for this and only do the
-- pcall() if term_contains_top_level_html() returns false.
is_angle_bracket = true
else
-- If it's ambiguous whether it's an angle-bracket format or separate params with an inline modifier,
-- try to parse as the latter. If an error occurs, treat as the former.
local ok
ok, par1s = pcall(parse_inflection, args, {1, "pres_3sg"})
if not ok then
par1s = nil
is_angle_bracket = true
end
end
end
if is_angle_bracket then
-------------------------- ANGLE-BRACKET FORMAT --------------------------
-- (0) Expand multiword term with angle brackets just on the first word.
local arg11 = args[1][1]
if arg11:find("^<.*>$") and pagename:find(" ") then
local first, rest = pagename:match("^(.-)( .*)$")
arg11 = first .. arg11 .. rest
end
-- (1) Parse the indicator specs inside of angle brackets.
local function parse_indicator_spec(angle_bracket_spec)
local inside = angle_bracket_spec:match("^<(.*)>$")
assert(inside)
local segments = put.parse_balanced_segment_run(inside, "[", "]")
local comma_separated_groups = put.split_alternating_runs(segments, ",")
if #comma_separated_groups > 4 then
error("Too many comma-separated parts in indicator spec, expected at most 4: " ..
angle_bracket_spec)
end
local function fetch_footnotes(separated_group)
local footnotes
for j = 2, #separated_group - 1, 2 do
if separated_group[j + 1] ~= "" then
error("Extraneous text after bracketed footnotes: '" .. concat(separated_group) .. "'")
end
if not footnotes then
footnotes = {}
end
insert(footnotes, separated_group[j])
end
return footnotes
end
local function fetch_specs(comma_separated_group)
if not comma_separated_group then
return {{term = "+"}}
end
local specs = {}
local colon_separated_groups = put.split_alternating_runs(comma_separated_group, ":")
for _, colon_separated_group in ipairs(colon_separated_groups) do
local form = colon_separated_group[1]
if form == "*" or form == "**" or form == "*l" or form == "*!" or form == "*'" then
error("*, **, *l, *! and *' not allowed inside of indicator specs: " .. angle_bracket_spec)
end
if form == "" then
form = "+"
end
local termobj = {
term = form
}
local footnotes = fetch_footnotes(colon_separated_group)
if footnotes then
for _, footnote in ipairs(footnotes) do
m_headword_utilities.add_footnote_to_termobj(termobj, footnote)
end
end
insert(specs, termobj)
end
return specs
end
local s_specs = fetch_specs(comma_separated_groups[1])
local ing_specs = fetch_specs(comma_separated_groups[2])
local ed_specs = fetch_specs(comma_separated_groups[3])
local en_specs = fetch_specs(comma_separated_groups[4])
return {
forms = {},
s_specs = s_specs,
ing_specs = ing_specs,
ed_specs = ed_specs,
en_specs = en_specs,
}
end
local parse_props = {
parse_indicator_spec = parse_indicator_spec,
}
local alternant_multiword_spec = iut.parse_inflected_text(arg11, parse_props)
-- (2) Check for user-specified brackets; remove any links from the lemma, but remember the original
-- form so we can use it below in the 'lemma_linked' form.
-- Check to see if there are brackets in the pre-text or post-text. If so, use the linked lemma (with the
-- verb autolinked unless noautolinkverb is given). Otherwise, use the default headword algorithm.
local function check_bracket(val)
if val:find("%[%[") then
alternant_multiword_spec.saw_bracket = true
end
end
for _, alternant_or_word_spec in ipairs(alternant_multiword_spec.alternant_or_word_specs) do
check_bracket(alternant_or_word_spec.before_text)
if alternant_or_word_spec.alternants then
for _, multiword_spec in ipairs(alternant_or_word_spec.alternants) do
for _, word_spec in ipairs(multiword_spec.word_specs) do
check_bracket(word_spec.before_text)
end
check_bracket(multiword_spec.post_text)
end
end
end
check_bracket(alternant_multiword_spec.post_text)
iut.map_word_specs(alternant_multiword_spec, function(base)
if base.lemma == "" then
base.lemma = pagename
end
base.orig_lemma = base.lemma
base.lemma = remove_links(base.lemma)
if args.noautolinkverb or base.orig_lemma:find("%[%[") then
base.linked_lemma = base.orig_lemma
else
base.linked_lemma = "[[" .. base.orig_lemma .. "]]"
end
end)
-- (3) Conjugate the verbs according to the indicator specs parsed above.
local all_verb_slots = {
lemma = "infinitive",
lemma_linked = "infinitive",
s_form = "3|s|pres",
ing_form = "pres|ptcp",
ed_form = "past",
en_form = "past|ptcp",
}
local function conjugate_verb(base)
local function process_specs(slot, specs, canon_func, default_values, default_already_formobj)
local function insert_termobj_into_slot(termobj)
local formobj = m_headword_utilities.convert_termobj_to_formobj(termobj)
-- If the form is -, don't insert any forms, which will result in there being no overall forms
-- (in fact it will be nil). We check for that down below and substitute a single "-" as the
-- form, which in turn gets turned into special labels like "no present participle".
if formobj.form == "-" then
if formobj.footnotes then
error("Unable to preserve footnotes specified on missing form '-': FIXME: " ..
dump(formobj.footnotes))
end
else
iut.insert_form(base.forms, slot, formobj)
end
end
local function canonicalize_and_insert(arg)
local canon_arg = canon_func(arg)
if type(canon_arg) == "string" then
arg.term = canon_arg
insert_termobj_into_slot(arg)
else
for _, canon in ipairs(canon_arg) do
m_headword_utilities.combine_termobj_decorations(canon, arg)
insert_termobj_into_slot(canon)
end
end
end
for _, arg in ipairs(specs) do
if arg.term == "+" then
if default_values then -- will be nil if past tense specified as - and no past ptc given
for _, val in ipairs(default_values) do
val = shallowCopy(val)
if default_already_formobj then
local argformobj = m_headword_utilities.convert_termobj_to_formobj(arg)
val.footnotes = iut.combine_footnotes(val.footnotes, argformobj.footnotes)
iut.insert_form(base.forms, slot, val)
else
m_headword_utilities.combine_termobj_decorations(val, arg)
canonicalize_and_insert(val)
end
end
end
else
canonicalize_and_insert(arg)
end
end
end
set_lemma_and_default_forms(base.lemma)
local all_part_default_specs = {}
local function process_and_canonicalize_s_form(arg)
local form = arg.term
if form == "+" then
error("Internal error: '+' should have been converted to '^' by now")
end
if form == "*" or form == "**" or form == "*l" or form == "*!" or form == "*'" then
error(("Internal error: '%s' should have already thrown an error"):format(form))
end
if form == "^" or form == "++" or form == "+l" or form == "+!" or form == "+'" then
insert(all_part_default_specs, shallowCopy(arg))
end
return canonicalize_s_form(form)
end
process_specs("s_form", base.s_specs, process_and_canonicalize_s_form, {{term = "^"}})
if not all_part_default_specs[1] then
all_part_default_specs[1] = {term = "^"}
end
process_specs("ing_form", base.ing_specs, function(arg) return canonicalize_ing_form(arg.term) end,
all_part_default_specs)
process_specs("ed_form", base.ed_specs, function(arg) return canonicalize_ed_form(arg.term) end,
all_part_default_specs)
process_specs("en_form", base.en_specs, function(arg) return canonicalize_en_form(arg.term) end,
base.forms.ed_form, "default already formobj")
iut.insert_form(base.forms, "lemma", {form = base.lemma})
-- Add linked version of lemma for use in head=. We write this in a general fashion in case
-- there are multiple lemma forms (which isn't possible currently at this level, although it's
-- possible overall using the ((...,...)) notation).
iut.insert_forms(base.forms, "lemma_linked", iut.map_forms(base.forms.lemma, function(form)
if form == base.lemma and base.linked_lemma:find("%[%[") then
return base.linked_lemma
else
return form
end
end))
end
local inflect_props = {
slot_table = all_verb_slots,
inflect_word_spec = conjugate_verb,
}
iut.inflect_multiword_or_alternant_multiword_spec(alternant_multiword_spec, inflect_props)
-- (4) Fetch the forms and put the conjugated lemmas in data.heads if not explicitly given.
local function fetch_termobjs(slot)
local forms = alternant_multiword_spec.forms[slot]
-- See above. This should only occur if the user explicitly used - for a spec.
if not forms or not forms[1] then
return {{term = "-"}}
end
local termobjs = {}
for _, formobj in ipairs(forms) do
insert(termobjs, m_headword_utilities.convert_formobj_to_termobj(formobj))
end
return termobjs
end
pres_3sgs = fetch_termobjs("s_form")
pres_ptcs = fetch_termobjs("ing_form")
pasts = fetch_termobjs("ed_form")
past_ptcs = fetch_termobjs("en_form")
-- Use the "linked" form of the lemma as the head if no head= explicitly given and the user specified
-- brackets in one of the lemmas. Otherwise we use the default headword-linking algorithm.
if not data.user_specified_heads[1] and alternant_multiword_spec.saw_bracket then
data.heads = {}
for _, lemma_obj in ipairs(alternant_multiword_spec.forms.lemma_linked) do
insert(data.heads, m_headword_utilities.convert_formobj_to_termobj(lemma_obj))
end
end
else
-------------------------- SEPARATE-PARAM FORMAT --------------------------
set_lemma_and_default_forms(pagename)
par1s = par1s or parse_inflection(args, {1, "pres_3sg"})
pres_3sgs = {}
pres_ptcs = {}
pasts = {}
past_ptcs = {}
if not par1s[1] then
par1s = {{term = "+"}}
end
if not par2s[1] then
par2s = {{term = "+"}}
end
if not par3s[1] then
par3s = {{term = "+"}}
end
if not par4s[1] then
par4s = {{term = "+"}}
end
local function process_argument(args, dest, canon_func, default_values, default_already_canonicalized)
local function canonicalize_and_insert(arg)
local canon_arg = canon_func(arg)
if type(canon_arg) == "string" then
arg.term = canon_arg
m_headword_utilities.insert_termobj_combining_duplicates(dest, arg)
else
for _, canon in ipairs(canon_arg) do
m_headword_utilities.combine_termobj_decorations(canon, arg)
m_headword_utilities.insert_termobj_combining_duplicates(dest, canon)
end
end
end
for _, arg in ipairs(args) do
if arg.term == "+" then
for _, val in ipairs(default_values) do
val = shallowCopy(val)
m_headword_utilities.combine_termobj_decorations(val, arg)
if default_already_canonicalized then
m_headword_utilities.insert_termobj_combining_duplicates(dest, val)
else
canonicalize_and_insert(val)
end
end
else
canonicalize_and_insert(arg)
end
end
end
local all_part_default_specs = {}
local function process_and_canonicalize_s_form(arg)
local form = arg.term
if form == "+" then
error("Internal error: '+' should have been converted to '^' by now")
end
if form == "^" or form == "++" or form == "+l" or form == "+!" or form == "+'" or
form == "*" or form == "**" or form == "*l" or form == "*!" or form == "*'" then
insert(all_part_default_specs, shallowCopy(arg))
end
return canonicalize_s_form(form)
end
process_argument(par1s, pres_3sgs, process_and_canonicalize_s_form, {{term = "^"}})
if not all_part_default_specs[1] then
all_part_default_specs[1] = {term = "^"}
end
process_argument(par2s, pres_ptcs, function(arg) return canonicalize_ing_form(arg.term) end,
all_part_default_specs)
process_argument(par3s, pasts, function(arg) return canonicalize_ed_form(arg.term) end,
all_part_default_specs)
process_argument(par4s, past_ptcs, function(arg) return canonicalize_en_form(arg.term) end,
pasts, "default already canonicalized")
end
------------------------------------------- INSERT INFLECTIONS ------------------------------------------
insert_inflection(data, pres_3sgs, "third-person singular simple present", "s-verb-form")
insert_inflection(data, pres_ptcs, "present participle", "ing-form")
if deepEquals(pasts, past_ptcs) then
insert_inflection(data, pasts, "simple past and past participle", "ed-form",
"no simple past or past participle")
else
insert_inflection(data, pasts, "simple past", "spast")
insert_inflection(data, past_ptcs, "past participle", "past|part")
end
if pagename:find(" ") then
-- Check for placeholder "it"
local words = split(pagename, " ")
for _, word in ipairs(words) do
if word == "it" or word == "its" or word == "it's" then
insert(data.categories, langname .. ' terms with placeholder "it"')
break
end
end
-- Check for phrasal verbs
local phrasal_adverbs = list_to_set{
-- NOTE: This should only contain common phrasal adverbs, not random words like [[low]],
-- [[adrift]], etc.
"aback",
"about",
"above",
"across",
"after",
"against",
"ahead",
"along",
"apart",
"around",
"as",
"aside",
"at",
"away",
"back",
"before",
"behind",
"below",
"between",
"beyond",
"by",
"down",
"for",
"forth",
"from",
"in",
"into",
"of",
"off",
"on",
"onto",
"out",
"over",
"past",
"round",
"through",
"to",
"together",
"towards",
"under",
"up",
"upon",
"with",
"without",
}
local allowed_non_adverb_words = list_to_set{
"it",
"one",
"oneself",
"someone",
}
local base = pagename
local seen_adverbs = {}
-- Only consider a verb to be phrasal if it consists of a single base verb followed exclusively by either
-- adverbs from `phrasal_adverbs` or placeholder words from `allowed_non_adverb_words`, where at
-- least one following word is from `phrasal_adverbs` (hence [[can it]] is not a phrasal verb).
while true do
local prev, word = base:match("^(.+) (.-)$")
if not prev then
break
end
if phrasal_adverbs[word] then
insert(seen_adverbs, word)
elseif allowed_non_adverb_words[word] then
-- do nothing
else
break
end
base = prev
end
if not base:find(" ") and seen_adverbs[1] then
insert(data.categories, langname .. " phrasal verbs")
for i = #seen_adverbs, 1, -1 do
insert(data.categories, langname .. ' phrasal verbs formed with "' .. seen_adverbs[i] ..
'"')
end
end
end
end,
}
-----------------------------------------------------------------------------------------
-- Suffix forms --
-----------------------------------------------------------------------------------------
pos_functions["suffix forms"] = {
params = {
[1] = {required = true, list = true, disallow_holes = true},
},
func = function(args, data, is_suffix)
local suffix_type = {}
for _, typ in ipairs(args[1]) do
insert(suffix_type, typ .. "-forming suffix")
end
insert(data.inflections, {label = "non-lemma form of " .. m_table.serialCommaJoin(suffix_type, {conj = "or"})})
end,
}
return export
16kpxx6u8rw55bh0m9lw3iuegl8ptae
and
0
8060
54911
54873
2026-09-28T23:24:24Z
Deadend0914
7211
/* Wordstǣr */
54911
wikitext
text/x-wiki
=={{sprǣc|en}}==
===Rihtstefn===
* IPA: /ˈænd
===Wordstǣr===
Of {{inh|en|ang|and}}
===Fégung===
# [[and]]
[[Flocc: Nīwenglisc fégung]]
rwbb8mm31st5hwkem0cg5m9d61hy4pw
Module:etymology/templates
828
8063
54906
54876
2026-09-28T23:20:44Z
Deadend0914
7211
54906
Scribunto
text/plain
local export = {}
local require_when_needed = require("Module:require when needed")
local get_current_L2 = require_when_needed("Module:pages", "get_current_L2")
local get_lang_by_name = require_when_needed("Module:languages", "getByCanonicalName")
local is_content_page = require_when_needed("Module:pages", "is_content_page")
local process_params = require_when_needed("Module:parameters", "process")
local trim = mw.text.trim
local lower = mw.ustring.lower
local etymology_module = "Module:etymology"
local headword_data_module = "Module:headword/data"
local etymology_specialized_module = "Module:etymology/specialized"
local parameter_utilities_module = "Module:parameter utilities"
-- For testing
local force_cat = false
local allowed_conjs = {"and", "or", ",", "/", "~", ";"}
-- Sinitic lects (Mandarin, Cantonese, Hokkien, etc.) are full languages, but Chinese entries sit
-- under a single ==Chinese== L2, while romanization entries (pinyin, jyutping, pe̍h-ōe-jī) have lect
-- L2s, and content is often shared between them. Contact languages (Chinese-based creoles and mixed
-- languages) have their own L2s and are excluded.
local function is_sinitic(lang)
return lang:inFamily("zhx") and not lang:inFamily("qfa-cnt")
end
local content_page
local function is_content_page_cached()
if content_page == nil then
content_page = is_content_page(mw.title.getCurrentTitle())
end
return content_page
end
-- Old English localization: the ==L2== heading is rendered by [[Bysen:sprǣc]] from
-- [[Module:sprǣcnaman]], so the comparison below has to use the same names. The module is
-- optional: if it is missing, the English names are used exactly as before.
local ang_names_module = "Module:sprǣcnaman"
local ang_names
local function get_ang_names()
if ang_names == nil then
local ok, mod = pcall(require, ang_names_module)
ang_names = ok and mod or false
end
return ang_names or nil
end
-- Old English name of the language, or nil.
local function ang_name(lang)
local mod = get_ang_names()
return mod and mod.get_name(lang) or nil
end
-- Code of the language with the given Old English name, or nil.
local function code_of_ang_name(name)
local mod = get_ang_names()
return mod and mod.get_code(name) or nil
end
-- Throw an error if `lang` (the language of the entry) doesn't match
-- the L2 header that the template is invoked under.
local function check_lang_matches_L2(lang, nocat)
if nocat or not lang or lang:getCode() == "und" or (lang.hasType and lang:hasType("family")) then
return
end
local headword_data = mw.loadData(headword_data_module)
if headword_data.large_pages[headword_data.pagename] then
return
end
if not is_content_page_cached() then
return
end
local current_L2 = get_current_L2()
if not current_L2 then
return
end
local full_name = ang_name(lang) or lang:getFullName()
-- Old English localization: also accept an ==L2== heading written with an Old English name.
local L2_code = code_of_ang_name(current_L2)
if full_name == current_L2 or L2_code == lang:getCode() or L2_code == lang:getFullCode() then
return
end
-- Accept any Sinitic language under any Sinitic L2.
if is_sinitic(lang) then
local L2_lang = get_lang_by_name(current_L2)
if L2_lang and is_sinitic(L2_lang) then
return
end
end
local lang_desc = lang:getCode() .. " (" .. (ang_name(lang) or lang:getCanonicalName()) .. ")"
if lang:getFullCode() ~= lang:getCode() then
lang_desc = lang_desc .. ", an etymology-only language whose full language is " ..
lang:getFullCode() .. " (" .. full_name .. ")"
end
-- TODO: translate this message into Old English.
error("Language '" .. lang_desc .. "' does not match the L2 header (" .. current_L2 .. ").")
end
local function parse_etym_args(parent_args, base_params, has_dest_lang)
local m_param_utils = require(parameter_utilities_module)
local param_mods = m_param_utils.construct_param_mods {
{group = {"link", "q", "l", "ref"}},
}
local sourcearg, termarg
if has_dest_lang then
sourcearg, termarg = 2, 3
else
sourcearg, termarg = 1, 2
end
local terms, args = m_param_utils.parse_term_with_inline_modifiers_and_separate_params {
params = base_params,
param_mods = param_mods,
raw_args = parent_args,
termarg = termarg,
track_module = "etymology",
lang = function(args)
return args[sourcearg][#args[sourcearg]]
end,
sc = "sc",
-- Don't do this, doesn't seem to make sense.
-- parse_lang_prefix = true,
make_separate_g_into_list = true,
splitchar = ",",
subitem_param_handling = "last",
}
-- If term param 3= is empty, there will be no terms in terms.terms. To facilitate further code and for
-- compatibility,, insert one. It will display as <small>[Term?]</small>.
if not terms.terms[1] then
terms.terms[1] = {
lang = args[sourcearg][#args[sourcearg]],
sc = args.sc,
}
end
return terms.terms, args
end
function export.parse_2_lang_args(parent_args, has_text, no_family)
local boolean = {type = "boolean"}
local params = {
[1] = {
required = true,
type = "language",
default = "und"
},
[2] = {
required = true,
sublist = true,
type = "language",
family = not no_family,
default = "und"
},
[3] = true,
[4] = {alias_of = "alt"},
[5] = {alias_of = "t"},
["senseid"] = true,
["nocat"] = boolean,
["sort"] = true,
["sourceconj"] = true,
["conj"] = {set = allowed_conjs, default = ","},
}
if has_text then
params["notext"] = boolean
params["nocap"] = boolean
end
local terms, args = parse_etym_args(parent_args, params, "has dest lang")
check_lang_matches_L2(args[1], args.nocat)
return terms, args
end
-- Implementation of deprecated {{etyl}}. Provided to make histories more legible.
function export.etyl(frame)
local params = {
[1] = {required = true, type = "language", default = "und"},
[2] = {type = "language", default = "en"},
["sort"] = {},
}
-- Empty language means English, but "-" means no language. Yes, confusing...
local args = frame:getParent().args
if args[2] and trim(args[2]) == "-" then
params[2] = nil
args = process_params({
[1] = args[1],
["sort"] = args.sort
}, params)
else
args = process_params(args, params)
end
check_lang_matches_L2(args[2])
return require(etymology_module).format_source {
lang = args[2],
source = args[1],
sort_key = args.sort,
force_cat = force_cat,
}
end
-- Implementation of {{derived}}/{{der}}.
function export.derived(frame)
local parent_args = frame:getParent().args
local terms, args = export.parse_2_lang_args(parent_args)
return require(etymology_module).format_derived {
lang = args[1],
sources = args[2],
terms = terms,
sort_key = args.sort,
nocat = args.nocat,
sourceconj = args.sourceconj,
conj = args.conj,
template_name = "derived",
force_cat = force_cat,
}
end
-- Implementation of {{borrowed}}/{{bor}}.
function export.borrowed(frame)
local parent_args = frame:getParent().args
local terms, args = export.parse_2_lang_args(parent_args)
return require(etymology_module).format_borrowed {
lang = args[1],
sources = args[2],
terms = terms,
sort_key = args.sort,
nocat = args.nocat,
sourceconj = args.sourceconj,
conj = args.conj,
force_cat = force_cat,
}
end
function export.inherited(frame)
local parent_args = frame:getParent().args
local terms, args = export.parse_2_lang_args(parent_args)
local sources = args[2]
if sources[2] then
-- Because this doesn't really make sense.
error("[[Template:inherited]] doesn't support multiple comma-separated sources")
end
return require(etymology_module).format_inherited {
lang = args[1],
terms = terms,
sort_key = args.sort,
nocat = args.nocat,
conj = args.conj,
force_cat = force_cat,
}
end
function export.cognate(frame)
local params = {
[1] = {
required = true,
sublist = true,
type = "language",
family = true,
default = "und"
},
[2] = true,
[3] = {alias_of = "alt"},
[4] = {alias_of = "t"},
sourceconj = true,
["conj"] = {set = allowed_conjs, default = ","},
sort = true,
}
local parent_args = frame:getParent().args
local terms, args = parse_etym_args(parent_args, params, false)
return require(etymology_module).format_cognate {
sources = args[1],
terms = terms,
sort_key = args.sort,
sourceconj = args.sourceconj,
conj = args.conj,
force_cat = force_cat,
}
end
function export.noncognate(frame)
return export.cognate(frame)
end
-- Supports various specialized types of borrowings, according to `frame.args.bortype`:
-- "learned" = {{lbor}}/{{learned borrowing}}
-- "semi-learned" = {{slbor}}/{{semi-learned borrowing}}
-- "orthographic" = {{obor}}/{{orthographic borrowing}}
-- "unadapted" = {{ubor}}/{{unadapted borrowing}}
-- "calque" = {{cal}}/{{calque}}
-- "partial-calque" = {{pcal}}/{{partial calque}}
-- "semantic-loan" = {{sl}}/{{semantic loan}}
-- "transliteration" = {{translit}}/{{transliteration}}
-- "phono-semantic-matching" = {{psm}}/{{phono-semantic matching}}
function export.specialized_borrowing(frame)
local parent_args = frame:getParent().args
local terms, args = export.parse_2_lang_args(parent_args, "has text")
local m_etymology_specialized = require(etymology_specialized_module)
return m_etymology_specialized.specialized_borrowing {
bortype = frame.args.bortype,
lang = args[1],
sources = args[2],
terms = terms,
sort_key = args.sort,
nocap = args.nocap,
notext = args.notext,
nocat = args.nocat,
sourceconj = args.sourceconj,
conj = args.conj,
senseid = args.senseid,
force_cat = force_cat,
}
end
-- Implementation of miscellaneous templates such as {{abbrev}}, {{back-formation}}, {{clipping}}, {{ellipsis}},
-- {{rebracketing}} and {{reduplication}} that have a single associated term.
function export.misc_variant(frame)
local iparams = {
["ignore-params"] = true,
text = {required = true},
oftext = true,
cat = {list = true}, -- allow and compress holes
conj = true,
}
local iargs = process_params(frame.args, iparams)
local boolean = {type = "boolean"}
local params = {
[1] = {required = true, type = "language", default = "und"},
[2] = true,
[3] = {alias_of = "alt"},
[4] = {alias_of = "t"},
nocap = boolean, -- should be processed in the template itself
notext = boolean,
nocat = boolean,
conj = {set = allowed_conjs},
sort = true,
}
-- |ignore-params= parameter to module invocation specifies
-- additional parameter names to allow in template invocation, separated by
-- commas. They must consist of ASCII letters or numbers or hyphens.
local ignore_params = iargs["ignore-params"]
if ignore_params then
ignore_params = trim(ignore_params)
if not ignore_params:match("^[%w%-,]+$") then
error("Invalid characters in |ignore-params=: " .. ignore_params:gsub("[%w%-,]+", ""))
end
for param in ignore_params:gmatch("[%w%-]+") do
if params[param] then
error("Duplicate param |" .. param
.. " in |ignore-params=: already specified in params")
end
params[param] = true
end
end
local m_param_utils = require(parameter_utilities_module)
local param_mods = m_param_utils.construct_param_mods {
{group = {"link", "q", "l", "ref"}},
}
local parent_args = frame:getParent().args
local terms, args = m_param_utils.parse_term_with_inline_modifiers_and_separate_params {
params = params,
param_mods = param_mods,
raw_args = parent_args,
termarg = 2,
track_module = "etymology",
-- Don't set lang here as we want to know whether there was a lang prefix or not.
sc = "sc",
parse_lang_prefix = true,
allow_multiple_lang_prefixes = true,
make_separate_g_into_list = true,
splitchar = ",",
subitem_param_handling = "last",
}
check_lang_matches_L2(args[1], args.nocat)
return require(etymology_module).format_misc_variant {
lang = args[1],
notext = args.notext,
text = iargs.text,
oftext = iargs.oftext,
terms = terms.terms,
sort_key = args.sort,
conj = args.conj or iargs.conj or "and",
nocat = args.nocat,
cats = iargs.cat,
force_cat = force_cat,
}
end
-- Implementation of miscellaneous templates such as {{doublet}} that can take multiple terms. Doesn't handle {{blend}}
-- or {{univerbation}}, which display + signs between elements and use compound_like in [[Module:affix/templates]].
function export.misc_variant_multiple_terms(frame)
local iparams = {
text = {required = true},
oftext = true,
cat = {list = true}, -- allow and compress holes
conj = true,
}
local iargs = process_params(frame.args, iparams)
local boolean = {type = "boolean"}
local params = {
[1] = {required = true, type = "language", template_default = "und"},
[2] = {list = true, allow_holes = true},
nocap = boolean, -- should be processed in the template itself
notext = boolean,
nocat = boolean,
conj = {set = allowed_conjs},
sort = true,
}
local m_param_utils = require(parameter_utilities_module)
local param_mods = m_param_utils.construct_param_mods {
-- We want to require an index for all params.
{default = true, require_index = true},
{group = {"link", "q", "l", "ref"}},
}
local parent_args = frame:getParent().args
local terms, args = m_param_utils.parse_list_with_inline_modifiers_and_separate_params {
params = params,
param_mods = param_mods,
raw_args = parent_args,
termarg = 2,
parse_lang_prefix = true,
allow_multiple_lang_prefixes = true,
track_module = "etymology-templates-doublet",
disallow_custom_separators = true,
-- For compatibility, we need to not skip completely unspecified items. It is common, for example, to do
-- {{suffix|lang||foo}} to generate "+ -foo".
dont_skip_items = true,
-- Don't set lang here as we want to know whether there was a lang prefix or not.
sc = "sc.default",
}
check_lang_matches_L2(args[1], args.nocat)
return require(etymology_module).format_misc_variant {
lang = args[1],
notext = args.notext,
text = iargs.text,
oftext = iargs.oftext,
terms = terms,
sort_key = args.sort,
conj = args.conj or iargs.conj or "and",
nocat = args.nocat,
cats = iargs.cat,
force_cat = force_cat,
}
end
-- Implementation of miscellaneous templates such as {{unknown}} that have no associated terms.
do
local function get_args(frame)
local boolean = {type = "boolean"}
local params = {
[1] = {required = true, type = "language", default = "und"},
["title"] = true,
["nocap"] = boolean, -- should be processed in the template itself
["notext"] = boolean,
["nocat"] = boolean,
["sort"] = true,
}
if frame.args.title2_alias then
params[2] = {alias_of = "title"}
end
local args = process_params(frame:getParent().args, params)
check_lang_matches_L2(args[1], args.nocat)
return args
end
function export.misc_variant_no_term(frame)
local args = get_args(frame)
return require(etymology_module).format_misc_variant_no_term {
lang = args[1],
notext = args.notext,
title = args.title or frame.args.text,
nocat = args.nocat,
cat = frame.args.cat,
sort_key = args.sort,
force_cat = force_cat,
}
end
-- This function works similarly to misc_variant_no_term(), but with some automatic linking to the glossary in
-- `title`.
function export.onomatopoeia(frame)
local args = get_args(frame)
local title = args.title
if title and (lower(title) == "imitative" or lower(title) == "imitation") then
title = "[[Appendix:Glossary#imitative|" .. title .. "]]"
end
return require(etymology_module).format_misc_variant_no_term {
lang = args[1],
notext = args.notext,
title = title or frame.args.text,
nocat = args.nocat,
cat = frame.args.cat,
sort_key = args.sort,
force_cat = force_cat,
}
end
end
return export
syg6utaikdtm1mu22f7fk80qw5zgk37
Module:etymology
828
8064
54905
54877
2026-09-28T23:20:13Z
Deadend0914
7211
54905
Scribunto
text/plain
local export = {}
-- For testing
local force_cat = false
local debug_track_module = "Module:debug/track"
local languages_module = "Module:languages"
local links_module = "Module:links"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local concat = table.concat
local insert = table.insert
local new_title = mw.title.new
local function debug_track(...)
debug_track = require(debug_track_module)
return debug_track(...)
end
local function format_categories(...)
format_categories = require(utilities_module).format_categories
return format_categories(...)
end
local function full_link(...)
full_link = require(links_module).full_link
return full_link(...)
end
local function get_language_data_module_name(...)
get_language_data_module_name = require(languages_module).getDataModuleName
return get_language_data_module_name(...)
end
local function get_link_page(...)
get_link_page = require(links_module).get_link_page
return get_link_page(...)
end
local function language_link(...)
language_link = require(links_module).language_link
return language_link(...)
end
local function serial_comma_join(...)
serial_comma_join = require(table_module).serialCommaJoin
return serial_comma_join(...)
end
local function shallow_copy(...)
shallow_copy = require(table_module).shallowCopy
return shallow_copy(...)
end
-- Old English localization: language names come from [[Module:sprǣcnaman]], which is also what
-- [[Bysen:sprǣc]] (the ==L2== heading template) uses, so headings, wordstǣr lines and categories
-- can never disagree with each other. The module is optional: if it is missing, the English names
-- are used exactly as before.
local ang_names_module = "Module:sprǣcnaman"
local ang_names
local function get_ang_names()
if ang_names == nil then
local ok, mod = pcall(require, ang_names_module)
ang_names = ok and mod or false
end
return ang_names or nil
end
-- Old English name of the language, or nil.
local function ang_name(lang)
local mod = get_ang_names()
return mod and mod.get_name(lang) or nil
end
-- Old English "of"-form of the language, or nil.
local function ang_of(lang)
local mod = get_ang_names()
return mod and mod.get_of(lang) or nil
end
-- Replace the visible text of a language link, e.g. "[[w:Old English|Old English]]" -> "Englisce",
-- keeping the link target.
local function replace_display(display, text)
local target = display:match("^%[%[(.-)|.-%]%]$")
if target then
return "[[" .. target .. "|" .. text .. "]]"
end
return text
end
-- Localized display text and category name for a source language. Returns nil when the language has
-- no Old English name, in which case the original English name is used.
local function ang_display_and_cat_name(source, raw)
local name = ang_name(source)
if not name then
return nil
end
local display
if raw then
display = name
else
display = replace_display(source:makeWikipediaLink(), ang_of(source) or name)
end
return display, name
end
local function track(page, code)
local tracking_page = "etymology/" .. page
debug_track(tracking_page)
if code then
debug_track(tracking_page .. "/" .. code)
end
end
local function join_segs(segs, conj)
if not segs[2] then
return segs[1]
elseif conj == "and" or conj == "or" then
return serial_comma_join(segs, {conj = conj})
end
local sep
if conj == "," or conj == ";" then
sep = conj .. " "
elseif conj == "/" then
sep = "/"
elseif conj == "~" then
sep = " ~ "
elseif conj then
error(("Internal error: Unrecognized conjunction \"%s\""):format(conj))
else
error(("Internal error: No value supplied for conjunction"):format(conj))
end
return concat(segs, sep)
end
-- Returns true if `lang` is the same as `source`, or a variety of it.
local function lang_is_source(lang, source)
return lang:getCode() == source:getCode() or lang:hasParent(source)
end
--[==[
Format one or more links as specified in `termobjs`, a list of term objects of the format accepted by `full_link()` in
[[Module:links]], including decorations (qualifiers, labels and references). `conj` is used to join multiple terms
and must be specified if there is more than one term. `template_name` is the template name used in debug tracking and
must be specified. Optional `sourcetext` is text to prepend to the concatenated terms, separated by a space if the
concatenated terms are non-empty (which is always the case unless there is a single term with the value "-"). If
`decorations_on_outside` is given, any decorations specified in the first term go on the outside of (i.e before)
`sourcetext`; otherwise they will end up on the inside.
]==]
function export.format_links(termobjs, conj, template_name, sourcetext, decorations_on_outside)
if not template_name then
error("Internal error: Must specify `template_name` to format_links()")
end
for i, termobj in ipairs(termobjs) do
if termobj.lang:hasType("family") or termobj.lang:getFamilyCode() == "qfa-sub" then
if termobj.term and termobj.term ~= "-" then
debug_track(template_name .. "/family-with-term")
end
termobj.term = "-"
end
if termobj.term == "-" then
--[=[
[[Special:WhatLinksHere/Wiktionary:Tracking/cognate/no-term]]
[[Special:WhatLinksHere/Wiktionary:Tracking/derived/no-term]]
[[Special:WhatLinksHere/Wiktionary:Tracking/borrowed/no-term]]
[[Special:WhatLinksHere/Wiktionary:Tracking/calque/no-term]]
]=]
debug_track(template_name .. "/no-term")
termobjs[i] = i == 1 and sourcetext or ""
else
if i == 1 and decorations_on_outside and sourcetext then
termobj.pretext = sourcetext .. " "
sourcetext = nil
end
termobjs[i] = (i == 1 and sourcetext and sourcetext .. " " or "") .. full_link(termobj, "term")
end
end
return join_segs(termobjs, conj)
end
function export.get_display_and_cat_name(source, raw)
local display, cat_name
if source:getCode() == "und" then
display = "undetermined"
cat_name = "other languages"
elseif source:getCode() == "mul" then
display = raw and "translingual" or "[[w:Translingualism|translingual]]"
cat_name = "Translingual"
elseif source:getCode() == "mul-tax" then
display = raw and "taxonomic name" or "[[w:Biological nomenclature|taxonomic name]]"
cat_name = "taxonomic names"
else
-- Old English localization: use the "of"-form of the name, e.g. "Of Englisce and".
local ang_display, ang_cat_name = ang_display_and_cat_name(source, raw)
display = ang_display or raw and source:getCanonicalName() or source:makeWikipediaLink()
cat_name = ang_cat_name or source:getDisplayForm()
end
return display, cat_name
end
function export.insert_source_cat_get_display(data)
local categories, lang, source = data.categories, data.lang, data.source
local display, cat_name = export.get_display_and_cat_name(source, data.raw)
if lang and not data.nocat then
-- Add the category, but only if there is a current language
if not categories then
categories = {}
end
local langname = ang_name(lang) or lang:getFullName()
-- If `lang` is an etym-only language, we need to check both it and its parent full language against `source`.
-- Otherwise if e.g. `lang` is Medieval Latin and `source` is Latin, we'll end up wrongly constructing a
-- category 'Latin terms derived from Latin'.
insert(categories, langname .. (
lang_is_source(lang, source) and " terms borrowed back into " .. cat_name or
" " .. (data.borrowing_type or "terms derived") .. " from " .. cat_name
))
end
return display, categories
end
function export.format_source(data)
local lang, sort_key = data.lang, data.sort_key
-- [[Special:WhatLinksHere/Wiktionary:Tracking/etymology/sortkey]]
if sort_key then
track("sortkey")
end
local display, categories = export.insert_source_cat_get_display(data)
if lang and not data.nocat then
-- Format categories, but only if there is a current language; {{cog}} currently gets no categories
categories = format_categories(categories, lang, sort_key, nil, data.force_cat or force_cat)
else
categories = ""
end
return "<span class=\"etyl\">" .. display .. categories .. "</span>"
end
--[==[
Format sources for etymology templates such as {{tl|bor}}, {{tl|der}}, {{tl|inh}} and {{tl|cog}}. There may potentially
be more than one source language (except currently {{tl|inh}}, which doesn't support it because it doesn't really
make sense). In that case, all but the last source language is linked to the first term, but only if there is such a
term and this linking makes sense, i.e. either (1) the term page exists after stripping diacritics according to the
source language in question, or (2) the result of stripping diacritics according to the source language in question
results in a different page from the same process applied with the last source language. For example, {{m|ru|соля́нка}}
will link to [[солянка]] but {{m|en|соля́нка}} will link to [[соля́нка]] with an accent, and since they are different
pages, the use of English as a non-final source with term 'соля́нка' will link to [[соля́нка]] even though it doesn't
exist, on the assumption that it is merely a redlink that might exist. If none of the above criteria apply, a non-final
source language will be linked to the Wikipedia entry for the language, just as final source languages always are.
`data` contains the following fields:
* `lang`: The destination language object into which the terms were borrowed, inherited or otherwise derived. Used for
categorization and can be nil, as with {{tl|cog}}.
* `sources`: List of source objects. Most commonly there is only one. If there are multiple, the non-final ones are
handled specially; see above.
* `terms`: List of term objects. Most commonly there is only one. If there are multiple source objects as well as
multiple term objects, the non-final source objects link to the first term object.
* `sort_key`: Sort key for categories. Usually nil.
* `categories`: Categories to add to the page. Additional categories may be added to `categories` based on the source
languages ('''in which case `categories` is destructively modified'''). If `lang` is nil, no categories will be
added.
* `nocat`: Don't add any categories to the page.
* `sourceconj`: Conjunction used to separate multiple source languages. Defaults to {"and"}. Currently recognized
values are `and`, `or`, `,`, `;`, `/` and `~`.
* `borrowing_type`: Borrowing type used in categories, such as {"learned borrowings"}. Defaults to {"terms derived"}.
* `force_cat`: Force category generation on non-mainspace pages.
]==]
function export.format_sources(data)
local lang, sources, terms, borrowing_type, sort_key, categories, nocat =
data.lang, data.sources, data.terms, data.borrowing_type, data.sort_key, data.categories, data.nocat
local term1, sources_n, source_segs = terms[1], #sources, {}
local final_link_page
local term1_term, term1_sc = term1.term, term1.sc
if sources_n > 1 and term1_term and term1_term ~= "-" then
final_link_page = get_link_page(term1_term, sources[sources_n], term1_sc)
end
for i, source in ipairs(sources) do
local seg, display_term
if i < sources_n and term1_term and term1_term ~= "-" then
local link_page = get_link_page(term1_term, source, term1_sc)
display_term = (link_page ~= final_link_page) or (link_page and not not new_title(link_page):getContent())
end
-- TODO: if the display forms or transliterations are different, display the terms separately.
if display_term then
local display, this_cats = export.insert_source_cat_get_display{
lang = lang,
source = source,
borrowing_type = borrowing_type,
raw = true,
categories = categories,
nocat = nocat,
}
seg = language_link {
lang = source,
term = term1_term,
alt = display,
tr = "-",
}
if lang and not nocat then
-- Format categories, but only if there is a current language; {{cog}} currently gets no categories
this_cats = format_categories(this_cats, lang, sort_key, nil, data.force_cat or force_cat)
else
this_cats = ""
end
seg = "<span class=\"etyl\">" .. seg .. this_cats .. "</span>"
else
seg = export.format_source{
lang = lang,
source = source,
borrowing_type = borrowing_type,
sort_key = sort_key,
categories = categories,
nocat = nocat,
}
end
insert(source_segs, seg)
end
return join_segs(source_segs, data.sourceconj or "and")
end
-- Internal implementation of {{cognate}}/{{cog}} template.
function export.format_cognate(data)
return export.format_derived {
sources = data.sources,
terms = data.terms,
sort_key = data.sort_key,
sourceconj = data.sourceconj,
conj = data.conj,
template_name = "cognate",
force_cat = data.force_cat,
}
end
--[==[
Internal implementation of {{derived}}/{{der}} template. This is called externally from [[Module:affix]],
[[Module:affixusex]] and [[Module:see]] and needs to support decorations (qualifiers, labels and references) on the
outside of the sources for use by those modules.
`data` contains the following fields:
* `lang`: The destination language object into which the terms were derived. Used for categorization and can be nil, as
with {{tl|cog}}; in this case, no categories are added.
* `sources`: List of source objects. Most commonly there is only one. If there are multiple, the non-final ones are
handled specially; see `format_sources()`.
* `terms`: List of term objects. Most commonly there is only one. If there are multiple source objects as well as
multiple term objects, the non-final source objects link to the first term object.
* `conj`: Conjunction used to separate multiple terms. '''Required'''. Currently recognized values are `and`, `or`, `,`,
`;`, `/` and `~`.
* `sourceconj`: Conjunction used to separate multiple source languages. Defaults to {"and"}. Currently recognized
values are as for `conj` above.
* `decorations_on_outside`: If specified, any decorations (qualifiers, labels or references) in the first term in
`terms` will be displayed on the outside of (before) the source language(s) in `sources`. Normally this should be
specified if there is only one term possible in `terms`.
* `template_name`: Name of the template invoking this function. Must be specified. Only used for tracking pages.
* `sort_key`: Sort key for categories. Usually nil.
* `categories`: Categories to add to the page. Additional categories may be added to `categories` based on the source
languages ('''in which case `categories` is destructively modified'''). If `lang` is nil, no categories will be
added.
* `nocat`: Don't add any categories to the page.
* `borrowing_type`: Borrowing type used in categories, such as {"learned borrowings"}. Defaults to {"terms derived"}.
* `force_cat`: Force category generation on non-mainspace pages.
]==]
function export.format_derived(data)
local terms = data.terms
local sourcetext = export.format_sources(data)
return export.format_links(terms, data.conj, data.template_name, sourcetext, data.decorations_on_outside)
end
function export.insert_borrowed_cat(categories, lang, source)
if lang_is_source(lang, source) then
return
end
-- If both are the same, we want e.g. [[:Category:English terms borrowed back into English]] not
-- [[:Category:English terms borrowed from English]]; the former is inserted automatically by format_source().
-- The second parameter here doesn't matter as it only affects `display`, which we don't use.
insert(categories, (ang_name(lang) or lang:getFullName()) .. " terms borrowed from " .. select(2, export.get_display_and_cat_name(source, "raw")))
end
-- Internal implementation of {{borrowed}}/{{bor}} template.
function export.format_borrowed(data)
local categories = {}
if not data.nocat then
local lang = data.lang
for _, source in ipairs(data.sources) do
export.insert_borrowed_cat(categories, lang, source)
end
end
data = shallow_copy(data)
data.categories = categories
return export.format_links(data.terms, data.conj, "borrowed", export.format_sources(data))
end
do
-- Generate the non-ancestor error message.
local function show_language(lang)
local retval = ("%s (%s)"):format(lang:makeCategoryLink(), lang:getCode())
if lang:hasType("etymology-only") then
retval = retval .. (" (an etymology-only language whose regular parent is %s)"):format(
show_language(lang:getParent()))
end
return retval
end
-- Check that `lang` has `otherlang` (which may be an etymology-only language) as an ancestor. Throw an error if
-- not. When `lang` is a family, verifies that `otherlang` is a language in that family.
function export.check_ancestor(lang, otherlang)
-- When `lang` is a family, verify `otherlang` is in that family or in its parent family.
if lang.hasType and lang:hasType("family") then
local family_code = lang:getCode()
local function in_family_code(fcode, other)
if not fcode or fcode == "" then return false end
if other.inFamily and other:inFamily(fcode) then return true end
if other.getFamilyCode and other:getFamilyCode() == fcode then return true end
return false
end
local in_family = in_family_code(family_code, otherlang)
if not in_family then
local parent_code
if lang.getParent then
local parent_family = lang:getParent()
if parent_family and parent_family.getCode then
parent_code = parent_family:getCode()
end
end
if not parent_code and family_code:find("-", 1, true) then
parent_code = family_code:match("^(.+)-[^-]+$")
end
if parent_code then
in_family = in_family_code(parent_code, otherlang)
end
end
if not in_family then
local other_display = (otherlang.getCanonicalName and otherlang:getCanonicalName()) or (otherlang.getCode and otherlang:getCode()) or tostring(otherlang)
local fam_display = (lang.getCanonicalName and lang:getCanonicalName()) or family_code
error(("%s is not in family %s; inherited ancestor under a family must be a language in that family or its parent family.")
:format(other_display, fam_display))
end
return
end
-- FIXME: I don't know if this function works correctly with etym-only languages in `lang`. I have fixed up
-- the module link code appropriately (June 2024) but the remaining logic is untouched.
if lang:hasAncestor(otherlang) then
-- [[Special:WhatLinksHere/Wiktionary:Tracking/etymology/variety]]
-- Track inheritance from varieties of Latin that shouldn't have any descendants (everything except Old Latin, Classical Latin and Vulgar Latin).
if otherlang:getFullCode() == "la" then
otherlang = otherlang:getCode()
if not (otherlang == "itc-ola" or otherlang == "la-cla" or otherlang == "la-vul") then
track("bad ancestor", otherlang)
end
end
return
end
local ancestors = lang:getAncestors()
local postscript
local etym_module_link = lang:hasType("etymology-only") and "[[Module:etymology languages/data]] or " or ""
local module_link = "[[" .. get_language_data_module_name(lang:getFullCode()) .. "]]"
if not ancestors[1] then
postscript = show_language(lang) .. " has no ancestors."
else
local ancestor_list = {}
for _, ancestor in ipairs(ancestors) do
insert(ancestor_list, show_language(ancestor))
end
postscript = ("The ancestor%s of %s %s %s."):format(
ancestors[2] and "s" or "", lang:getCanonicalName(),
ancestors[2] and "are" or "is", concat(ancestor_list, " and "))
end
error(("%s is not set as an ancestor of %s in %s%s. %s")
:format(show_language(otherlang), show_language(lang), etym_module_link, module_link, postscript))
end
end
-- Internal implementation of {{inherited}}/{{inh}} template.
function export.format_inherited(data)
local lang, terms, nocat = data.lang, data.terms, data.nocat
local source = terms[1].lang
local categories = {}
if not nocat then
insert(categories, (ang_name(lang) or lang:getFullName()) .. " terms inherited from " .. (ang_name(source) or source:getCanonicalName()))
end
export.check_ancestor(lang, source)
data = shallow_copy(data)
data.categories = categories
data.source = source
return export.format_links(terms, data.conj, "inherited", export.format_source(data))
end
-- Internal implementation of "misc variant" templates such as {{abbrev}}, {{clipping}}, {{reduplication}} and the like.
function export.format_misc_variant(data)
local lang, notext, terms, cats, parts = data.lang, data.notext, data.terms, data.cats, {}
if not notext then
insert(parts, data.text)
end
if terms[1] then
if not notext then
-- FIXME: If term is given as '-', we should consider displaying just "Clipping" not "Clipping of".
insert(parts, " " .. (data.oftext or "of"))
end
local termparts = {}
-- Make links out of all the parts.
for _, termobj in ipairs(terms) do
local result
if termobj.lang then
result = export.format_derived {
lang = lang,
terms = {termobj},
sources = termobj.termlangs or {termobj.lang},
template_name = "misc_variant",
decorations_on_outside = true,
force_cat = data.force_cat,
}
else
termobj.lang = lang
result = export.format_links({termobj}, nil, "misc_variant")
end
table.insert(termparts, result)
end
local linktext = join_segs(termparts, data.conj)
if not notext and linktext ~= "" then
insert(parts, " ")
end
insert(parts, linktext)
end
local categories = {}
if not data.nocat and cats then
for _, cat in ipairs(cats) do
insert(categories, (ang_name(lang) or lang:getFullName()) .. " " .. cat)
end
end
if categories[1] then
insert(parts, format_categories(categories, lang, data.sort_key, nil, data.force_cat or force_cat))
end
return concat(parts)
end
-- Implementation of miscellaneous templates such as {{unknown}} and {{onomatopoeia}} that have no associated terms.
function export.format_misc_variant_no_term(data)
local parts = {}
if not data.notext then
insert(parts, data.title)
end
if not data.nocat and data.cat then
local lang, categories = data.lang, {}
insert(categories, (ang_name(lang) or lang:getFullName()) .. " " .. data.cat)
insert(parts, format_categories(categories, lang, data.sort_key, nil, data.force_cat or force_cat))
end
return concat(parts)
end
return export
tme5lnxmobc95ub37jg1tqwmk1tlre9
54922
54905
2026-09-29T00:03:01Z
Deadend0914
7211
54922
Scribunto
text/plain
local export = {}
-- For testing
local force_cat = false
local debug_track_module = "Module:debug/track"
local languages_module = "Module:languages"
local links_module = "Module:links"
local table_module = "Module:table"
local utilities_module = "Module:utilities"
local concat = table.concat
local insert = table.insert
local new_title = mw.title.new
local function debug_track(...)
debug_track = require(debug_track_module)
return debug_track(...)
end
local function format_categories(...)
format_categories = require(utilities_module).format_categories
return format_categories(...)
end
local function full_link(...)
full_link = require(links_module).full_link
return full_link(...)
end
local function get_language_data_module_name(...)
get_language_data_module_name = require(languages_module).getDataModuleName
return get_language_data_module_name(...)
end
local function get_link_page(...)
get_link_page = require(links_module).get_link_page
return get_link_page(...)
end
local function language_link(...)
language_link = require(links_module).language_link
return language_link(...)
end
local function serial_comma_join(...)
serial_comma_join = require(table_module).serialCommaJoin
return serial_comma_join(...)
end
local function shallow_copy(...)
shallow_copy = require(table_module).shallowCopy
return shallow_copy(...)
end
-- Old English localization: language names come from [[Module:sprǣcnaman]], which is also what
-- [[Bysen:sprǣc]] (the ==L2== heading template) uses, so headings, wordstǣr lines and categories
-- can never disagree with each other. The module is optional: if it is missing, the English names
-- are used exactly as before.
local ang_names_module = "Module:sprǣcnaman"
local ang_names
local function get_ang_names()
if ang_names == nil then
local ok, mod = pcall(require, ang_names_module)
ang_names = ok and mod or false
end
return ang_names or nil
end
-- Old English name of the language, or nil.
local function ang_name(lang)
local mod = get_ang_names()
return mod and mod.get_name(lang) or nil
end
-- Old English "of"-form of the language, or nil.
local function ang_of(lang)
local mod = get_ang_names()
return mod and mod.get_of(lang) or nil
end
-- Replace the visible text of a language link, e.g. "[[w:Old English|Old English]]" -> "Englisce",
-- keeping the link target.
local function replace_display(display, text)
local target = display:match("^%[%[(.-)|.-%]%]$")
if target then
return "[[" .. target .. "|" .. text .. "]]"
end
return text
end
-- Localized display text and category name for a source language. Returns nil when the language has
-- no Old English name, in which case the original English name is used.
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
local function ang_display_and_cat_name(source, raw)
local name = ang_name(source)
if not name then
return nil
end
local display
if raw then
display = name
else
display = replace_display(source:makeWikipediaLink(), ang_of(source) or name)
end
return display, name
end
local function track(page, code)
local tracking_page = "etymology/" .. page
debug_track(tracking_page)
if code then
debug_track(tracking_page .. "/" .. code)
end
end
local function join_segs(segs, conj)
if not segs[2] then
return segs[1]
elseif conj == "and" or conj == "or" then
return serial_comma_join(segs, {conj = conj})
end
local sep
if conj == "," or conj == ";" then
sep = conj .. " "
elseif conj == "/" then
sep = "/"
elseif conj == "~" then
sep = " ~ "
elseif conj then
error(("Internal error: Unrecognized conjunction \"%s\""):format(conj))
else
error(("Internal error: No value supplied for conjunction"):format(conj))
end
return concat(segs, sep)
end
-- Returns true if `lang` is the same as `source`, or a variety of it.
local function lang_is_source(lang, source)
return lang:getCode() == source:getCode() or lang:hasParent(source)
end
--[==[
Format one or more links as specified in `termobjs`, a list of term objects of the format accepted by `full_link()` in
[[Module:links]], including decorations (qualifiers, labels and references). `conj` is used to join multiple terms
and must be specified if there is more than one term. `template_name` is the template name used in debug tracking and
must be specified. Optional `sourcetext` is text to prepend to the concatenated terms, separated by a space if the
concatenated terms are non-empty (which is always the case unless there is a single term with the value "-"). If
`decorations_on_outside` is given, any decorations specified in the first term go on the outside of (i.e before)
`sourcetext`; otherwise they will end up on the inside.
]==]
function export.format_links(termobjs, conj, template_name, sourcetext, decorations_on_outside)
if not template_name then
error("Internal error: Must specify `template_name` to format_links()")
end
for i, termobj in ipairs(termobjs) do
if termobj.lang:hasType("family") or termobj.lang:getFamilyCode() == "qfa-sub" then
if termobj.term and termobj.term ~= "-" then
debug_track(template_name .. "/family-with-term")
end
termobj.term = "-"
end
if termobj.term == "-" then
--[=[
[[Special:WhatLinksHere/Wiktionary:Tracking/cognate/no-term]]
[[Special:WhatLinksHere/Wiktionary:Tracking/derived/no-term]]
[[Special:WhatLinksHere/Wiktionary:Tracking/borrowed/no-term]]
[[Special:WhatLinksHere/Wiktionary:Tracking/calque/no-term]]
]=]
debug_track(template_name .. "/no-term")
termobjs[i] = i == 1 and sourcetext or ""
else
if i == 1 and decorations_on_outside and sourcetext then
termobj.pretext = sourcetext .. " "
sourcetext = nil
end
termobjs[i] = (i == 1 and sourcetext and sourcetext .. " " or "") .. full_link(termobj, "term")
end
end
return join_segs(termobjs, conj)
end
function export.get_display_and_cat_name(source, raw)
local display, cat_name
if source:getCode() == "und" then
display = "undetermined"
cat_name = cat_word(source, "other languages")
elseif source:getCode() == "mul" then
display = raw and "translingual" or "[[w:Translingualism|translingual]]"
cat_name = cat_word(source, "Translingual")
elseif source:getCode() == "mul-tax" then
display = raw and "taxonomic name" or "[[w:Biological nomenclature|taxonomic name]]"
cat_name = cat_word(source, "taxonomic names")
else
-- Old English localization: use the "of"-form of the name, e.g. "Of Englisce and".
local ang_display, ang_cat_name = ang_display_and_cat_name(source, raw)
display = ang_display or raw and source:getCanonicalName() or source:makeWikipediaLink()
cat_name = ang_cat_name or source:getDisplayForm()
end
return display, cat_name
end
function export.insert_source_cat_get_display(data)
local categories, lang, source = data.categories, data.lang, data.source
local display, cat_name = export.get_display_and_cat_name(source, data.raw)
if lang and not data.nocat then
-- Add the category, but only if there is a current language
if not categories then
categories = {}
end
local langname = ang_name(lang) or lang:getFullName()
-- If `lang` is an etym-only language, we need to check both it and its parent full language against `source`.
-- Otherwise if e.g. `lang` is Medieval Latin and `source` is Latin, we'll end up wrongly constructing a
-- category 'Latin terms derived from Latin'.
insert(categories, langname .. (
lang_is_source(lang, source) and (" " .. cat_word(lang, "terms borrowed back into") .. " " .. cat_name) or
" " .. cat_word(lang, data.borrowing_type or "terms derived") .. " " .. cat_word(lang, "from") .. " " .. cat_name
))
end
return display, categories
end
function export.format_source(data)
local lang, sort_key = data.lang, data.sort_key
-- [[Special:WhatLinksHere/Wiktionary:Tracking/etymology/sortkey]]
if sort_key then
track("sortkey")
end
local display, categories = export.insert_source_cat_get_display(data)
if lang and not data.nocat then
-- Format categories, but only if there is a current language; {{cog}} currently gets no categories
categories = format_categories(categories, lang, sort_key, nil, data.force_cat or force_cat)
else
categories = ""
end
return "<span class=\"etyl\">" .. display .. categories .. "</span>"
end
--[==[
Format sources for etymology templates such as {{tl|bor}}, {{tl|der}}, {{tl|inh}} and {{tl|cog}}. There may potentially
be more than one source language (except currently {{tl|inh}}, which doesn't support it because it doesn't really
make sense). In that case, all but the last source language is linked to the first term, but only if there is such a
term and this linking makes sense, i.e. either (1) the term page exists after stripping diacritics according to the
source language in question, or (2) the result of stripping diacritics according to the source language in question
results in a different page from the same process applied with the last source language. For example, {{m|ru|соля́нка}}
will link to [[солянка]] but {{m|en|соля́нка}} will link to [[соля́нка]] with an accent, and since they are different
pages, the use of English as a non-final source with term 'соля́нка' will link to [[соля́нка]] even though it doesn't
exist, on the assumption that it is merely a redlink that might exist. If none of the above criteria apply, a non-final
source language will be linked to the Wikipedia entry for the language, just as final source languages always are.
`data` contains the following fields:
* `lang`: The destination language object into which the terms were borrowed, inherited or otherwise derived. Used for
categorization and can be nil, as with {{tl|cog}}.
* `sources`: List of source objects. Most commonly there is only one. If there are multiple, the non-final ones are
handled specially; see above.
* `terms`: List of term objects. Most commonly there is only one. If there are multiple source objects as well as
multiple term objects, the non-final source objects link to the first term object.
* `sort_key`: Sort key for categories. Usually nil.
* `categories`: Categories to add to the page. Additional categories may be added to `categories` based on the source
languages ('''in which case `categories` is destructively modified'''). If `lang` is nil, no categories will be
added.
* `nocat`: Don't add any categories to the page.
* `sourceconj`: Conjunction used to separate multiple source languages. Defaults to {"and"}. Currently recognized
values are `and`, `or`, `,`, `;`, `/` and `~`.
* `borrowing_type`: Borrowing type used in categories, such as {"learned borrowings"}. Defaults to {"terms derived"}.
* `force_cat`: Force category generation on non-mainspace pages.
]==]
function export.format_sources(data)
local lang, sources, terms, borrowing_type, sort_key, categories, nocat =
data.lang, data.sources, data.terms, data.borrowing_type, data.sort_key, data.categories, data.nocat
local term1, sources_n, source_segs = terms[1], #sources, {}
local final_link_page
local term1_term, term1_sc = term1.term, term1.sc
if sources_n > 1 and term1_term and term1_term ~= "-" then
final_link_page = get_link_page(term1_term, sources[sources_n], term1_sc)
end
for i, source in ipairs(sources) do
local seg, display_term
if i < sources_n and term1_term and term1_term ~= "-" then
local link_page = get_link_page(term1_term, source, term1_sc)
display_term = (link_page ~= final_link_page) or (link_page and not not new_title(link_page):getContent())
end
-- TODO: if the display forms or transliterations are different, display the terms separately.
if display_term then
local display, this_cats = export.insert_source_cat_get_display{
lang = lang,
source = source,
borrowing_type = borrowing_type,
raw = true,
categories = categories,
nocat = nocat,
}
seg = language_link {
lang = source,
term = term1_term,
alt = display,
tr = "-",
}
if lang and not nocat then
-- Format categories, but only if there is a current language; {{cog}} currently gets no categories
this_cats = format_categories(this_cats, lang, sort_key, nil, data.force_cat or force_cat)
else
this_cats = ""
end
seg = "<span class=\"etyl\">" .. seg .. this_cats .. "</span>"
else
seg = export.format_source{
lang = lang,
source = source,
borrowing_type = borrowing_type,
sort_key = sort_key,
categories = categories,
nocat = nocat,
}
end
insert(source_segs, seg)
end
return join_segs(source_segs, data.sourceconj or "and")
end
-- Internal implementation of {{cognate}}/{{cog}} template.
function export.format_cognate(data)
return export.format_derived {
sources = data.sources,
terms = data.terms,
sort_key = data.sort_key,
sourceconj = data.sourceconj,
conj = data.conj,
template_name = "cognate",
force_cat = data.force_cat,
}
end
--[==[
Internal implementation of {{derived}}/{{der}} template. This is called externally from [[Module:affix]],
[[Module:affixusex]] and [[Module:see]] and needs to support decorations (qualifiers, labels and references) on the
outside of the sources for use by those modules.
`data` contains the following fields:
* `lang`: The destination language object into which the terms were derived. Used for categorization and can be nil, as
with {{tl|cog}}; in this case, no categories are added.
* `sources`: List of source objects. Most commonly there is only one. If there are multiple, the non-final ones are
handled specially; see `format_sources()`.
* `terms`: List of term objects. Most commonly there is only one. If there are multiple source objects as well as
multiple term objects, the non-final source objects link to the first term object.
* `conj`: Conjunction used to separate multiple terms. '''Required'''. Currently recognized values are `and`, `or`, `,`,
`;`, `/` and `~`.
* `sourceconj`: Conjunction used to separate multiple source languages. Defaults to {"and"}. Currently recognized
values are as for `conj` above.
* `decorations_on_outside`: If specified, any decorations (qualifiers, labels or references) in the first term in
`terms` will be displayed on the outside of (before) the source language(s) in `sources`. Normally this should be
specified if there is only one term possible in `terms`.
* `template_name`: Name of the template invoking this function. Must be specified. Only used for tracking pages.
* `sort_key`: Sort key for categories. Usually nil.
* `categories`: Categories to add to the page. Additional categories may be added to `categories` based on the source
languages ('''in which case `categories` is destructively modified'''). If `lang` is nil, no categories will be
added.
* `nocat`: Don't add any categories to the page.
* `borrowing_type`: Borrowing type used in categories, such as {"learned borrowings"}. Defaults to {"terms derived"}.
* `force_cat`: Force category generation on non-mainspace pages.
]==]
function export.format_derived(data)
local terms = data.terms
local sourcetext = export.format_sources(data)
return export.format_links(terms, data.conj, data.template_name, sourcetext, data.decorations_on_outside)
end
function export.insert_borrowed_cat(categories, lang, source)
if lang_is_source(lang, source) then
return
end
-- If both are the same, we want e.g. [[:Category:English terms borrowed back into English]] not
-- [[:Category:English terms borrowed from English]]; the former is inserted automatically by format_source().
-- The second parameter here doesn't matter as it only affects `display`, which we don't use.
insert(categories, (ang_name(lang) or lang:getFullName()) .. " " .. cat_word(lang, "terms borrowed from") .. " " .. select(2, export.get_display_and_cat_name(source, "raw")))
end
-- Internal implementation of {{borrowed}}/{{bor}} template.
function export.format_borrowed(data)
local categories = {}
if not data.nocat then
local lang = data.lang
for _, source in ipairs(data.sources) do
export.insert_borrowed_cat(categories, lang, source)
end
end
data = shallow_copy(data)
data.categories = categories
return export.format_links(data.terms, data.conj, "borrowed", export.format_sources(data))
end
do
-- Generate the non-ancestor error message.
local function show_language(lang)
local retval = ("%s (%s)"):format(lang:makeCategoryLink(), lang:getCode())
if lang:hasType("etymology-only") then
retval = retval .. (" (an etymology-only language whose regular parent is %s)"):format(
show_language(lang:getParent()))
end
return retval
end
-- Check that `lang` has `otherlang` (which may be an etymology-only language) as an ancestor. Throw an error if
-- not. When `lang` is a family, verifies that `otherlang` is a language in that family.
function export.check_ancestor(lang, otherlang)
-- When `lang` is a family, verify `otherlang` is in that family or in its parent family.
if lang.hasType and lang:hasType("family") then
local family_code = lang:getCode()
local function in_family_code(fcode, other)
if not fcode or fcode == "" then return false end
if other.inFamily and other:inFamily(fcode) then return true end
if other.getFamilyCode and other:getFamilyCode() == fcode then return true end
return false
end
local in_family = in_family_code(family_code, otherlang)
if not in_family then
local parent_code
if lang.getParent then
local parent_family = lang:getParent()
if parent_family and parent_family.getCode then
parent_code = parent_family:getCode()
end
end
if not parent_code and family_code:find("-", 1, true) then
parent_code = family_code:match("^(.+)-[^-]+$")
end
if parent_code then
in_family = in_family_code(parent_code, otherlang)
end
end
if not in_family then
local other_display = (otherlang.getCanonicalName and otherlang:getCanonicalName()) or (otherlang.getCode and otherlang:getCode()) or tostring(otherlang)
local fam_display = (lang.getCanonicalName and lang:getCanonicalName()) or family_code
error(("%s is not in family %s; inherited ancestor under a family must be a language in that family or its parent family.")
:format(other_display, fam_display))
end
return
end
-- FIXME: I don't know if this function works correctly with etym-only languages in `lang`. I have fixed up
-- the module link code appropriately (June 2024) but the remaining logic is untouched.
if lang:hasAncestor(otherlang) then
-- [[Special:WhatLinksHere/Wiktionary:Tracking/etymology/variety]]
-- Track inheritance from varieties of Latin that shouldn't have any descendants (everything except Old Latin, Classical Latin and Vulgar Latin).
if otherlang:getFullCode() == "la" then
otherlang = otherlang:getCode()
if not (otherlang == "itc-ola" or otherlang == "la-cla" or otherlang == "la-vul") then
track("bad ancestor", otherlang)
end
end
return
end
local ancestors = lang:getAncestors()
local postscript
local etym_module_link = lang:hasType("etymology-only") and "[[Module:etymology languages/data]] or " or ""
local module_link = "[[" .. get_language_data_module_name(lang:getFullCode()) .. "]]"
if not ancestors[1] then
postscript = show_language(lang) .. " has no ancestors."
else
local ancestor_list = {}
for _, ancestor in ipairs(ancestors) do
insert(ancestor_list, show_language(ancestor))
end
postscript = ("The ancestor%s of %s %s %s."):format(
ancestors[2] and "s" or "", lang:getCanonicalName(),
ancestors[2] and "are" or "is", concat(ancestor_list, " and "))
end
error(("%s is not set as an ancestor of %s in %s%s. %s")
:format(show_language(otherlang), show_language(lang), etym_module_link, module_link, postscript))
end
end
-- Internal implementation of {{inherited}}/{{inh}} template.
function export.format_inherited(data)
local lang, terms, nocat = data.lang, data.terms, data.nocat
local source = terms[1].lang
local categories = {}
if not nocat then
insert(categories, (ang_name(lang) or lang:getFullName()) .. " " .. cat_word(lang, "terms inherited from") .. " " .. (ang_name(source) or source:getCanonicalName()))
end
export.check_ancestor(lang, source)
data = shallow_copy(data)
data.categories = categories
data.source = source
return export.format_links(terms, data.conj, "inherited", export.format_source(data))
end
-- Internal implementation of "misc variant" templates such as {{abbrev}}, {{clipping}}, {{reduplication}} and the like.
function export.format_misc_variant(data)
local lang, notext, terms, cats, parts = data.lang, data.notext, data.terms, data.cats, {}
if not notext then
insert(parts, data.text)
end
if terms[1] then
if not notext then
-- FIXME: If term is given as '-', we should consider displaying just "Clipping" not "Clipping of".
insert(parts, " " .. (data.oftext or "of"))
end
local termparts = {}
-- Make links out of all the parts.
for _, termobj in ipairs(terms) do
local result
if termobj.lang then
result = export.format_derived {
lang = lang,
terms = {termobj},
sources = termobj.termlangs or {termobj.lang},
template_name = "misc_variant",
decorations_on_outside = true,
force_cat = data.force_cat,
}
else
termobj.lang = lang
result = export.format_links({termobj}, nil, "misc_variant")
end
table.insert(termparts, result)
end
local linktext = join_segs(termparts, data.conj)
if not notext and linktext ~= "" then
insert(parts, " ")
end
insert(parts, linktext)
end
local categories = {}
if not data.nocat and cats then
for _, cat in ipairs(cats) do
insert(categories, (ang_name(lang) or lang:getFullName()) .. " " .. cat_word(lang, cat))
end
end
if categories[1] then
insert(parts, format_categories(categories, lang, data.sort_key, nil, data.force_cat or force_cat))
end
return concat(parts)
end
-- Implementation of miscellaneous templates such as {{unknown}} and {{onomatopoeia}} that have no associated terms.
function export.format_misc_variant_no_term(data)
local parts = {}
if not data.notext then
insert(parts, data.title)
end
if not data.nocat and data.cat then
local lang, categories = data.lang, {}
insert(categories, (ang_name(lang) or lang:getFullName()) .. " " .. cat_word(lang, data.cat))
insert(parts, format_categories(categories, lang, data.sort_key, nil, data.force_cat or force_cat))
end
return concat(parts)
end
return export
tc1h50hma4xpgupok2rsigzjth6htgg
Module:etymology/specialized
828
8065
54923
54878
2026-09-29T00:03:30Z
Deadend0914
7211
54923
Scribunto
text/plain
local export = {}
local m_str_utils = require("Module:string utilities")
local en_utilities_module = "Module:en-utilities"
local etymology_module = "Module:etymology"
local gsub = m_str_utils.gsub
local insert = table.insert
local pluralize = require(en_utilities_module).pluralize
local upper = m_str_utils.upper
-- This function handles all the messiness of different types of specialized borrowings. It should insert any
-- borrowing-type-specific categories into `categories` unless `nocat` is given, and return the text to display
-- before the source + term (or "" for no text).
-- Old English localization: category wordings come from [[Module:floccnaman]] (see that module);
-- the English wording is kept when a translation is missing. Loaded lazily and optionally, so a
-- missing module can never break a page.
local floccnaman_module = "Module:floccnaman"
local floccnaman
local function get_floccnaman()
if floccnaman == nil then
local ok, mod = pcall(require, floccnaman_module)
floccnaman = ok and mod or false
end
return floccnaman or nil
end
-- Old English wording for one category word, or the English wording unchanged.
local function cat_word(lang, text)
local mod = get_floccnaman()
return mod and mod.get(lang, text) or text
end
local function get_specialized_borrowing_text_insert_cats(data)
local bortype, categories, lang, terms, source, nocap, nocat, senseid =
data.bortype, data.categories, data.lang, data.terms, data.source, data.nocap, data.nocat, data.senseid
local function inscat(cat)
if not nocat then
local display, sourcedisp = require(etymology_module).get_display_and_cat_name(source, "raw")
if cat:find("DISPLAY") then
cat = cat:gsub("DISPLAY", display)
elseif cat:find("SOURCE") then
cat = cat:gsub("SOURCE", sourcedisp)
else
cat = cat .. " " .. sourcedisp
end
insert(categories, lang:getFullName() .. " " .. cat_word(lang, cat))
end
end
-- `text` is the display text for the borrowing type, which gets converted
-- into a link.
-- `appendix` is a the glossary anchor, which defaults to `text`
-- `prep` is the preposition between the borrowing type and the language
-- name (e.g. "of", "from")
-- `pos` is the part of speech for the borrowing type ("noun" or
-- "adjective"; defaults to "noun")
-- `plural` is the plural form of the borrowing type; if not specified,
-- the pluralize function is used
local text, appendix, prep, pos, plural
if bortype == "calque" then
text, prep = "calque", "of"
inscat("terms calqued from")
elseif bortype == "partial-calque" then
text, prep = "partial calque", "of"
inscat("terms partially calqued from")
elseif bortype == "semantic-loan" then
text, prep = "semantic loan", "from"
inscat("semantic loans from")
elseif bortype == "transliteration" then
text, prep = "transliteration", "of"
inscat("terms borrowed from")
inscat("transliterations of DISPLAY terms")
elseif bortype == "phono-semantic-matching" then
text, prep = "phono-semantic matching", "of"
inscat("phono-semantic matchings from")
else
local langcode = lang:getCode()
local lang_is_source = langcode == source:getCode()
if lang_is_source then
-- Track, because this shouldn't be happening. A language can only have itself as a source further up the chain after a borrowing, which is always "derived".
require("Module:debug/track"){
"etymology/specialized/self-as-source",
"etymology/specialized/self-as-source/" .. langcode
}
inscat("terms borrowed back into")
else
inscat("terms borrowed from")
if bortype ~= "borrowing" then
inscat(bortype .. " borrowings from")
end
end
if bortype == "borrowing" then
text, appendix, prep, pos = "borrowed", "loanword", "from", "adjective"
elseif (
bortype == "learned" or
bortype == "semi-learned" or
bortype == "orthographic" or
bortype == "unadapted"
) then
text, prep = bortype .. " borrowing", "from"
elseif bortype == "adapted" then
text, prep = bortype .. " borrowing", "of"
else
error("Internal error: Unrecognized bortype: " .. bortype)
end
end
-- If the term is suppressed, the preposition should always be "from":
-- "Calque of Chinese 中國".
-- "Calque from Chinese" (not "Calque of Chinese").
if terms[1].term == "-" then
prep = "from"
end
appendix = "Appendix:Glossary#" .. (appendix or text)
if senseid then
local senseids, output = mw.text.split(senseid, '!!'), {}
for i, id in ipairs(senseids) do
-- FIXME: This should be done via a function.
insert(output, mw.getCurrentFrame():preprocess('{{senseno|' .. lang:getCode() .. '|' .. id .. (i == 1 and not nocap and "|uc=1" or "") .. '}}'))
end
local link
if senseid:find('!!') then
link, text = "are", pos == "adjective" and text or plural or pluralize(text)
else
link = pos == "adjective" and "is" or "is a"
end
text = mw.text.listToText(output) .. " " .. link .. " " .. '[[' .. appendix .. '|' .. text .. ']]'
else
text = "[[" .. appendix .. "|" .. (nocap and text or gsub(text, "^.", upper)) .. "]]"
end
return text .. " " .. prep .. " "
end
function export.specialized_borrowing(data)
local lang, sources, terms = data.lang, data.sources, data.terms
local categories = {}
local text
for _, source in ipairs(sources) do
text = get_specialized_borrowing_text_insert_cats {
bortype = data.bortype,
categories = categories,
lang = lang,
terms = terms,
source = source,
nocap = data.nocap,
nocat = data.nocat,
senseid = data.senseid,
}
end
text = data.notext and "" or text
local sourcetext = require(etymology_module).format_sources {
lang = lang,
sources = sources,
terms = terms,
sort_key = data.sort_key,
categories = categories,
nocat = data.nocat,
sourceconj = data.sourceconj,
}
return text .. require(etymology_module).format_links(terms, data.conj, "etymology/specialized", sourcetext)
end
return export
k0nrpxi8wtdfcl3hfg6iamh8tat8ooh
Brūcend:Deadend0914
2
8070
54891
54887
2026-09-28T20:30:37Z
Deadend0914
7211
/* Parts of Speach */
54891
wikitext
text/x-wiki
=Standardization!=
==Parts of Speach==
* (a lot of these are already established, this is just a list)
*Noun - Nama
** Masculine - Werlic
** Feminine - Wīflic
** Neuter - Nāhwæðer
*Adjective - Tōgeīecendlic (note: this is also an adjective)
*Adverb - Bīword
*Case - Cāsus
** Accusative - Wrēgendlic
** Dative - Forgifendlic
** Genitive - Āgniendlic
** Imperative - Bebēodendlic
** Instrumental - Tōllic
** Nominative - Nemniendlic
** Subjunctive - Underþēodendlic
* Comparable or Comparative - Wiþmetendlīc
*Conjunction - Fēgung
*Declension(s) - Declīnung(a)
*Gender - Cynn
*Inflection - Gebīegednes
*Infinitive (or Indefinite) - Ungeendigendlic
*Interjection - Betwuxālegednes
*Participle - Dǣlnimend
*Person - Hād
*Plural - Manigfealdlic (mnf.)
*Preposition - Foresetednes
*Pronoun - Bīnama
*Singular - Ānfealdlic (anf.)
*Time - Tīd
** Past - Forþgewiten
** Perfect - Fullfremed
** Present - Andweardnes
*Verb - Word
** Strong - Strang
** Weak - Unstrang
=Templates=
==Noun Example (use 2 "=")==
*(script used is sprǣc|language-code surrounded by brackets ({}).
=={{sprǣc|ang}}==
===Āwendednessa (use 3 "=")===
* Here, you put alternate forms of words. Optional.
===Rihtstefn (use 3 "=")===
* Here, you put the pronunciation of the word.
* IPA: /whatever-word/
===Wordstǣr (use 3 "=")===
* Here, you put where the word came from. I'm still working on the script but it will be inh|current-language|language-from|word
* For now, use this format below
* Of (language, use the dative)
====Gesibbword====
* Same language Cognates
====Sweostorword====
* Non-same language Cognates)
====Cildru====
* Descendants
===(Gender if applicable) Nama (use 3 "=")===
* Still working on the script here, for now use 3 ' around the word!
'''example'''
* For definitions, use a #, and for examples, use #:
# It will look like this
#: This is an example!
====Declīnung (use 4 "=")====
* Here, you put the inflection table! The script is depending on the specific noun's conjugation! I'll make a page for that soon!
====Wendunga (use 4 "=")====
* Here, you put translations! Only for Englisc words!
* Categories go further down, but it doesn't really matter where, because they don't appear on the actual page anyway. We use Flocc:(whatever category name) inside square brackets "[]"
a98udzvqkvko7wzpa256z96e3t0fxu8
54892
54891
2026-09-28T20:31:25Z
Deadend0914
7211
/* Parts of Speach */
54892
wikitext
text/x-wiki
=Standardization!=
==Parts of Speach==
* (a lot of these are already established, this is just a list)
*Noun - Nama
** Masculine - Werlic
** Feminine - Wīflic
** Neuter - Nāhwæðer
*Adjective - Tōgeīecendlic (note: this is also an adjective)
*Adverb - Bīword
*Case - Cāsus
** Accusative - Wrēgendlic
** Dative - Forgifendlic
** Genitive - Āgniendlic
** Imperative - Bebēodendlic
** Instrumental - Tōllic
** Nominative - Nemniendlic
** Subjunctive - Underþēodendlic
* Comparable or Comparative - Wiþmetendlīc
*Conjunction - Fēgung
*Declension(s) - Declīnung(a)
*Gender - Cynn
*Inflection - Gebīegednes
*Infinitive (or Indefinite) - Ungeendigendlic
*Interjection - Betwuxālegednes
*Participle - Dǣlnimend
*Person - Hād
*Plural - Manigfealdlic (mnf.)
*Preposition - Foresetednes
*Pronoun - Bīnama
*Proper Noun - Āgennama
*Singular - Ānfealdlic (anf.)
*Time - Tīd
** Past - Forþgewiten
** Perfect - Fullfremed
** Present - Andweardnes
*Verb - Word
** Strong - Strang
** Weak - Unstrang
=Templates=
==Noun Example (use 2 "=")==
*(script used is sprǣc|language-code surrounded by brackets ({}).
=={{sprǣc|ang}}==
===Āwendednessa (use 3 "=")===
* Here, you put alternate forms of words. Optional.
===Rihtstefn (use 3 "=")===
* Here, you put the pronunciation of the word.
* IPA: /whatever-word/
===Wordstǣr (use 3 "=")===
* Here, you put where the word came from. I'm still working on the script but it will be inh|current-language|language-from|word
* For now, use this format below
* Of (language, use the dative)
====Gesibbword====
* Same language Cognates
====Sweostorword====
* Non-same language Cognates)
====Cildru====
* Descendants
===(Gender if applicable) Nama (use 3 "=")===
* Still working on the script here, for now use 3 ' around the word!
'''example'''
* For definitions, use a #, and for examples, use #:
# It will look like this
#: This is an example!
====Declīnung (use 4 "=")====
* Here, you put the inflection table! The script is depending on the specific noun's conjugation! I'll make a page for that soon!
====Wendunga (use 4 "=")====
* Here, you put translations! Only for Englisc words!
* Categories go further down, but it doesn't really matter where, because they don't appear on the actual page anyway. We use Flocc:(whatever category name) inside square brackets "[]"
hjvpjsii9yw2liqk2a9z1jrfor16tdt
54893
54892
2026-09-28T20:33:54Z
Deadend0914
7211
/* Parts of Speach */
54893
wikitext
text/x-wiki
=Standardization!=
==Parts of Speach==
* (a lot of these are already established, this is just a list)
*Noun - Nama
** Masculine - Werlic
** Feminine - Wīflic
** Neuter - Nāhwæðer
*Adjective - Tōgeīecendlic (note: this is also an adjective)
*Adverb - Bīword
*Case - Cāsus
** Accusative - Wrēgendlic
** Dative - Forgifendlic
** Genitive - Āgniendlic
** Imperative - Bebēodendlic
** Instrumental - Tōllic
** Nominative - Nemniendlic
** Subjunctive - Underþēodendlic
* Comparable or Comparative - Wiþmetendlīc
*Conjunction - Fēgung
*Declension(s) - Declīnung(a)
*Gender - Cynn
*Inflection - Gebīegednes
*Infinitive (or Indefinite) - Ungeendigendlic
*Interjection - Betwuxālegednes
*Lemma - Frumcenned
*Participle - Dǣlnimend
*Person - Hād
*Plural - Manigfealdlic (mnf.)
*Preposition - Foresetednes
*Pronoun - Bīnama
*Proper Noun - Āgennama
*Singular - Ānfealdlic (anf.)
*Time - Tīd
** Past - Forþgewiten
** Perfect - Fullfremed
** Present - Andweardnes
*Verb - Word
** Strong - Strang
** Weak - Unstrang
=Templates=
==Noun Example (use 2 "=")==
*(script used is sprǣc|language-code surrounded by brackets ({}).
=={{sprǣc|ang}}==
===Āwendednessa (use 3 "=")===
* Here, you put alternate forms of words. Optional.
===Rihtstefn (use 3 "=")===
* Here, you put the pronunciation of the word.
* IPA: /whatever-word/
===Wordstǣr (use 3 "=")===
* Here, you put where the word came from. I'm still working on the script but it will be inh|current-language|language-from|word
* For now, use this format below
* Of (language, use the dative)
====Gesibbword====
* Same language Cognates
====Sweostorword====
* Non-same language Cognates)
====Cildru====
* Descendants
===(Gender if applicable) Nama (use 3 "=")===
* Still working on the script here, for now use 3 ' around the word!
'''example'''
* For definitions, use a #, and for examples, use #:
# It will look like this
#: This is an example!
====Declīnung (use 4 "=")====
* Here, you put the inflection table! The script is depending on the specific noun's conjugation! I'll make a page for that soon!
====Wendunga (use 4 "=")====
* Here, you put translations! Only for Englisc words!
* Categories go further down, but it doesn't really matter where, because they don't appear on the actual page anyway. We use Flocc:(whatever category name) inside square brackets "[]"
m6oijpg8v9ursslq28j3g1i6gltvsv4
food
0
8071
54888
2026-09-28T17:30:39Z
Deadend0914
7211
Gesceop tramet þe hafaþ '=={{sprǣc|en}}== ===Rihtstefn=== * IPA: /fuːd/ ===Wordstǣr=== * Of Middelenglisce ''[[fode]]'', of Englisce ''[[fōda]]'' ===Nama=== '''food''' # fōda [[Flocc: Nīwenglisc nama]] [[Flocc: Nīwenglisc nama ofgangen of Middelenglisce]]'
54888
wikitext
text/x-wiki
=={{sprǣc|en}}==
===Rihtstefn===
* IPA: /fuːd/
===Wordstǣr===
* Of Middelenglisce ''[[fode]]'', of Englisce ''[[fōda]]''
===Nama===
'''food'''
# fōda
[[Flocc: Nīwenglisc nama]]
[[Flocc: Nīwenglisc nama ofgangen of Middelenglisce]]
lyi4ye6jsquvqg6b2o6z0gopu2g9ebg
dish
0
8072
54889
2026-09-28T19:54:20Z
Deadend0914
7211
Gesceop tramet þe hafaþ '=={{sprǣc|en}}== ===Rihtstefn=== * IPA: /dɪʃ/ ===Wordstǣr=== Of Middelenglisce ''[[dissh]]'', of Englisce ''[[disc]]'' ===Nama=== '''dish''' (mnf. dishes) # [[disc]] [[Flocc: Nīwenglisc nama]] [[Flocc: Nīwenglisc nama ofgangen of Middelenglisce]]'
54889
wikitext
text/x-wiki
=={{sprǣc|en}}==
===Rihtstefn===
* IPA: /dɪʃ/
===Wordstǣr===
Of Middelenglisce ''[[dissh]]'', of Englisce ''[[disc]]''
===Nama===
'''dish''' (mnf. dishes)
# [[disc]]
[[Flocc: Nīwenglisc nama]]
[[Flocc: Nīwenglisc nama ofgangen of Middelenglisce]]
t11zl4u88tk165mk9s3ui31smeagbxv
54890
54889
2026-09-28T19:55:25Z
Deadend0914
7211
/* {{sprǣc|en}} */
54890
wikitext
text/x-wiki
=={{sprǣc|en}}==
===Rihtstefn===
* IPA: /dɪʃ/
===Wordstǣr===
Of Middelenglisce ''[[dissh]]'', of Englisce ''[[disc]]''
===Nama===
{{en-noun|~}}
# [[disc]]
[[Flocc: Nīwenglisc nama]]
[[Flocc: Nīwenglisc nama ofgangen of Middelenglisce]]
0pz0k5ie8xrasfakrw2gf5d3yfmnhhs
Module:bases
828
8073
54898
2026-09-28T22:39:10Z
Deadend0914
7211
Gesceop tramet þe hafaþ 'local p = {} local locale = mw.language.new('ang') local currentTitle = mw.title.getCurrentTitle() -- Namespaces p.NS_MEDIA = { id = -2, canonical_name = 'Media', local_name = 'Cræft', } p.NS_SPECIAL = { id = -1, canonical_name = 'Special', local_name = 'Synderlīċ', } p.NS_MAIN = { id = 0, canonical_name = '', local_name = '', } p.NS_TALK = { id = 1, canonical_name = 'Talk', local_name = 'Motung', } p.NS_USER = { id = 2, canonical...'
54898
Scribunto
text/plain
local p = {}
local locale = mw.language.new('ang')
local currentTitle = mw.title.getCurrentTitle()
-- Namespaces
p.NS_MEDIA = {
id = -2,
canonical_name = 'Media',
local_name = 'Cræft',
}
p.NS_SPECIAL = {
id = -1,
canonical_name = 'Special',
local_name = 'Synderlīċ',
}
p.NS_MAIN = {
id = 0,
canonical_name = '',
local_name = '',
}
p.NS_TALK = {
id = 1,
canonical_name = 'Talk',
local_name = 'Motung',
}
p.NS_USER = {
id = 2,
canonical_name = 'User',
local_name = 'Brūcend',
}
p.NS_USER_TALK = {
id = 3,
canonical_name = 'User talk',
local_name = 'Brūcend motung',
}
p.NS_PROJECT = {
id = 4,
canonical_name = 'Project',
local_name = 'Wikiwordbēċ',
}
p.NS_PROJECT_TALK = {
id = 5,
canonical_name = 'Project talk',
local_name = 'Wikiwordbēċ motung',
}
p.NS_FILE = {
id = 6,
canonical_name = 'File',
local_name = 'Tabule',
}
p.NS_FILE_TALK = {
id = 7,
canonical_name = 'File talk',
local_name = 'Tabule motung',
}
p.NS_MEDIAWIKI = {
id = 8,
canonical_name = 'MediaWiki',
local_name = 'MediaWiki',
}
p.NS_MEDIAWIKI_TALK = {
id = 9,
canonical_name = 'MediaWiki talk',
local_name = 'MediaWiki motung',
}
p.NS_TEMPLATE = {
id = 10,
canonical_name = 'Template',
local_name = 'Bysen',
}
p.NS_TEMPLATE_TALK = {
id = 11,
canonical_name = 'Template talk',
local_name = 'Bysen motung',
}
p.NS_HELP = {
id = 12,
canonical_name = 'Help',
local_name = 'Help',
}
p.NS_HELP_TALK = {
id = 13,
canonical_name = 'Help talk',
local_name = 'Help motung',
}
p.NS_CATEGORY = {
id = 14,
canonical_name = 'Category',
local_name = 'Flocc',
}
p.NS_CATEGORY_TALK = {
id = 15,
canonical_name = 'Category talk',
local_name = 'Flocc motung',
}
p.NS_ANNEXE = {
id = 100,
canonical_name = 'Annexe',
local_name = 'Annexe',
}
p.NS_DISCUSSION_ANNEXE = {
id = 101,
canonical_name = 'Discussion Annexe',
local_name = 'Discussion Annexe',
}
p.NS_TRANSWIKI = {
id = 102,
canonical_name = 'Transwiki',
local_name = 'Transwiki',
}
p.NS_DISCUSSION_TRANSWIKI = {
id = 103,
canonical_name = 'Discussion Transwiki',
local_name = 'Discussion Transwiki',
}
p.NS_PORTAIL = {
id = 104,
canonical_name = 'Portail',
local_name = 'Portail',
}
p.NS_DISCUSSION_PORTAIL = {
id = 105,
canonical_name = 'Discussion Portail',
local_name = 'Discussion Portail',
}
p.NS_THESAURUS = {
id = 106,
canonical_name = 'Thésaurus',
local_name = 'Thésaurus',
}
p.NS_DISCUSSION_THESAURUS = {
id = 107,
canonical_name = 'Discussion Thésaurus',
local_name = 'Discussion Thésaurus',
}
p.NS_PROJET = {
id = 108,
canonical_name = 'Projet',
local_name = 'Projet',
}
p.NS_DISCUSSION_PROJET = {
id = 109,
canonical_name = 'Discussion Projet',
local_name = 'Discussion Projet',
}
p.NS_RECONSTRUCTION = {
id = 110,
canonical_name = 'Reconstruction',
local_name = 'Reconstruction',
}
p.NS_DISCUSSION_RECONSTRUCTION = {
id = 111,
canonical_name = 'Discussion Reconstruction',
local_name = 'Discussion Reconstruction',
}
p.NS_TUTORIEL = {
id = 112,
canonical_name = 'Tutoriel',
local_name = 'Tutoriel',
}
p.NS_DISCUSSION_TUTORIEL = {
id = 113,
canonical_name = 'Discussion Tutoriel',
local_name = 'Discussion Tutoriel',
}
p.NS_RIME = {
id = 114,
canonical_name = 'Rime',
local_name = 'Rime',
}
p.NS_DISCUSSION_RIME = {
id = 115,
canonical_name = 'Discussion Rime',
local_name = 'Discussion Rime',
}
p.NS_CONJUGAISON = {
id = 116,
canonical_name = 'Conjugaison',
local_name = 'Conjugaison',
}
p.NS_DISCUSSION_CONJUGAISON = {
id = 117,
canonical_name = 'Discussion Conjugaison',
local_name = 'Discussion Conjugaison',
}
p.NS_RACINE = {
id = 118,
canonical_name = 'Racine',
local_name = 'Racine',
}
p.NS_DISCUSSION_RACINE = {
id = 119,
canonical_name = 'Discussion Racine',
local_name = 'Discussion Racine',
}
p.NS_MODULE = {
id = 828,
canonical_name = 'Module',
local_name = 'Module',
}
p.NS_MODULE_TALK = {
id = 829,
canonical_name = 'Module talk',
local_name = 'Discussion module',
}
p.NS_TRANSLATIONS = {
id = 1198,
canonical_name = 'Translations',
local_name = 'Translations',
}
p.NS_TRANSLATIONS_TALK = {
id = 1199,
canonical_name = 'Translations talk',
local_name = 'Translations talk',
}
p.NS_GADGET = {
id = 2300,
canonical_name = 'Gadget',
local_name = 'Gadget',
}
p.NS_GADGET_TALK = {
id = 2301,
canonical_name = 'Gadget talk',
local_name = 'Discussion gadget',
}
p.NS_GADGET_DEFINITION = {
id = 2302,
canonical_name = 'Gadget definition',
local_name = 'Définition de gadget',
}
p.NS_GADGET_DEFINITION_TALK = {
id = 2303,
canonical_name = 'Gadget definition talk',
local_name = 'Discussion définition de gadget',
}
p.NS_TOPIC = {
id = 2600,
canonical_name = 'Topic',
local_name = 'Sujet',
}
-- Fonctions
--- Indique si le mot donné déclenche une élision.
--- NB: cas particuliers non pris en charge (p. ex. haricot)
--- @param word string Le mot à tester.
--- @return boolean Vrai si le mot déclenche l’élision, faux sinon.
function p.is_elidable(word)
return mw.ustring.match(p.lcfirst(word), "^h?[aáàâäeéèêëiíìîïoóòôöuúùûüǘǜ]") ~= nil
end
--- Indique si la page donnée existe.
--- @param title string Le titre de la page.
--- @return boolean Vrai si la page correspondante existe, faux sinon.
function p.page_existe(title)
return title ~= nil and mw.title.new(title).exists
end
--- Renvoie le texte avec la première lettre en majuscule (si le texte est en français).
--- @param text string Le texte.
--- @return string Le texte avec la première lettre en majuscule.
function p.ucfirst(text)
if text == nil then
return nil
end
-- parenthèses nécessaires
return (mw.ustring.gsub(text, "^([’ǂǃǀǁ]*.)", p.uc))
end
--- Renvoie le texte avec la première lettre en minuscule (si le texte est en français).
--- @param text string Le texte.
--- @return string Le texte avec la première lettre en minuscule.
function p.lcfirst(text)
if text == nil then
return nil
end
return locale:lcfirst(text)
end
--- Renvoie le texte avec en majuscule (si le texte est en français).
--- @param text string Le texte.
--- @return string Le texte en majuscule.
function p.uc(text)
if text == nil then
return nil
end
return locale:uc(text)
end
--- Renvoie le texte avec en minuscule (si le texte est en français).
--- @param text string Le texte.
--- @return string Le texte en minuscule.
function p.lc(text)
if text == nil then
return nil
end
return locale:lc(text)
end
--- Renvoie vrai si le contexte est une page de contenu (principal, annexe, thésaurus ou reconstruction).
--- @return boolean
function p.page_de_contenu()
local ns = currentTitle.namespace
return ns == p.NS_MAIN.id or ns == p.NS_ANNEXE.id or ns == p.NS_THESAURUS.id or ns == p.NS_RECONSTRUCTION.id or ns == p.NS_RIME.id or ns == p.NS_CONJUGAISON.id or ns == p.NS_RACINE.id
end
--- Renvoie vrai si on est dans une page de l’espace principal.
--- @return boolean
function p.page_principale()
return currentTitle:inNamespace(p.NS_MAIN.id)
end
--- Génère une catégorie.
--- @param name string Le nom de la catégorie.
--- @param sortingKey string La clé de tri.
--- @param asLink boolean Indique si la fonction doit retourner un lien (:Catégorie:…) ou non.
--- @return string La catégorie ou une chaîne vide si le nom est nil.
function p.fait_categorie(name, sortingKey, asLink)
local cat = asLink and ':Catégorie:' or 'Catégorie:'
if name ~= nil then
if sortingKey ~= nil and sortingKey ~= '' then
return '[[' .. cat .. name .. '|' .. sortingKey .. ']]'
else
return '[[' .. cat .. name .. ']]'
end
else
return ''
end
end
--- Génère une catégorie uniquement si le contexte est dans l’espace principal,
--- annexe, thésaurus ou reconstruction.
--- @param name string Le nom de la catégorie.
--- @param sortingKey string La clé de tri.
--- @param asLink boolean Indique si la fonction doit retourner un lien (:Catégorie:…) ou non.
--- @return string La catégorie ou une chaîne vide si le nom est nil.
function p.fait_categorie_contenu(name, sortingKey, asLink)
if p.page_de_contenu() then
return p.fait_categorie(name, sortingKey, asLink) or ''
else
return ''
end
end
--- Génère une catégorie uniquement si le contexte est dans l’espace principal.
--- @param name string Le nom de la catégorie.
--- @param sortingKey string La clé de tri.
--- @param asLink boolean Indique si la fonction doit retourner un lien (:Catégorie:…) ou non.
--- @return string La catégorie ou une chaîne vide si le nom est nil.
function p.fait_categorie_principale(name, sortingKey, asLink)
if p.page_principale() then
return p.fait_categorie(name, sortingKey, asLink) or ''
else
return ''
end
end
--- Crée l’entête d’un tableau wiki triable.
--- @param columnTitles table Les titres des colonnes.
--- @return string L’entête du tableau.
function p.tableau_entete(columnTitles)
return '{| class="wikitable sortable"\n|-\n!' .. table.concat(columnTitles, ' !! ')
end
--- Crée une ligne de tableau wiki.
--- @param elements table La liste des éléments de la ligne.
--- @return string La ligne du tableau.
function p.tableau_ligne(elements)
return '|-\n|' .. table.concat(elements, ' || ')
end
--- Crée la fin d’un tableau wiki.
--- @return string La fin du tableau.
function p.tableau_fin()
return '|}\n'
end
--- Met un texte en exposant.
--- @param text string Le texte.
--- @return string Le texte dans une balise <sup>.
function p.exposant(text)
return mw.ustring.format('<sup style="font-size:83%%;line-height:1">%s</sup>', text)
end
--- Balise un texte écrit en langue étrangère.
--- @param text string Le texte.
--- @param code string Le code de la langue ([[Module:langues/data]]).
--- @return string Le texte balisé.
function p.balise_langue(text, code)
local escapedCode = mw.ustring.gsub(code, " ", "_")
return mw.ustring.format('<bdi lang="%s" xml:lang="%s" class="lang-%s">%s</bdi>', code, code, escapedCode, text)
end
--- Enlève les espaces de part et d’autre de tous les paramètres fournis.
--- @param args table La table des paramètres.
--- @return table Une nouvelle table contenant les paramètres sans les espaces.
--- @deprecated Utiliser le [[Module:paramètre]] à la place.
function p.trim_parametres(args)
if args == nil then
return nil
end
local trim_args = {}
for k, v in pairs(args) do
trim_args[k] = mw.text.trim(v)
end
return trim_args
end
--- Crée un lien.
--- @param word string Le mot vers lequel créer le lien.
--- @param langCode string Le code langue.
--- @param anchor string L’ancre, typiquement l’ID de la section dans la page.
--- @param text string Le texte à afficher (optionnel).
--- @param keepLangAnchor boolean Si vrai, le code langue est ajouté au lien
--- même s’il pointe vers la page courante.
--- @return string Le lien.
function p.lien_modele(word, langCode, anchor, text, keepLangAnchor)
if langCode and langCode == "" then
langCode = nil
end
if text and text == "" then
text = nil
end
if anchor and anchor == "" then
anchor = nil
end
local m_unicode = require("Module:données Unicode")
local m_langs = require("Module:langues")
text = m_unicode.setWritingDirection(text or word)
local langCodeForlink = m_langs.specialCodes[langCode] or langCode
local link
if word == currentTitle.prefixedText and not anchor then
if keepLangAnchor and langCodeForlink then
link = mw.ustring.format("[[%s#%s|%s]]", word, langCodeForlink, text)
else
link = mw.ustring.format("[[%s|%s]]", word, text)
end
else
if langCodeForlink then
if anchor and anchor ~= "" then
anchor = langCodeForlink .. "-" .. anchor
else
anchor = langCodeForlink
end
end
if anchor then
link = mw.ustring.format("[[%s#%s|%s]]", word, anchor, text)
else
link = mw.ustring.format("[[%s|%s]]", word, text)
end
end
if langCode then
return p.balise_langue(link, langCode)
end
return link
end
--- Cherche la position de la dernière occurence de la seconde chaîne dans la première.
--- @param subject string La chaîne dans laquelle chercher.
--- @param s string La chaîne à rechercher.
--- @return number La position de la dernière occurence de “s” dans “subject” ou 0 si aucune n’a été trouvée.
function p.derniereOccurrence(subject, s)
local dernier = 0
while subject:sub(dernier + 1, subject:len()):find(s) ~= nil do
dernier = dernier + subject:sub(dernier + 1, subject:len()):find(s)
end
return dernier
end
return p
9r8s9c2fh4l5fihdopqset96ai43g7r
Module:sprǣcnaman
828
8074
54901
2026-09-28T23:17:51Z
Deadend0914
7211
Gesceop tramet þe hafaþ '--[=[ Rēgister of sprǣcnaman (language names) for the Old English Wiktionary. This is the single place where the Old English name of a language is entered. Everything that displays a language name on this wiki reads it from here: * [[Bysen:sprǣc]] (the ==L2== heading template) is a thin wrapper around sprǣc() below. * [[Module:etymology]] and [[Module:etymology/templates]] use get_name() for headings and category names, and get_of() for the "of"-for...'
54901
Scribunto
text/plain
--[=[
Rēgister of sprǣcnaman (language names) for the Old English Wiktionary.
This is the single place where the Old English name of a language is entered. Everything that
displays a language name on this wiki reads it from here:
* [[Bysen:sprǣc]] (the ==L2== heading template) is a thin wrapper around sprǣc() below.
* [[Module:etymology]] and [[Module:etymology/templates]] use get_name() for headings and
category names, and get_of() for the "of"-form, because Old English uses "of" + genitive
when an ancestor or source language is mentioned, e.g. "Of Englisce and".
Names are entered without leading or trailing spaces. get_of() applies the following rules in
order:
1. an explicit entry in `of_names` (for names that follow no rule);
2. `-isc` + "e" (Englisc -> Englisce, Nīwenglisc -> Nīwenglisce, Þēodisc -> Þēodisce);
3. otherwise the nominative name is returned unchanged and the miss is tracked in
[[Wiktionary:Tracking/sprǣcnaman/no of-form]] so that an entry can be supplied.
Codes with no name at all display "?" (as [[Bysen:sprǣc]] always has) and are tracked in
[[Wiktionary:Tracking/sprǣc/unknown code]], see [[Special:WhatLinksHere/Wiktionary:Tracking/sprǣc/unknown code]].
]=]
local export = {}
local names = {
af = "Affricanisc",
ang = "Englisc",
bn = "Bengalisc",
ca = "Catalānisc",
cs = "Bæmisc",
da = "Denisc",
de = "Þēodisc",
el = "Crēacisc",
en = "Nīwenglisc",
eo = "Esperantisc",
es = "Spēonisc",
et = "Eotolisc",
eu = "Wascisc",
fa = "Persisc",
fi = "Finnisc",
fo = "Faerisc",
fr = "Frencisc",
frp = "Profencalisc",
ga = "Īrisc",
gl = "Galizisc",
gn = "Awaisc",
goh = "Ealdhēahþēodisc",
got = "Gotisc",
gv = "Manisc",
haw = "Hawaiisc",
hi = "Hindisc",
hu = "Hungarisc",
id = "Indonesisc",
io = "Idoisc",
is = "Īslendisc",
it = "Italisc",
iu = "Inuctitutisc",
la = "Lǣden",
li = "Limburgisc",
lt = "Litwisc",
lv = "Lettisc",
mul = "Þēodeorþe",
nap = "Neapolitisc",
nl = "Niðerlendisc",
no = "Norþwegisc",
non = "Eald Noren",
ovd = "Ælfdælisc",
pl = "Polisc",
pt = "Portugisc",
qu = "Kescwisc",
ro = "Rumǣnisc",
sa = "Sanscritisc",
sco = "Niderscyttisc",
sq = "Albānisc",
sv = "Swēonisc",
tpi = "Tok Pisin",
vo = "Volapük",
}
--[=[
Codes that are needed in etymology lines (ancestors and source languages) but that have no
name yet. They currently display their '''English''' name (via [[Module:languages]]) and should
be given an Old English name here. The forms below are suggestions only and are deliberately
commented out until they have been checked against a source.
-- gem-pro = "?", -- Proto-Germanic
-- gmw-pro = "?", -- Proto-West Germanic
-- ine-pro = "?", -- Proto-Indo-European
-- enm = "Middelenglisc", -- Middle English
-- gmh = "Middelhēahþēodisc", -- Middle High German
-- odt = "Ealdniðerlendisc", -- Old Dutch
-- dum = "Middelniðerlendisc", -- Middle Dutch
-- ofs = "?", -- Old Frisian
-- osx = "Ealdseaxisc", -- Old Saxon
-- gml = "Middelniðersaxisc", -- Middle Low German
-- cel-pro = "?", -- Proto-Celtic
-- gmq-pro = "?", -- Proto-North Germanic
]=]
--[=[
Explicit "of"-forms, for names that the `-isc` rule cannot handle. Add an entry whenever
[[Wiktionary:Tracking/sprǣcnaman/no of-form]] lists a code that needs one. Suggestions
(commented out until checked against a source):
-- la = "Lǣdenes", -- Latin
-- non = "Eald Norðrena", -- Old Norse
-- mul = "Þēodeorðan", -- Translingual
-- vo = "Volapük", -- Volapük (no ending to inflect)
-- tpi = "Tok Pisin", -- Tok Pisin (no ending to inflect)
]=]
local of_names = {}
-- Spellings that may be passed to {{sprǣc}} or found in a ==L2== heading, mapped to their code.
local aliases = {
["Ænglisc"] = "ang",
}
-- Codes with no name display "?" and are tracked, so that the gaps are visible.
local function track(key)
local ok, track_module = pcall(require, "Module:debug/track")
if ok then
track_module(key)
end
end
function export.track_missing_name(code)
code = tostring(code)
if code == "" then
code = "(empty)"
end
track("sprǣc/unknown code/" .. code)
end
local function track_no_of_form(code)
track("sprǣcnaman/no of-form/" .. tostring(code))
end
-- Accept either a language code or a language object (from [[Module:languages]]).
local function code_candidates(x)
if type(x) ~= "table" then
return { x }
end
local codes = {}
local code = x.getCode and x:getCode()
if code then
codes[#codes + 1] = code
end
local full_code = x.getFullCode and x:getFullCode()
if full_code and full_code ~= code then
codes[#codes + 1] = full_code
end
return codes
end
--[==[
Return the Old English name of the given language (code or language object), or nil if the
language has no name yet. Used for ==L2== headings and for category names.
]==]
function export.get_name(x)
for _, code in ipairs(code_candidates(x)) do
if names[code] then
return names[code]
end
end
return nil
end
--[==[
Return the "of"-form of the given language (code or language object), or nil if the language
has no name yet. Used wherever Old English needs "of" + genitive, e.g. "Of Englisce and".
Names that follow no rule fall back to the nominative and are tracked.
]==]
function export.get_of(x)
for _, code in ipairs(code_candidates(x)) do
if names[code] then
return export.get_of_for_code(code)
end
end
return nil
end
function export.get_of_for_code(code)
local name = names[code]
if not name then
return nil
end
if of_names[code] then
return of_names[code]
end
if name:sub(-3) == "isc" then
return name .. "e"
end
track_no_of_form(code)
return name
end
local code_of_name, lower_code_of_name
local function make_reverse_maps()
if code_of_name then
return
end
code_of_name, lower_code_of_name = {}, {}
for alias, code in pairs(aliases) do
code_of_name[alias] = code
lower_code_of_name[mw.ustring.lower(alias)] = code
end
for code, name in pairs(names) do
code_of_name[name] = code_of_name[name] or code
local lower = mw.ustring.lower(name)
lower_code_of_name[lower] = lower_code_of_name[lower] or code
end
end
--[==[
Return the code of the language with the given Old English name, or nil. Used by
[[Module:etymology/templates]] to match an ==L2== heading back to its language.
]==]
function export.get_code(name)
if type(name) ~= "string" then
return nil
end
name = mw.text.trim(name)
if name == "" then
return nil
end
make_reverse_maps()
return code_of_name[name] or lower_code_of_name[mw.ustring.lower(name)]
end
--[==[
Entry point for [[Bysen:sprǣc]]: {{sprǣc|CODE}} gives the name, {{sprǣc|CODE|of}} the
"of"-form. A code with no name gives "?" and is tracked, exactly as the template always has.
]==]
export["sprǣc"] = function(frame)
local args = frame and frame.args or {}
local code = mw.text.trim(args[1] or "")
local mode = mw.text.trim(args[2] or "")
if code == "" then
export.track_missing_name("")
return "?"
end
local name
if mode == "of" or mode == "gen" or mode == "genitive" then
name = export.get_of(code)
else
name = export.get_name(code)
if not name then
-- The argument may be a name rather than a code (e.g. "Englisc").
local matched_code = export.get_code(code)
name = matched_code and names[matched_code] or nil
end
end
if not name then
export.track_missing_name(code)
return "?"
end
return name
end
--[==[
Entry point for templates that need the "of"-form only:
{{#invoke:sprǣcnaman|of|CODE}}.
]==]
function export.of(frame)
local args = frame and frame.args or {}
local code = mw.text.trim(args[1] or "")
if code == "" then
export.track_missing_name("")
return "?"
end
local name = export.get_of(code)
if not name then
export.track_missing_name(code)
return "?"
end
return name
end
-- The tables are exposed for tests and maintenance scripts; use the getters elsewhere.
export.names = names
export.of_names = of_names
return export
2myyfj8ae4x1vyyh89ecub3sr3d829r
Module:Wordstǣr
828
8075
54902
2026-09-28T23:18:38Z
Deadend0914
7211
Gesceop tramet þe hafaþ '--[=[ Wordstǣr (etymology) template handlers for the Old English Wiktionary. This module holds the Old English wording used by the wordstǣr templates. It deliberately does not re-implement argument handling, the ancestor check or the categories: the handlers here call the corresponding function in [[Module:etymology/templates]] (which in turn calls [[Module:etymology]]) and only add or replace the wording. * [[Bysen:inh]]: "Englisce and" -- source langu...'
54902
Scribunto
text/plain
--[=[
Wordstǣr (etymology) template handlers for the Old English Wiktionary.
This module holds the Old English wording used by the wordstǣr templates. It deliberately does
not re-implement argument handling, the ancestor check or the categories: the handlers here
call the corresponding function in [[Module:etymology/templates]] (which in turn calls
[[Module:etymology]]) and only add or replace the wording.
* [[Bysen:inh]]: "Englisce and" -- source language in its "of"-form, then the term.
* [[Bysen:inh+]]: "Of Englisce and" -- the same, plus the preposition that Old English needs.
The "of"-form comes from [[Module:sprǣcnaman]] (see get_of() there); the same module names the
==L2== headings and the categories, so headings, wordstǣr lines and categories can never
disagree with each other.
Add the Old English wording for the other wordstǣr templates ({{bor}}, {{der}}, {{cog}}, ...)
here in the same way: call the handler in [[Module:etymology/templates]] and replace or add only
the wording.
]=]
local export = {}
--[==[
Entry point for [[Bysen:inh+]], i.e. [[Bysen:inh]] with "Of " in front.
The arguments of {{inh+}} are exactly the arguments of {{inh}} and are passed through unchanged,
so qualifiers, references, alternative forms, gender, transliteration, sort keys, the ancestor
check and the categories of {{inh}} all keep working.
The preposition can be set when invoking the module, e.g. {{#invoke:wordstǣr|inh_plus|of=of}}
for a lower-case "of", or {{#invoke:wordstǣr|inh_plus|of=}} for no preposition at all.
]==]
function export.inh_plus(frame)
local preposition = frame.args.of
if preposition == nil then
preposition = "Of"
end
local text = require("Module:etymology/templates").inherited(frame)
if preposition == "" then
return text
end
return preposition .. " " .. text
end
return export
ipd2claluv1q2mp23l3htfia5ruy6ri
Bysen:inh+
10
8076
54904
2026-09-28T23:19:40Z
Deadend0914
7211
Gesceop tramet þe hafaþ '<includeonly>{{#invoke:wordstǣr|inh_plus|of=Of}}</includeonly><noinclude>{{Documentation}}</noinclude>'
54904
wikitext
text/x-wiki
<includeonly>{{#invoke:wordstǣr|inh_plus|of=Of}}</includeonly><noinclude>{{Documentation}}</noinclude>
gtczggwsqii2jkhhh2kb3rurvfjdxlo
Module:languages/data/exceptional
828
8077
54907
2026-09-28T23:21:55Z
Deadend0914
7211
Gesceop tramet þe hafaþ 'local m_langdata = require("Module:languages/data") -- Loaded on demand, as it may not be needed (depending on the data). local function u(...) u = require("Module:string utilities").char return u(...) end local c = m_langdata.chars local p = m_langdata.puaChars local s = m_langdata.shared local m = {} m["aav-khs-pro"] = { "Proto-Khasian", 116773216, "aav-khs", "Latn", type = "reconstructed", } m["aav-nic-pro"] = { "Proto-Nicobarese", 116773793, "a...'
54907
Scribunto
text/plain
local m_langdata = require("Module:languages/data")
-- Loaded on demand, as it may not be needed (depending on the data).
local function u(...)
u = require("Module:string utilities").char
return u(...)
end
local c = m_langdata.chars
local p = m_langdata.puaChars
local s = m_langdata.shared
local m = {}
m["aav-khs-pro"] = {
"Proto-Khasian",
116773216,
"aav-khs",
"Latn",
type = "reconstructed",
}
m["aav-nic-pro"] = {
"Proto-Nicobarese",
116773793,
"aav-nic",
"Latn",
type = "reconstructed",
}
m["aav-pkl-pro"] = {
"Proto-Pnar-Khasi-Lyngngam",
116773259,
"aav-pkl",
"Latn",
type = "reconstructed",
}
m["aav-pro"] = { -- mkh-pro will merge into this
"Proto-Austroasiatic",
116773186,
"aav",
"Latn",
type = "reconstructed",
}
m["afa-pro"] = {
"Proto-Afroasiatic",
269125,
"afa",
"Latn",
type = "reconstructed",
}
m["alg-aga"] = {
"Agawam",
nil,
"alg-eas",
"Latn",
}
m["alg-pro"] = {
"Proto-Algonquian",
7251834,
"alg",
"Latn",
type = "reconstructed",
sort_key = {remove_diacritics = "·"},
}
m["alv-ama"] = {
"Amasi",
4740400,
"nic-grs",
"Latn",
strip_diacritics = {remove_diacritics = c.grave .. c.acute .. c.circ .. c.tilde .. c.macron},
}
m["alv-bgu"] = {
"Bainouk Gubeeher",
17002646,
"alv-bny",
"Latn",
}
m["alv-bua-pro"] = {
"Proto-Bua",
116773723,
"alv-bua",
"Latn",
type = "reconstructed",
}
m["alv-cng-pro"] = {
"Proto-Cangin",
116773726,
"alv-cng",
"Latn",
type = "reconstructed",
}
m["alv-edo-pro"] = {
"Proto-Edoid",
116773206,
"alv-edo",
"Latn",
type = "reconstructed",
}
m["alv-fli-pro"] = {
"Proto-Fali",
116773754,
"alv-fli",
"Latn",
type = "reconstructed",
}
m["alv-gbe-pro"] = {
"Proto-Gbe",
116773208,
"alv-gbe",
"Latn",
type = "reconstructed",
}
m["alv-gng-pro"] = {
"Proto-Guang",
116773757,
"alv-gng",
"Latn",
type = "reconstructed",
}
m["alv-gtm-pro"] = {
"Proto-Central Togo",
116773732,
"alv-gtm",
"Latn",
type = "reconstructed",
}
m["alv-gwa"] = {
"Gwara",
16945580,
"nic-pla",
"Latn",
}
m["alv-hei-pro"] = {
"Proto-Heiban",
116773760,
"alv-hei",
"Latn",
type = "reconstructed",
}
m["alv-ido-pro"] = {
"Proto-Idomoid",
116773764,
"alv-ido",
"Latn",
type = "reconstructed",
}
m["alv-igb-pro"] = {
"Proto-Igboid",
116773765,
"alv-igb",
"Latn",
type = "reconstructed",
}
m["alv-kwa-pro"] = {
"Proto-Kwa",
116773780,
"alv-kwa",
"Latn",
type = "reconstructed",
}
m["alv-mum-pro"] = {
"Proto-Mumuye",
116773791,
"alv-mum",
"Latn",
type = "reconstructed",
}
m["alv-nup-pro"] = {
"Proto-Nupoid",
116773795,
"alv-nup",
"Latn",
type = "reconstructed",
}
m["alv-pro"] = {
"Proto-Atlantic-Congo",
116732838,
"alv",
"Latn",
type = "reconstructed",
}
m["alv-edk-pro"] = {
"Proto-Edekiri",
nil,
"alv-edk",
"Latn",
type = "reconstructed",
}
m["alv-yor-pro"] = {
"Proto-Yoruba",
nil,
"alv-yor",
"Latn",
type = "reconstructed",
}
m["alv-yrd-pro"] = {
"Proto-Yoruboid",
116773824,
"alv-yrd",
"Latn",
type = "reconstructed",
}
m["alv-von-pro"] = {
"Proto-Volta-Niger",
116773820,
"alv-von",
"Latn",
type = "reconstructed",
}
m["apa-pro"] = {
"Proto-Apachean",
116773135,
"apa",
"Latn",
type = "reconstructed",
}
m["aql-pro"] = {
"Proto-Algic",
18389588,
"aql",
"Latn",
type = "reconstructed",
sort_key = {remove_diacritics = "·"},
}
m["art-adu"] = {
"Adûni",
1232159,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-bel"] = {
"Belter Creole",
108055510,
"art",
"Latn",
type = "appendix-constructed",
sort_key = {
remove_diacritics = c.acute,
from = {"ɒ"},
to = {"a"},
},
}
m["art-blk"] = {
"Bolak",
2909283,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-bsp"] = {
"Black Speech",
686210,
"art",
"Latn, Teng",
type = "appendix-constructed",
}
m["art-com"] = {
"Communicationssprache",
35227,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-dtk"] = {
"Dothraki",
2914733,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-elo"] = {
"Eloi",
nil,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-gld"] = {
"Goa'uld",
19823,
"art",
"Latn, Egyp, Mero",
type = "appendix-constructed",
}
m["art-lap"] = {
"Lapine",
6488195,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-man"] = {
"Mandalorian",
54289,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-mun"] = {
"Mundolinco",
851355,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-nav"] = {
"Naʼvi",
316939,
"art",
"Latn",
type = "appendix-constructed",
}
m["art-vlh"] = {
"High Valyrian",
64483808,
"art",
"Latn",
type = "appendix-constructed",
}
m["ath-nic"] = {
"Nicola",
20609,
"ath-nor",
"Latn",
}
m["ath-pro"] = {
"Proto-Athabaskan",
104841722,
"ath",
"Latn",
type = "reconstructed",
}
m["auf-pro"] = {
"Proto-Arawan",
116773706,
"auf",
"Latn",
type = "reconstructed",
}
m["aus-alu"] = {
"Alungul",
16827670,
"aus-pmn",
"Latn",
}
m["aus-and"] = {
"Andjingith",
4754509,
"aus-pmn",
"Latn",
}
m["aus-ang"] = {
"Angkula",
16828520,
"aus-pmn",
"Latn",
}
m["aus-arn-pro"] = {
"Proto-Arnhem",
116773720,
"aus-arn",
"Latn",
type = "reconstructed",
}
m["aus-bra"] = {
"Barranbinya",
4863220,
"aus-pmn",
"Latn",
}
m["aus-brm"] = {
"Barunggam",
4865914,
"aus-pmn",
"Latn",
}
m["aus-cww-pro"] = {
"Proto-Central New South Wales",
116773199,
"aus-cww",
"Latn",
type = "reconstructed",
}
m["aus-dal-pro"] = {
"Proto-Daly",
116773743,
"aus-dal",
"Latn",
type = "reconstructed",
}
m["aus-guw"] = {
"Guwar",
6652138,
"aus-pam",
"Latn",
}
m["aus-lsw"] = {
"Little Swanport",
6652138,
"qfa-unc",
"Latn",
}
m["aus-mbi"] = {
"Mbiywom",
6799701,
"aus-pmn",
"Latn",
}
m["aus-ngk"] = {
"Ngkoth",
7022405,
"aus-pmn",
"Latn",
}
m["aus-nyu-pro"] = {
"Proto-Nyulnyulan",
116773797,
"aus-nyu",
"Latn",
type = "reconstructed",
}
m["aus-pam-pro"] = {
"Proto-Pama-Nyungan",
33942,
"aus-pam",
"Latn",
type = "reconstructed",
}
m["aus-tul"] = {
"Tulua",
16938541,
"aus-pam",
"Latn",
}
m["aus-uwi"] = {
"Uwinymil",
7903995,
"aus-arn",
"Latn",
}
m["aus-wdj-pro"] = {
"Proto-Iwaidjan",
116773767,
"aus-wdj",
"Latn",
type = "reconstructed",
}
m["aus-won"] = {
"Wong-gie",
nil,
"aus-pam",
"Latn",
}
m["aus-wul"] = {
"Wulguru",
8039196,
"aus-dyb",
"Latn",
}
m["aus-ynk"] = { -- contrast nny
"Yangkaal",
3913770,
"aus-tnk",
"Latn",
}
m["awd-amc-pro"] = {
"Proto-Amuesha-Chamicuro",
nil,
"awd",
"Latn",
type = "reconstructed",
}
m["awd-kmp-pro"] = {
"Proto-Kampa",
nil,
"awd",
"Latn",
type = "reconstructed",
}
m["awd-prw-pro"] = {
"Proto-Paresi-Waura",
nil,
"awd",
"Latn",
type = "reconstructed",
}
m["awd-ama"] = {
"Amarizana",
16827787,
"awd",
"Latn",
}
m["awd-ana"] = {
"Anauyá",
16828252,
"awd",
"Latn",
}
m["awd-apo"] = {
"Apolista",
16916645,
"awd",
"Latn",
}
m["awd-cab"] = {
"Cabre",
16850160,
"awd",
"Latn",
}
m["awd-gnu"] = {
"Guinau",
3504087,
"awd",
"Latn",
}
m["awd-kar"] = {
"Cariay",
16920253,
"awd",
"Latn",
}
m["awd-kaw"] = {
"Kawishana",
6379993,
"awd-nwk",
"Latn",
}
m["awd-kus"] = {
"Kustenau",
5196293,
"awd",
"Latn",
}
m["awd-man"] = {
"Manao",
6746920,
"awd",
"Latn",
}
m["awd-mar"] = {
"Marawan",
6755108,
"awd",
"Latn",
}
m["awd-mpr"] = {
"Maipure",
6736872,
"awd",
"Latn",
}
m["awd-mrt"] = {
"Mariaté",
16910017,
"awd-nwk",
"Latn",
}
m["awd-nwk-pro"] = {
"Proto-Nawiki",
116773234,
"awd-nwk",
"Latn",
type = "reconstructed",
}
m["awd-pai"] = {
"Paikoneka",
128807835,
"awd",
"Latn",
}
m["awd-pas"] = {
"Pasé",
7143168,
"awd-nwk",
"Latn",
}
m["awd-pro"] = {
"Proto-Arawak",
97573478,
"awd",
"Latn",
type = "reconstructed",
}
m["awd-she"] = {
"Shebayo",
7492248,
"awd",
"Latn",
}
m["awd-taa-pro"] = {
"Proto-Ta-Arawak",
116773282,
"awd-taa",
"Latn",
type = "reconstructed",
}
m["awd-wai"] = {
"Wainumá",
16910017,
"awd-nwk",
"Latn",
}
m["awd-war"] = {
"Old Warekena",
105320180,
"awd-nwk",
"Latn",
}
m["awd-yum"] = {
"Yumana",
8061062,
"awd-nwk",
"Latn",
}
m["azc-caz"] = {
"Cazcan",
5055514,
"azc",
"Latn",
}
m["azc-cup-pro"] = {
"Proto-Cupan",
116773738,
"azc-cup",
"Latn",
type = "reconstructed",
}
m["azc-ktn"] = {
"Kitanemuk",
3197558,
"azc-tak",
"Latn",
}
m["azc-nah-pro"] = {
"Proto-Nahuan",
7251860,
"azc-nah",
"Latn",
type = "reconstructed",
}
m["azc-nic"] = {
"Nicoleño",
50241488,
"azc",
"Latn",
}
m["azc-num-pro"] = {
"Proto-Numic",
116773247,
"azc-num",
"Latn",
type = "reconstructed",
}
m["azc-pro"] = {
"Proto-Uto-Aztecan",
96400333,
"azc",
"Latn",
type = "reconstructed",
}
m["azc-tak-pro"] = {
"Proto-Takic",
116773283,
"azc-tak",
"Latn",
type = "reconstructed",
}
m["azc-tat"] = {
"Tataviam",
743736,
"azc",
"Latn",
}
m["ber-pro"] = {
"Proto-Berber",
2855698,
"ber",
"Latn",
type = "reconstructed",
}
m["ber-fog"] = {
"Fogaha",
107610173,
"ber",
"Latn",
}
m["ber-zuw"] = {
"Zuwara",
4117169,
"ber",
"Latn",
}
m["bnt-bal"] = {
"Balong",
93935237,
"bnt-bbo",
"Latn",
}
m["bnt-bon"] = {
"Boma Nkuu",
nil,
"bnt",
"Latn",
}
m["bnt-boy"] = {
"Boma Yumu",
nil,
"bnt",
"Latn",
}
m["bnt-bwa"] = {
"Bwala",
128810345,
"bnt-tek",
"Latn",
}
m["bnt-cmw"] = {
"Chimwiini",
4958328,
"bnt-swh",
"Latn",
}
m["bnt-ind"] = {
"Indanga",
51412803,
"bnt",
"Latn",
}
m["bnt-lal"] = {
"Lala (South Africa)",
6480154,
"bnt-ngu",
"Latn",
}
m["bnt-mpi"] = {
"Mpiin",
93937013,
"bnt-bdz",
"Latn",
}
m["bnt-mpu"] = {
"Mpuono", -- not to be confused with Mbuun zmp
36056,
"bnt",
"Latn",
}
m["bnt-ngu-pro"] = {
"Proto-Nguni",
961559,
"bnt-ngu",
"Latn",
type = "reconstructed",
sort_key = {remove_diacritics = c.grave .. c.acute .. c.circ .. c.caron},
}
m["bnt-phu"] = {
"Phuthi",
33796,
"bnt-ngu",
"Latn",
strip_diacritics = {remove_diacritics = c.grave .. c.acute},
}
m["bnt-pro"] = {
"Proto-Bantu",
3408025,
"bnt",
"Latn",
type = "reconstructed",
sort_key = "bnt-pro-sortkey",
}
m["bnt-sab-pro"] = {
"Proto-Sabaki",
nil, -- Q2209395 is the code for the Sabaki family
"bnt-sab",
"Latn",
type = "reconstructed",
}
m["bnt-sbo"] = {
"South Boma",
nil,
"bnt",
"Latn",
}
m["bnt-sts-pro"] = {
"Proto-Sotho-Tswana",
116773278,
"bnt-sts",
"Latn",
type = "reconstructed",
}
m["btk-pro"] = {
"Proto-Batak",
116773191,
"btk",
"Latn",
type = "reconstructed",
}
m["cau-abz-pro"] = {
"Proto-Abkhaz-Abaza",
7251831,
"cau-abz",
"Latn",
type = "reconstructed",
}
m["cau-and-pro"] = {
"Proto-Andian",
nil,
"cau-and",
"Latn",
type = "reconstructed",
}
m["cau-ava-pro"] = {
"Proto-Avaro-Andian",
116773187,
"cau-ava",
"Latn",
type = "reconstructed",
}
m["cau-cir-pro"] = {
"Proto-Circassian",
7251838,
"cau-cir",
"Latn",
type = "reconstructed",
}
m["cau-drg-pro"] = {
"Proto-Dargwa",
116773205,
"cau-drg",
"Latn",
type = "reconstructed",
}
m["cau-lzg-pro"] = {
"Proto-Lezghian",
116773223,
"cau-lzg",
"Latn",
type = "reconstructed",
}
m["cau-nec-pro"] = {
"Proto-Northeast Caucasian",
116773244,
"cau-nec",
"Latn",
type = "reconstructed",
}
m["cau-nkh-pro"] = {
"Proto-Nakh",
108032840,
"cau-nkh",
"Latn",
type = "reconstructed",
}
m["cau-nwc-pro"] = {
"Proto-Northwest Caucasian",
7251861,
"cau-nwc",
"Latn",
type = "reconstructed",
}
m["cau-tsz-pro"] = {
"Proto-Tsezian",
116773287,
"cau-tsz",
"Latn",
type = "reconstructed",
}
m["cba-ata"] = {
"Atanques",
4812783,
"cba",
"Latn",
}
m["cba-cat"] = {
"Catío Chibcha",
7083619,
"cba",
"Latn",
}
m["cba-dor"] = {
"Dorasque",
5297532,
"cba",
"Latn",
}
m["cba-dui"] = {
"Duit",
3041061,
"cba",
"Latn",
}
m["cba-hue"] = {
"Huetar",
35514,
"cba",
"Latn",
}
m["cba-nut"] = {
"Nutabe",
7070405,
"cba",
"Latn",
}
m["cba-pro"] = {
"Proto-Chibchan",
116773203,
"cba",
"Latn",
type = "reconstructed",
}
m["ccs-pro"] = {
"Proto-Kartvelian",
2608203,
"ccs",
"Latn",
type = "reconstructed",
strip_diacritics = {
from = {"q̣", "p̣", "ʓ", "ċ"},
to = {"q̇", "ṗ", "ʒ", "c̣"}
},
}
m["ccs-gzn-pro"] = {
"Proto-Georgian-Zan",
23808119,
"ccs-gzn",
"Latn",
type = "reconstructed",
strip_diacritics = {
from = {"q̣", "p̣", "ʓ", "ċ"},
to = {"q̇", "ṗ", "ʒ", "c̣"}
},
}
m["cdc-cbm-pro"] = {
"Proto-Central Chadic",
116773197,
"cdc-cbm",
"Latn",
type = "reconstructed",
}
m["cdc-mas-pro"] = {
"Proto-Masa",
116773789,
"cdc-mas",
"Latn",
type = "reconstructed",
}
m["cdc-pro"] = {
"Proto-Chadic",
116773201,
"cdc",
"Latn",
type = "reconstructed",
}
m["cdd-pro"] = {
"Proto-Caddoan",
116773725,
"cdd",
"Latn",
type = "reconstructed",
}
m["cel-bry-pro"] = {
"Proto-Brythonic",
1248800,
"cel-bry",
"Latn, Polyt",
sort_key = {
Latn = "cel-bry-pro-sortkey",
},
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["cel-gal"] = {
"Gallaecian",
3094789,
"cel-his",
}
m["cel-gau"] = {
"Gaulish",
29977,
"cel",
"Latn, Polyt, Ital",
strip_diacritics = {
Latn = {remove_diacritics = c.macron .. c.breve .. c.diaer},
},
sort_key = {
Latn = "cel-bry-pro-sortkey",
},
-- Ital translit in [[Module:scripts/data]]
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["cel-pro"] = {
"Proto-Celtic",
653649,
"cel",
"Latn",
type = "reconstructed",
sort_key = "cel-pro-sortkey",
}
m["chi-pro"] = {
"Proto-Chimakuan",
116773734,
"chi",
"Latn",
type = "reconstructed",
}
m["chm-pro"] = {
"Proto-Mari",
116773788,
"chm",
"Latn",
type = "reconstructed",
}
m["cmc-pro"] = {
"Proto-Chamic",
114793834,
"cmc",
"Latn",
type = "reconstructed",
}
m["crp-bip"] = {
"Basque-Icelandic Pidgin",
810378,
"crp",
"Latn",
ancestors = "eu",
}
m["crp-cpr"] = {
"Chinese Pidgin Russian",
nil,
"crp",
"Hani, Cyrl, Latn",
ancestors = "ru, zh",
translit = {Cyrl = "ru-translit"},
strip_diacritics = {
Cyrl = {remove_diacritics = c.acute .. c.grave .. c.macron},
},
}
m["crp-gep"] = {
"West Greenlandic Pidgin",
17036301,
"crp",
"Latn",
ancestors = "kl",
}
m["crp-kia"] = {
"Kiautschou German Pidgin",
108314615,
"crp",
"Latn",
ancestors = "de",
}
m["crp-mar"] = {
"Maroon Spirit Language",
1093206,
"crp",
"Latn",
ancestors = "en",
}
m["crp-mpp"] = {
"Macau Pidgin Portuguese",
128804537,
"crp",
"Hant, Latn",
ancestors = "pt",
sort_key = {Hant = "Hani-sortkey"},
}
m["crp-rsn"] = {
"Russenorsk",
505125,
"crp",
"Cyrl, Latn",
ancestors = "nn, ru",
translit = {Cyrl = "ru-translit"},
}
m["crp-spp"] = {
"Samoan Plantation Pidgin",
7409948,
"crp",
"Latn",
ancestors = "en",
}
m["crp-slb"] = {
"Solombala English",
7558525,
"crp",
"Cyrl, Latn",
ancestors = "en, ru",
translit = {Cyrl = "ru-translit"},
}
m["crp-tpr"] = {
"Taimyr Pidgin Russian",
16930506,
"crp",
"Cyrl",
ancestors = "ru",
translit = "ru-translit",
}
m["csu-bba-pro"] = {
"Proto-Bongo-Bagirmi",
116773722,
"csu-bba",
"Latn",
type = "reconstructed",
}
m["csu-maa-pro"] = {
"Proto-Mangbetu",
116773786,
"csu-maa",
"Latn",
type = "reconstructed",
}
m["csu-pro"] = {
"Proto-Central Sudanic",
116773730,
"csu",
"Latn",
type = "reconstructed",
}
m["csu-sar-pro"] = {
"Proto-Sara",
116773809,
"csu-sar",
"Latn",
type = "reconstructed",
}
m["cus-ash"] = {
"Ashraaf",
4805855,
"cus-som",
"Latn",
}
m["cus-hec-pro"] = {
"Proto-Highland East Cushitic",
116773761,
"cus-hec",
"Latn",
type = "reconstructed",
}
m["cus-som-pro"] = {
"Proto-Somaloid",
nil,
"cus-som",
"Latn",
type = "reconstructed",
}
m["cus-sou-pro"] = {
"Proto-South Cushitic",
126081567,
"cus-sou",
"Latn",
type = "reconstructed",
}
m["cus-pro"] = {
"Proto-Cushitic",
116773204,
"cus",
"Latn",
type = "reconstructed",
}
m["dmn-dam"] = {
"Dama (Sierra Leone)",
19601574,
"dmn",
"Latn",
}
m["dra-bry"] = {
"Beary",
1089116,
"qfa-mix",
"Mlym, Knda",
ancestors = "ml, tcy",
-- Knda translit in [[Module:scripts/data]]
-- Mlym translit in [[Module:scripts/data]]
}
m["dra-cen-pro"] = {
"Proto-Central Dravidian",
nil,
"dra-cen",
"Latn",
type = "reconstructed",
}
m["dra-mkn"] = {
"Middle Kannada",
128810572,
"dra-kan",
"Knda",
-- Knda translit in [[Module:scripts/data]]
}
m["dra-nor-pro"] = {
"Proto-North Dravidian",
124433593,
"dra-nor",
"Latn",
type = "reconstructed",
}
m["dra-okn"] = {
"Old Kannada",
15723156,
"dra-kan",
"Knda",
-- Knda translit in [[Module:scripts/data]]
}
m["dra-ote"] = {
"Old Telugu",
126720868,
"dra-tel",
"Telu",
translit = "te-translit",
}
m["dra-pro"] = {
"Proto-Dravidian",
1702853,
"dra",
"Latn",
type = "reconstructed",
}
m["dra-sdo-pro"] = {
"Proto-South Dravidian I",
104847952, -- Wikipedia's "Proto-South Dravidian" is Proto-South Dravidian I in this scheme.
"dra-sdo",
"Latn",
type = "reconstructed",
}
m["dra-sdt-pro"] = {
"Proto-South Dravidian II",
128885257,
"dra-sdt",
"Latn",
type = "reconstructed",
}
m["dra-sou-pro"] = {
"Proto-South Dravidian",
128886121,
"dra-sou",
"Latn",
type = "reconstructed",
}
m["egx-dem"] = {
"Demotic Egyptian",
36765,
"egx",
"Latn, Egyd, Polyt",
sort_key = {
Latn = {
remove_diacritics = "'%-%s",
from = {"ꜣ", "j", "e", "ꜥ", "y", "w", "b", "p", "f", "m", "n", "r", "l", "ḥ", "ḫ", "h̭", "ẖ", "h", "š", "s", "q", "k", "g", "ṱ", "ṯ", "t", "ḏ", "%.", "⸗"},
to = {p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[15], p[16], p[16], p[17], p[14], p[19], p[18], p[20], p[21], p[22], p[23], p[24], p[23], p[25], p[26], p[26]}
},
},
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["dmn-pro"] = {
"Proto-Mande",
116773785,
"dmn",
"Latn",
type = "reconstructed",
}
m["dmn-mdw-pro"] = {
"Proto-Western Mande",
116773822,
"dmn-mdw",
"Latn",
type = "reconstructed",
}
m["dru-pro"] = {
"Proto-Rukai",
116773807,
"map",
"Latn",
type = "reconstructed",
}
m["ero-gsz"] = {
"Geshiza",
nil,
"ero",
"Latn",
}
m["ero-nya"] = {
"Nyagrong Minyag",
nil,
"ero",
"Latn",
}
m["ero-tau"] = {
"Stau",
nil,
"ero",
"Latn",
}
m["esx-esk-pro"] = {
"Proto-Eskimo",
7251842,
"esx-esk",
"Latn",
type = "reconstructed",
display_text = s["esx-displaytext"],
strip_diacritics = s["esx-stripdiacritics"],
}
m["esx-ink"] = {
"Inuktun",
1671647,
"esx-inu",
"Latn",
}
m["esx-inq"] = {
"Inuinnaqtun",
28070,
"esx-inu",
"Latn",
}
m["esx-inu-pro"] = {
"Proto-Inuit",
60785588,
"esx-inu",
"Latn",
type = "reconstructed",
display_text = s["esx-displaytext"],
strip_diacritics = s["esx-stripdiacritics"],
}
m["esx-pro"] = {
"Proto-Eskimo-Aleut",
7251843,
"esx",
"Latn",
type = "reconstructed",
display_text = s["esx-displaytext"],
strip_diacritics = s["esx-stripdiacritics"],
}
m["esx-tut"] = {
"Tunumiisut",
15665389,
"esx-inu",
"Latn",
}
m["euq-pro"] = {
"Proto-Basque",
938011,
"euq",
"Latn",
type = "reconstructed",
}
m["gba-pro"] = {
"Proto-Gbaya",
nil,
"gba",
"Latn",
type = "reconstructed",
}
m["gem-pro"] = {
"Proto-Germanic",
669623,
"gem",
"Latn",
type = "reconstructed",
sort_key = "gem-pro-sortkey",
}
m["gme-bur"] = {
"Burgundian",
47625,
"gme",
"Latn",
}
m["gme-cgo"] = {
"Crimean Gothic",
36211,
"gme",
"Latn",
}
m["gmq-gut"] = {
"Gutnish",
1256646,
"gmq",
"Latn",
ancestors = "gmq-ogt",
}
m["gmq-jmk"] = {
"Jamtish",
35512,
"gmq-eas",
"Latn",
}
m["gmq-mno"] = {
"Middle Norwegian",
3417070,
"gmq-wes",
"Latn",
}
m["gmq-oda"] = {
"Old Danish",
12330003,
"gmq-eas",
"Latn, Runr",
strip_diacritics = {remove_diacritics = c.macron},
}
m["gmq-ogt"] = {
"Old Gutnish",
1133488,
"gmq",
"Latn, Runr",
ancestors = "non",
}
m["gmq-osw"] = {
"Old Swedish",
2417210,
"gmq-eas",
"Latn, Runr",
strip_diacritics = {remove_diacritics = c.macron},
}
m["gmq-pro"] = {
"Proto-Norse",
1671294,
"gmq",
"Runr",
translit = "Runr-translit",
}
m["gmq-scy"] = {
"Scanian",
768017,
"gmq-eas",
"Latn",
}
m["gmw-bgh"] = {
"Bergish",
329030,
"gmw-frk",
"Latn",
}
m["gmw-cfr"] = {
"Central Franconian",
572197,
"gmw-hgm",
"Latn",
ancestors = "gmh",
wikimedia_codes = "ksh",
}
m["gmw-ecg"] = {
"East Central German",
499344, -- subsumes Q699284, Q152965
"gmw-hgm",
"Latn",
ancestors = "gmh",
}
m["gmw-fin"] = {
"Fingallian",
3072588,
"gmw-ian",
"Latn",
}
m["gmw-gts"] = {
"Gottscheerish",
533109,
"gmw-hgm",
"Latn",
ancestors = "bar",
}
m["gmw-jdt"] = {
"Jersey Dutch",
1687911,
"gmw-frk",
"Latn",
ancestors = "nl",
}
m["gmw-msc"] = {
"Middle Scots",
3327000,
"gmw-ang",
"Latn",
ancestors = "enm-esc",
}
m["gmw-pro"] = {
"Proto-West Germanic",
78079021,
"gmw",
"Latn, Runr",
-- type = "reconstructed",
-- largely but not entirely reconstructed (like Proto-Norse); see April '24 BP, set back to reconstructed (?) if 'anti-asterisk' is added
sort_key = "gmw-pro-sortkey",
}
m["gmw-rfr"] = {
"Rhine Franconian",
707007,
"gmw-hgm",
"Latn",
ancestors = "gmh",
}
m["gmw-stm"] = {
"Sathmar Swabian",
2223059,
"gmw-hgm",
"Latn",
ancestors = "swg",
}
m["gmw-tsx"] = {
"Transylvanian Saxon",
260942,
"gmw-hgm",
"Latn",
ancestors = "gmw-cfr",
}
m["gmw-vog"] = {
"Volga German",
312574,
"gmw-hgm",
"Latn",
ancestors = "gmw-rfr",
}
m["gmw-zps"] = {
"Zipser German",
205548,
"gmw-hgm",
"Latn",
ancestors = "gmh",
}
m["gn-cls"] = {
"Classical Guarani",
17478065,
"gn",
"Latn",
}
m["grk-cal"] = {
"Calabrian Greek",
1146398,
"grk",
"Latn, Grek",
ancestors = "grk-ita",
translit = {
Grek = "el-translit",
},
-- Grek display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["grk-car"] = {
"Cargesian Greek",
16549443,
"grk",
"Latn, Grek",
ancestors = "gkm",
}
m["grk-ita"] = {
"Italiot Greek",
19720507,
"grk",
"Latn, Grek",
ancestors = "gkm",
translit = {
Grek = "el-translit",
},
-- Grek display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["grk-mar"] = {
"Mariupol Greek",
4400023,
"grk",
"Cyrl, Latn, Grek",
ancestors = "gkm",
translit = {
Cyrl = "grk-mar-translit",
Grek = "grk-mar-translit",
},
override_translit = true,
strip_diacritics = {
Cyrl = {remove_diacritics = c.acute},
},
-- Grek display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["grk-pro"] = {
"Proto-Hellenic",
1231805,
"grk",
"Latn, Polyt",
type = "reconstructed",
sort_key = {Latn = {
from = {"ʰ", "ʷ"},
to = {"h", "w"},
remove_diacritics = c.grave .. c.acute .. c.macron .. c.breve .. c.caron .. c.CGJ
}},
display_text = {Latn = {
from = {"([dlLt])" .. c.caron},
to = {"%1" .. c.CGJ .. c.caron},
}},
strip_diacritics = {Latn = {
from = {"([dlLt])" .. c.caron},
to = {"%1" .. c.CGJ .. c.caron},
}},
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
-- NOTE: formerly no translit specified for Polyt; presumably an accidental omission; if not, set Polyt = false in
-- the translit section
}
m["hmn-pro"] = {
"Proto-Hmongic",
116773210,
"hmn",
"Latn",
type = "reconstructed",
}
m["hmx-mie-pro"] = {
"Proto-Mienic",
116773229,
"hmx-mie",
"Latn",
type = "reconstructed",
}
m["hmx-pro"] = {
"Proto-Hmong-Mien",
7251846,
"hmx",
"Latn",
type = "reconstructed",
}
m["hyx-pro"] = {
"Proto-Armenian",
3848498,
"hyx",
"Latn",
type = "reconstructed",
}
m["iir-nur-pro"] = {
"Proto-Nuristani",
116773248,
"iir-nur",
"Latn",
type = "reconstructed",
}
m["iir-pro"] = {
"Proto-Indo-Iranian",
966439,
"iir",
"Latn",
type = "reconstructed",
}
m["ijo-pro"] = {
"Proto-Ijoid",
116773766,
"ijo",
"Latn",
type = "reconstructed",
}
m["inc-apa"] = {
"Apabhramsa",
616419,
"inc-mid",
"Deva, Shrd, Sidd",
ancestors = "pra",
translit = {
Deva = "sa-translit",
-- Shrd translit in [[Module:scripts/data]]
-- Sidd translit in [[Module:scripts/data]]
},
}
m["inc-ash"] = {
"Ashokan Prakrit",
104854379,
"inc-mid",
"Brah, Khar",
ancestors = "sa",
translit = {
-- Brah translit in [[Module:scripts/data]]
Khar = "Khar-translit",
},
}
m["inc-dng-pro"] = {
"Proto-Dangari",
nil,
"inc-dng",
"Latn",
type = "reconstructed",
}
m["inc-kam"] = {
"Kamarupi Prakrit",
6356097,
"inc-bas",
"Brah, Sidd",
-- Brah, Sidd translit in [[Module:scripts/data]]
}
m["inc-kho"] = {
"Kholosi",
24952008,
"inc-snd",
"Latn",
}
m["inc-khr"] = {
"Khortha",
13406670,
"inc-sad",
"Deva, Kthi",
translit = {
Deva = "bho-translit",
Kthi = "bho-Kthi-translit",
},
}
m["inc-krd-pro"] = {
"Proto-Kamta",
128816843,
"inc-bas",
"Latn",
ancestors = "inc-kam",
type = "reconstructed",
}
m["inc-mas"] = {
"Middle Assamese",
128806836,
"inc-bas",
"as-Beng",
ancestors = "inc-oas",
translit = "inc-mas-translit",
}
m["inc-mbn"] = {
"Middle Bengali",
113559927,
"inc-bas",
"Beng",
ancestors = "inc-obn",
translit = "inc-mbn-translit",
}
m["inc-mgu"] = {
"Middle Gujarati",
24907429,
"inc-wes",
"Deva",
ancestors = "inc-ogu",
}
m["inc-mor"] = {
"Middle Odia",
128810882,
"inc-eas",
"Orya",
ancestors = "inc-oor",
}
m["inc-oas"] = {
"Early Assamese",
85758237,
"inc-bas",
"as-Beng",
ancestors = "inc-kam",
translit = "inc-oas-translit",
}
m["inc-oaw"] = {
"Old Awadhi",
nil,
"inc-hie",
"Deva, Kthi, Aran",
strip_diacritics = {
from = {"هٔ", "ۂ"}, -- character "ۂ" code U+06C2 to "ه" and "هٔ" (U+0647 + U+0654) to "ه"
to = {"ہ", "ہ"},
remove_diacritics = c.fathatan .. c.dammatan .. c.kasratan .. c.fatha .. c.damma .. c.kasra .. c.shadda .. c.sukun .. c.nunghunna .. c.superalef
},
translit = {
Deva = "sa-translit",
Kthi = "sa-Kthi-translit",
Aran = "inc-ohi-translit",
},
}
m["inc-obn"] = {
"Old Bengali",
113559926,
"inc-bas",
"Beng",
}
m["inc-ogu"] = {
"Old Gujarati",
24907427,
"inc-wes",
"Deva",
translit = "sa-translit",
}
m["inc-ohi"] = {
"Old Hindi",
48767781,
"inc-hiw",
"Deva, Aran",
strip_diacritics = {
from = {"هٔ", "ۂ"}, -- character "ۂ" code U+06C2 to "ه" and "هٔ" (U+0647 + U+0654) to "ه"
to = {"ہ", "ہ"},
remove_diacritics = c.fathatan .. c.dammatan .. c.kasratan .. c.fatha .. c.damma .. c.kasra .. c.shadda .. c.sukun .. c.nunghunna .. c.superalef
},
translit = {
Deva = "sa-translit",
Aran = "inc-ohi-translit",
},
}
m["inc-oor"] = {
"Old Odia",
128807801,
"inc-eas",
"Orya",
}
m["inc-opa"] = {
"Old Punjabi",
115270971,
"inc-pan",
"Guru, Aran",
translit = {
Guru = "inc-opa-Guru-translit",
Aran = "pa-Aran-translit",
},
strip_diacritics = {remove_diacritics = c.fathatan .. c.dammatan .. c.kasratan .. c.fatha .. c.damma .. c.kasra .. c.shadda .. c.sukun},
}
m["inc-pro"] = {
"Proto-Indo-Aryan",
23808344,
"inc",
"Latn",
type = "reconstructed",
}
m["inc-sar"] = {
"Sarazi",
85799728,
"him",
"Aran, Deva, Takr",
strip_diacritics = {
from = {"هٔ", "ۂ"}, -- character "ۂ" code U+06C2 to "ه" and "هٔ" (U+0647 + U+0654) to "ه"
to = {"ہ", "ہ"},
remove_diacritics = c.fathatan .. c.dammatan .. c.kasratan .. c.fatha .. c.damma .. c.kasra .. c.shadda .. c.sukun .. c.nunghunna .. c.superalef
},
translit = {
Aran = "ur-translit",
Deva = "hi-translit",
-- Takr = "Takr-translit",
},
}
m["ine-ana-pro"] = {
"Proto-Anatolian",
7251833,
"ine-ana",
"Latn",
type = "reconstructed",
}
m["ine-bsl-pro"] = {
"Proto-Balto-Slavic",
1703347,
"ine-bsl",
"Latn",
type = "reconstructed",
sort_key = {
from = {"[áā]", "[éēḗ]", "[íī]", "[óōṓ]", "[úū]", c.acute, c.macron, "ˀ"},
to = {"a", "e", "i", "o", "u"}
},
}
m["ine-kal"] = {
"Kalašma",
122770439,
"ine-ana",
"Xsux",
}
m["ine-pae"] = {
"Paeonian",
2705672,
"ine",
"Polyt",
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["ine-pro"] = {
"Proto-Indo-European",
37178,
"ine",
"Latn",
type = "reconstructed",
sort_key = {
from = {"[áā]", "[éēḗ]", "[íī]", "[óōṓ]", "[úū]", "ĺ", "ḿ", "ń", "ŕ", "ǵ", "ḱ", "ʰ", "ʷ", "₁", "₂", "₃", c.ringbelow, c.acute, c.macron},
to = {"a", "e", "i", "o", "u", "l", "m", "n", "r", "g'", "k'", "¯h", "¯w", "1", "2", "3"}
},
}
m["ine-toc-pro"] = {
"Proto-Tocharian",
104841462,
"ine-toc",
"Latn",
type = "reconstructed",
}
m["xme-old"] = {
"Old Median",
36461,
"xme",
"Polyt, Latn",
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["xme-mid"] = {
"Middle Median",
12836150,
"xme",
"Latn",
}
m["xme-ker"] = {
"Kermanic",
129850,
"xme",
"Arab, Latn, Hebr",
ancestors = "xme-mid",
-- Hebr display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["xme-taf"] = {
"Tafreshi",
nil,
"xme",
"Arab, Latn",
ancestors = "xme-mid",
}
m["xme-ttc-pro"] = {
"Proto-Tatic",
122973870,
"xme-ttc",
"Latn",
ancestors = "xme-mid",
}
m["xme-kls"] = {
"Kalasuri",
nil,
"xme-ttc",
ancestors = "xme-ttc-nor",
}
m["xme-klt"] = {
"Kilit",
3612452,
"xme-ttc",
"Cyrl", -- and Arab?
}
m["xme-ott"] = {
"Old Tati",
434697,
"xme-ttc",
"Arab, Latn",
}
m["ira-kms-pro"] = {
"Proto-Komisenian",
116773777,
"ira-kms",
"Latn",
type = "reconstructed",
}
m["ira-mpr-pro"] = {
"Proto-Medo-Parthian",
116773227,
"ira-mpr",
"Latn",
type = "reconstructed",
}
m["ira-pat-pro"] = {
"Proto-Pathan",
116773255,
"ira-pat",
"Latn",
type = "reconstructed",
}
m["ira-pro"] = {
"Proto-Iranian",
4167865,
"ira",
"Latn",
type = "reconstructed",
}
m["ira-zgr-pro"] = {
"Proto-Zaza-Gorani",
116775031,
"ira-zgr",
"Latn",
type = "reconstructed",
}
m["xsc-pro"] = {
"Proto-Scythian",
116773273,
"xsc",
"Latn",
type = "reconstructed",
}
m["xsc-sar-pro"] = {
"Proto-Sarmatian",
116773249,
"xsc-sar",
"Latn",
type = "reconstructed",
}
m["xsc-skw-pro"] = {
"Proto-Saka-Wakhi",
116773267,
"xsc-skw",
"Latn",
type = "reconstructed",
}
m["xsc-sak-pro"] = {
"Proto-Saka",
116773264,
"xsc-sak",
"Latn",
type = "reconstructed",
}
m["ira-sym-pro"] = {
"Proto-Shughni-Yazghulami-Munji",
116773813,
"ira-sym",
"Latn",
type = "reconstructed",
}
m["ira-sgi-pro"] = {
"Proto-Sanglechi-Ishkashimi",
116773808,
"ira-sgi",
"Latn",
type = "reconstructed",
}
m["ira-mny-pro"] = {
"Proto-Munji-Yidgha",
116773792,
"ira-mny",
"Latn",
type = "reconstructed",
}
m["ira-shy-pro"] = {
"Proto-Shughni-Yazghulami",
116773812,
"ira-shy",
"Latn",
type = "reconstructed",
}
m["ira-shr-pro"] = {
"Proto-Shughni-Roshani",
116773811,
"ira-shr",
"Latn",
type = "reconstructed",
}
m["ira-sgc-pro"] = {
"Proto-Sogdic",
116773276,
"ira-sgc",
"Latn",
type = "reconstructed",
}
m["ira-wnj"] = {
"Vanji",
3398419,
"ira-shy",
"Latn",
}
m["iro-ere"] = {
"Erie",
5388365,
"iro-nor",
"Latn",
}
m["iro-min"] = {
"Mingo",
128531,
"iro-nor",
"Latn",
ietf_subtag = "i-mingo", -- grandfathered IETF tag
}
m["iro-nor-pro"] = {
"Proto-North Iroquoian",
116773242,
"iro-nor",
"Latn",
type = "reconstructed",
}
m["iro-pro"] = {
"Proto-Iroquoian",
7251852,
"iro",
"Latn",
type = "reconstructed",
}
m["itc-pro"] = {
"Proto-Italic",
17102720,
"itc",
"Latn",
type = "reconstructed",
}
m["itc-psa"] = {
"Pre-Samnite",
7239186,
"itc-sbl",
"Ital, Polyt, Latn",
-- Ital translit in [[Module:scripts/data]] (NOTE: formerly not present, probably an accidental omission)
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["jpx-hcj"] = {
"Hachijō",
5637049,
"jpx",
"Jpan",
ancestors = "ojp-eas",
translit = s["jpx-translit"],
display_text = s["jpx-displaytext"],
strip_diacritics = s["jpx-stripdiacritics"],
sort_key = s["jpx-sortkey"],
}
m["jpx-pro"] = {
"Proto-Japonic",
3924309,
"jpx",
"Latn",
type = "reconstructed",
}
m["jpx-ryu-pro"] = {
"Proto-Ryukyuan",
56349069,
"jpx-ryu",
"Latn",
type = "reconstructed",
}
m["kar-pro"] = {
"Proto-Karen",
85794783,
"kar",
"Latn",
type = "reconstructed",
}
m["kca-eas"] = {
"Eastern Khanty",
30304622,
"kca",
"Cyrl",
translit = "kca-translit",
override_translit = true,
-- TODO temporary until MediaWiki supports Unicode 16 (probably requires a PHP update from their side)
sort_key = { Cyrl = { from = {""}, to = {""} } },
}
m["kca-nor"] = {
"Northern Khanty",
30304527,
"kca",
"Cyrl",
translit = "kca-translit",
override_translit = true,
-- TODO temporary until MediaWiki supports Unicode 16 (probably requires a PHP update from their side)
sort_key = { Cyrl = { from = {""}, to = {""} } },
}
m["kca-pro"] = {
"Proto-Khanty",
127505171,
"kca",
"Latn",
type = "reconstructed",
}
m["kca-sou"] = {
"Southern Khanty",
30304618,
"kca",
"Cyrl",
translit = "kca-translit",
override_translit = true,
}
m["khi-kho-pro"] = {
"Proto-Khoe",
116773218,
"khi-kho",
"Latn",
type = "reconstructed",
}
m["khi-kun"] = {
"ǃKung",
32904,
"khi-kxa",
"Latn",
}
m["ko-ear"] = {
"Early Modern Korean",
756014,
"qfa-kor",
"Kore",
ancestors = "okm",
translit = "okm-translit",
-- Kore strip_diacritics in [[Module:scripts/data]]
}
m["kro-pro"] = {
"Proto-Kru",
116773778,
"kro",
"Latn",
type = "reconstructed",
}
m["ku-pro"] = {
"Proto-Kurdish",
116773221,
"ku",
"Latn",
type = "reconstructed",
}
m["map-ata-pro"] = {
"Proto-Atayalic",
116773151,
"map-ata",
"Latn",
type = "reconstructed",
}
m["map-bms"] = {
"Banyumasan",
33219,
"map",
"Latn, Java",
}
m["map-pro"] = {
"Proto-Austronesian",
49230,
"map",
"Latn",
type = "reconstructed",
}
m["mis-hkl"] = {
"Kelantan Peranakan Hokkien",
108794818,
"qfa-mix",
ancestors = "nan-hbl, sou, mfa",
}
m["mis-idn"] = {
"Idiom Neutral",
35847,
"art",
"Latn",
type = "appendix-constructed",
}
m["mis-isa"] = {
"Isaurian",
16956868,
nil,
-- "Xsux, Hluw, Latn",
}
m["mis-jie"] = {
"Jie",
124424186,
nil,
"Hani",
sort_key = "Hani-sortkey",
}
m["mis-jzh"] = {
"Jizhao",
45242758,
"qfa-bej",
"Latn",
}
m["mis-kas"] = {
"Kassite",
35612,
nil,
"Xsux",
}
m["mis-mmd"] = {
"Mimi of Decorse",
6862206,
nil,
"Latn",
}
m["mis-mmn"] = {
"Mimi of Nachtigal",
6862207,
nil,
"Latn",
}
m["mis-phi"] = {
"Philistine",
2230924,
nil,
"Phnx",
-- Phnx translit in [[Module:scripts/data]] (NOTE: not present before, presumably an accidental omission)
}
m["mis-rou"] = {
"Rouran",
48816637,
"qfa-xgx",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mis-tdl"] = {
"Turdulian",
133176492,
}
m["mis-tdt"] = {
"Turdetanian",
133176461,
}
m["mis-tnw"] = {
"Tangwang",
7683179,
"qfa-mix",
"Latn",
ancestors = "cmn, sce",
}
m["mis-tuh"] = {
"Tuyuhun",
48816625,
"qfa-xgx",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mis-tuo"] = {
"Tuoba",
48816629,
"qfa-xgx",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mis-wuh"] = {
"Wuhuan",
118976867,
"qfa-xgx",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mis-xbi"] = {
"Xianbei",
4448647,
"qfa-xgx",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mis-xnu"] = {
"Xiongnu",
10901674,
nil,
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mjg-mgl"] = {
"Mongghul",
53765528,
"mjg",
"Latn", -- also Mong, Cyrl ?
}
m["mjg-mgr"] = {
"Mangghuer",
56285392,
"mjg",
"Latn", -- also Mong, Cyrl ?
}
m["mkh-asl-pro"] = {
"Proto-Aslian",
55630680,
"mkh-asl",
"Latn",
type = "reconstructed",
}
m["mkh-ban-pro"] = {
"Proto-Bahnaric",
116773189,
"mkh-ban",
"Latn",
type = "reconstructed",
}
m["mkh-kat-pro"] = {
"Proto-Katuic",
116773772,
"mkh-kat",
"Latn",
type = "reconstructed",
}
m["mkh-khm-pro"] = {
"Proto-Khmuic",
116773774,
"mkh-khm",
"Latn",
type = "reconstructed",
}
m["mkh-kmr-pro"] = {
"Proto-Khmeric",
55630684,
"mkh-kmr",
"Latn",
type = "reconstructed",
}
m["mkh-mmn"] = {
"Middle Mon",
121337926,
"mkh-mnc",
"Latn, Mymr", --and also Pallava
ancestors = "omx",
}
m["mkh-mnc-pro"] = {
"Proto-Monic",
116773231,
"mkh-mnc",
"Latn",
type = "reconstructed",
}
m["mkh-mvi"] = {
"Middle Vietnamese",
9199,
"mkh-vie",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["mkh-pal-pro"] = {
"Proto-Palaungic",
104847372,
"mkh-pal",
"Latn",
type = "reconstructed",
}
m["mkh-pea-pro"] = {
"Proto-Pearic",
116773804,
"mkh-pea",
"Latn",
type = "reconstructed",
}
m["mkh-pkn-pro"] = {
"Proto-Pakanic",
116773803,
"mkh-pkn",
"Latn",
type = "reconstructed",
}
m["mkh-pro"] = { --This will be merged into 2015 aav-pro.
"Proto-Mon-Khmer",
7251859,
"mkh",
"Latn",
type = "reconstructed",
}
m["mnw-tha"] = { -- To be removed.
"Thai Mon",
nil,
"mkh-mnc",
"Mymr, Thai",
ancestors = "mkh-mmn",
sort_key = {
from = {"[%p]", "ျ", "ြ", "ွ", "ှ", "ၞ", "ၟ", "ၠ", "ၚ", "ဿ", "[็-๎]", "([เแโใไ])([ก-ฮ])ฺ?"},
to = {"", "္ယ", "္ရ", "္ဝ", "္ဟ", "္န", "္မ", "္လ", "င", "သ္သ", "", "%2%1"}
},
}
m["mkh-vie-pro"] = {
"Proto-Vietic",
109432616,
"mkh-vie",
"Latn",
type = "reconstructed",
}
m["mns-cen"] = {
"Central Mansi",
128810384,
"mns",
"Cyrl",
translit = "mns-translit",
override_translit = true,
}
m["mns-nor"] = {
"Northern Mansi",
30304537,
"mns",
"Cyrl",
translit = "mns-translit",
override_translit = true,
}
m["mns-pro"] = {
"Proto-Mansi",
128883093,
"mns",
"Latn",
type = "reconstructed",
}
m["mns-sou"] = {
"Southern Mansi",
30304629,
"mns",
"Cyrl",
translit = "mns-translit",
override_translit = true,
}
m["mun-pro"] = {
"Proto-Munda",
105102373,
"mun",
"Latn",
type = "reconstructed",
}
m["myn-chl"] = { -- the stage after ''emy''
"Ch'olti'",
873995,
"myn",
"Latn",
}
m["myn-pro"] = {
"Proto-Mayan",
3321532,
"myn",
"Latn",
type = "reconstructed",
}
m["nai-ala"] = {
"Alazapa",
128810233,
nil,
"Latn",
}
m["nai-bay"] = {
"Bayogoula",
1563704,
nil,
"Latn",
}
m["nai-cal"] = {
"Calusa",
51782,
nil,
"Latn",
}
m["nai-chi"] = {
"Chiquimulilla",
25339627,
"nai-xin",
"Latn",
}
m["nai-chu-pro"] = {
"Proto-Chumash",
116773736,
"nai-chu",
"Latn",
type = "reconstructed",
}
m["nai-cig"] = {
"Ciguayo",
20741700,
nil,
"Latn",
}
m["nai-ckn-pro"] = {
"Proto-Chinookan",
116773735,
"nai-ckn",
"Latn",
type = "reconstructed",
}
m["nai-guz"] = {
"Guazacapán",
19572028,
"nai-xin",
"Latn",
}
m["nai-hit"] = {
"Hitchiti",
1542882,
"nai-mus",
"Latn",
}
m["nai-ipa"] = {
"Ipai",
3027474,
"nai-yuc",
"Latn",
}
m["nai-jtp"] = {
"Jutiapa",
nil,
"nai-xin",
"Latn",
}
m["nai-jum"] = {
"Jumaytepeque",
25339626,
"nai-xin",
"Latn",
}
m["nai-kat"] = {
"Kathlamet",
6376639,
"nai-ckn",
"Latn",
}
m["nai-klp-pro"] = {
"Proto-Kalapuyan",
116773771,
"nai-klp",
"Latn",
type = "reconstructed",
}
m["nai-knm"] = {
"Konomihu",
3198734,
"nai-shs",
"Latn",
}
m["nai-kum"] = {
"Kumeyaay",
4910139,
"nai-yuc",
"Latn",
}
m["nai-mac"] = {
"Macoris",
21070851,
nil,
"Latn",
}
m["nai-mdu-pro"] = {
"Proto-Maidun",
116773784,
"nai-mdu",
"Latn",
type = "reconstructed",
}
m["nai-miz-pro"] = {
"Proto-Mixe-Zoquean",
7251858,
"nai-miz",
"Latn",
type = "reconstructed",
}
m["nai-mus-pro"] = {
"Proto-Muskogean",
116775368,
"nai-mus",
"Latn",
type = "reconstructed",
}
m["nai-nao"] = {
"Naolan",
6964594,
nil,
"Latn",
}
m["nai-nrs"] = {
"New River Shasta",
7011254,
"nai-shs",
"Latn",
}
m["nai-okw"] = {
"Okwanuchu",
3350126,
"nai-shs",
"Latn",
}
m["nai-per"] = {
"Pericú",
3375369,
nil,
"Latn",
}
m["nai-pic"] = {
"Picuris",
7191257,
"nai-kta",
"Latn",
}
m["nai-plp-pro"] = {
"Proto-Plateau Penutian",
116773806,
"nai-plp",
"Latn",
type = "reconstructed",
}
m["nai-pom-pro"] = {
"Proto-Pomo",
116773262,
"nai-pom",
"Latn",
type = "reconstructed",
}
m["nai-qng"] = {
"Quinigua",
36360,
nil,
"Latn",
}
m["nai-sca-pro"] = { -- NB 'sio-pro' "Proto-Siouan" which is Proto-Western Siouan
"Proto-Siouan-Catawban",
116773275,
"nai-sca",
"Latn",
type = "reconstructed",
}
m["nai-sin"] = {
"Sinacantán",
24190249,
"nai-xin",
"Latn",
}
m["nai-sln"] = {
"Salvadoran Lenca",
3229434,
"nai-len",
"Latn",
}
m["nai-spt"] = {
"Sahaptin",
3833015,
"nai-shp",
"Latn",
}
m["nai-tap"] = {
"Tapachultec",
7684401,
"nai-miz",
"Latn",
}
m["nai-taw"] = {
"Tawasa",
7689233,
nil,
"Latn",
}
m["nai-teq"] = {
"Tequistlatec",
2964454,
"nai-tqn",
"Latn",
}
m["nai-tip"] = {
"Tipai",
3027471,
"nai-yuc",
"Latn",
}
m["nai-tot-pro"] = {
"Proto-Totozoquean",
116773285,
"nai-tot",
"Latn",
type = "reconstructed",
}
m["nai-tsi-pro"] = {
"Proto-Tsimshianic",
nil,
"nai-tsi",
"Latn",
type = "reconstructed",
}
m["nai-utn-pro"] = {
"Proto-Utian",
116773290,
"nai-utn",
"Latn",
type = "reconstructed",
}
m["nai-wai"] = {
"Waikuri",
3118702,
nil,
"Latn",
}
m["nai-wji"] = {
"Western Jicaque",
3178610,
"nai-jcq",
"Latn",
}
m["nai-yup"] = {
"Yupiltepeque",
25339628,
"nai-xin",
"Latn",
}
m["nan-dat"] = {
"Datian Min",
19855572,
"zhx-nan",
"Hants",
generate_alternants = "zh-generatealternants",
sort_key = "Hani-sortkey",
}
m["nan-hbl"] = {
"Hokkien",
1624231,
"zhx-nan",
"Hants, Latn, Bopo, Kana",
wikimedia_codes = "zh-min-nan",
generate_alternants = "zh-generatealternants",
sort_key = {
Hani = "Hani-sortkey",
Kana = "Kana-sortkey"
},
}
m["nan-hlh"] = {
"Hailufeng Min",
120755728,
"zhx-nan",
"Hants",
generate_alternants = "zh-generatealternants",
sort_key = "Hani-sortkey",
}
m["nan-lnx"] = {
"Longyan Min",
6674568,
"zhx-nan",
"Hants",
generate_alternants = "zh-generatealternants",
sort_key = "Hani-sortkey",
}
m["nan-tws"] = {
"Teochew",
36759,
"zhx-nan",
"Hants",
generate_alternants = "zh-generatealternants",
translit = "zh-translit",
sort_key = "Hani-sortkey",
}
m["nan-zhe"] = {
"Zhenan Min",
3846710,
"zhx-nan",
"Hants",
generate_alternants = "zh-generatealternants",
sort_key = "Hani-sortkey",
}
m["nan-zsh"] = {
"Sanxiang Min",
7420769,
"zhx-nan",
"Hants",
generate_alternants = "zh-generatealternants",
sort_key = "Hani-sortkey",
}
m["ngf-bin-pro"] = {
"Proto-Binanderean",
137881672,
"ngf-bin",
"Latn",
type = "reconstructed",
}
m["ngf-pro"] = {
"Proto-Trans-New Guinea",
85794785,
"ngf",
"Latn",
type = "reconstructed",
}
m["nic-bco-pro"] = {
"Proto-Benue-Congo",
116773194,
"nic-bco",
"Latn",
type = "reconstructed",
}
m["nic-bod-pro"] = {
"Proto-Bantoid",
116773190,
"nic-bod",
"Latn",
type = "reconstructed",
}
m["nic-eov-pro"] = {
"Proto-Eastern Oti-Volta",
116773753,
"nic-eov",
"Latn",
type = "reconstructed",
}
m["nic-gns-pro"] = {
"Proto-Gurunsi",
116773759,
"nic-gns",
"Latn",
type = "reconstructed",
}
m["nic-grf-pro"] = {
"Proto-Grassfields",
116773755,
"nic-grf",
"Latn",
type = "reconstructed",
}
m["nic-gur-pro"] = {
"Proto-Gur",
116773758,
"nic-gur",
"Latn",
type = "reconstructed",
}
m["nic-jkn-pro"] = {
"Proto-Jukunoid",
116773769,
"nic-jkn",
"Latn",
type = "reconstructed",
}
m["nic-lcr-pro"] = {
"Proto-Lower Cross River",
116773782,
"nic-lcr",
"Latn",
type = "reconstructed",
}
m["nic-ogo-pro"] = {
"Proto-Ogoni",
116773799,
"nic-ogo",
"Latn",
type = "reconstructed",
}
m["nic-ovo-pro"] = {
"Proto-Oti-Volta",
116773802,
"nic-ovo",
"Latn",
type = "reconstructed",
}
m["nic-plt-pro"] = {
"Proto-Plateau",
116773805,
"nic-plt",
"Latn",
type = "reconstructed",
}
m["nic-pro"] = {
"Proto-Niger-Congo",
108000748,
"nic",
"Latn",
type = "reconstructed",
}
m["nic-ubg-pro"] = {
"Proto-Ubangian",
116773818,
"nic-ubg",
"Latn",
type = "reconstructed",
}
m["nic-ucr-pro"] = {
"Proto-Upper Cross River",
116773819,
"nic-ucr",
"Latn",
type = "reconstructed",
}
m["nic-vco-pro"] = {
"Proto-Volta-Congo",
116773293,
"nic-vco",
"Latn",
type = "reconstructed",
}
m["njo-jgl"] = {
"Chungli Ao",
55607615,
"njo",
"Latn",
}
m["njo-mng"] = {
"Mongsen Ao",
85383221,
"njo",
"Latn",
}
m["nub-har"] = {
"Haraza",
19572059,
"nub",
"Arab, Latn",
}
m["nub-pro"] = {
"Proto-Nubian",
116773246,
"nub",
"Latn",
type = "reconstructed",
}
m["omq-cha-pro"] = {
"Proto-Chatino",
116773202,
"omq-cha",
"Latn",
type = "reconstructed",
}
m["omq-maz-pro"] = {
"Proto-Mazatec",
116773790,
"omq-maz",
"Latn",
type = "reconstructed",
}
m["omq-mix-pro"] = {
"Proto-Mixtecan",
21573423,
"omq-mix",
"Latn",
type = "reconstructed",
}
m["omq-mxt-pro"] = {
"Proto-Mixtec",
21573424,
"omq-mxt",
"Latn",
type = "reconstructed",
}
m["omq-otp-pro"] = {
"Proto-Oto-Pamean",
116773251,
"omq-otp",
"Latn",
type = "reconstructed",
}
m["omq-pro"] = {
"Proto-Oto-Manguean",
33669,
"omq",
"Latn",
type = "reconstructed",
}
m["omq-sjq"] = {
"San Juan Quiahije Chatino",
138330751,
"omq-cha",
"Latn",
}
m["omq-tel"] = {
"Teposcolula Mixtec",
nil,
"omq-mxt",
"Latn",
}
m["omq-teo"] = {
"Teojomulco Chatino",
25340451,
"omq-cha",
"Latn",
}
m["omq-tri-pro"] = {
"Proto-Triqui",
116773817,
"omq-tri",
"Latn",
type = "reconstructed",
}
m["omq-zap-pro"] = {
"Proto-Zapotecan",
116773297,
"omq-zap",
"Latn",
type = "reconstructed",
}
m["omq-zpc-pro"] = {
"Proto-Zapotec",
116773296,
"omq-zpc",
"Latn",
type = "reconstructed",
}
m["omv-aro-pro"] = {
"Proto-Aroid",
116773721,
"omv-aro",
"Latn",
type = "reconstructed",
}
m["omv-diz-pro"] = {
"Proto-Dizoid",
116773750,
"omv-diz",
"Latn",
type = "reconstructed",
}
m["omv-pro"] = {
"Proto-Omotic",
116773800,
"omv",
"Latn",
type = "reconstructed",
}
m["oto-otm-pro"] = {
"Proto-Otomi",
5908710,
"oto-otm",
"Latn",
type = "reconstructed",
}
m["oto-pro"] = {
"Proto-Otomian",
116773252,
"oto",
"Latn",
type = "reconstructed",
}
m["paa-kmn"] = {
"Kómnzo",
18344310,
"paa-wko",
"Latn",
}
m["paa-kwn"] = {
"Kuwani",
6449056,
"qfa-unc", -- poorly attested, possibly the same as or related to Kalabra
"Latn",
}
m["paa-lei"] = {
"Leitre",
85776228,
"paa-isk",
}
m["paa-nha-pro"] = {
"Proto-North Halmahera",
116773241,
"paa-nha",
"Latn",
type = "reconstructed"
}
m["paa-nun"] = {
"Nungon",
128807788,
"ngf-ynu",
"Latn",
}
m["phi-din"] = {
"Dinapigue Agta",
16945774,
"phi",
"Latn",
}
m["phi-kal-pro"] = {
"Proto-Kalamian",
116773213,
"phi-kal",
"Latn",
type = "reconstructed",
}
m["phi-nag"] = {
"Nagtipunan Agta",
16966111,
"phi",
"Latn",
}
m["phi-pro"] = {
"Proto-Philippine",
18204898,
"phi",
"Latn",
type = "reconstructed",
}
m["poz-abi"] = {
"Abai",
19570729,
"poz-san",
"Latn",
}
m["poz-bal"] = {
"Baliledo",
4850912,
"poz",
"Latn",
}
m["poz-btk-pro"] = {
"Proto-Bungku-Tolaki",
116773724,
"poz-btk",
"Latn",
type = "reconstructed",
}
m["poz-cet-pro"] = {
"Proto-Central-Eastern Malayo-Polynesian",
2269883,
"poz-cet",
"Latn",
type = "reconstructed",
}
m["poz-hce-pro"] = {
"Proto-Halmahera-Cenderawasih",
116773209,
"poz-hce",
"Latn",
type = "reconstructed",
}
m["poz-lgx-pro"] = {
"Proto-Lampungic",
116773222,
"poz-lgx",
"Latn",
type = "reconstructed",
}
m["poz-mcm-pro"] = {
"Proto-Malayo-Chamic",
116773225,
"poz-mcm",
"Latn",
type = "reconstructed",
}
m["poz-mic-pro"] = {
"Proto-Micronesian",
111939079,
"poz-mic",
"Latn",
type = "reconstructed",
}
m["poz-mly-pro"] = {
"Proto-Malayic",
98057728,
"poz-mly",
"Latn",
type = "reconstructed",
}
m["poz-msa-pro"] = {
"Proto-Malayo-Sumbawan",
116773226,
"poz-msa",
"Latn",
type = "reconstructed",
}
m["poz-nes"] = {
"Nese",
2157412,
"poz-vnc",
"Latn",
}
m["poz-oce-pro"] = {
"Proto-Oceanic",
141741,
"poz-oce",
"Latn",
type = "reconstructed",
}
m["poz-pcc-pro"] = {
"Proto-Central Pacific",
111962726,
"poz-pcc",
"Latn",
type = "reconstructed",
}
m["poz-pep-pro"] = {
"Proto-Eastern Polynesian",
113988745,
"poz-pep",
"Latn",
type = "reconstructed",
}
m["poz-pnp-pro"] = {
"Proto-Nuclear Polynesian",
113988746,
"poz-pnp",
"Latn",
type = "reconstructed",
}
m["poz-pol-pro"] = {
"Proto-Polynesian",
1658709,
"poz-pol",
"Latn",
type = "reconstructed",
}
m["poz-pro"] = {
"Proto-Malayo-Polynesian",
3832960,
"poz",
"Latn",
type = "reconstructed",
}
m["poz-sml"] = {
"Sarawak Malay",
4251702,
"poz-mly",
"Latn, Arab",
}
m["poz-ssw-pro"] = {
"Proto-South Sulawesi",
116773279,
"poz-ssw",
"Latn",
type = "reconstructed",
}
m["poz-swa-pro"] = {
"Proto-North Sarawak",
116773243,
"poz-swa",
"Latn",
type = "reconstructed",
}
m["poz-ter"] = {
"Terengganu Malay",
4207412,
"poz-mly",
"Latn, Arab",
}
m["pqe-pro"] = {
"Proto-Eastern Malayo-Polynesian",
2269883,
"pqe",
"Latn",
type = "reconstructed",
}
m["pra-niy"] = {
"Niya Prakrit",
11991601,
"inc-mid",
"Khar",
ancestors = "inc-ash",
translit = "Khar-translit",
}
m["qfa-adm-pro"] = {
"Proto-Great Andamanese",
116773756,
"qfa-adm",
"Latn",
type = "reconstructed",
}
m["qfa-bet-pro"] = {
"Proto-Be-Tai",
116773193,
"qfa-bet",
"Latn",
type = "reconstructed",
}
m["qfa-cka-pro"] = {
"Proto-Chukotko-Kamchatkan",
7251837,
"qfa-cka",
"Latn",
type = "reconstructed",
}
m["qfa-hur-pro"] = {
"Proto-Hurro-Urartian",
116773211,
"qfa-hur",
"Latn",
type = "reconstructed",
}
m["qfa-kad-pro"] = {
"Proto-Kadu",
116773770,
"qfa-kad",
"Latn",
type = "reconstructed",
}
m["qfa-kms-pro"] = {
"Proto-Kam-Sui",
55630682,
"qfa-kms",
"Latn",
type = "reconstructed",
}
m["qfa-kor-pro"] = {
"Proto-Koreanic",
467883,
"qfa-kor",
"Latn",
type = "reconstructed",
}
m["qfa-kra-pro"] = {
"Proto-Kra",
7251854,
"qfa-kra",
"Latn",
type = "reconstructed",
}
m["qfa-lic-pro"] = {
"Proto-Hlai",
7251845,
"qfa-lic",
"Latn",
type = "reconstructed",
}
m["qfa-onb-pro"] = {
"Proto-Be",
116773192,
"qfa-onb",
"Latn",
type = "reconstructed",
}
m["qfa-ong-pro"] = {
"Proto-Ongan",
116773801,
"qfa-ong",
"Latn",
type = "reconstructed",
}
m["qfa-tak-pro"] = {
"Proto-Kra-Dai",
104901616,
"qfa-tak",
"Latn",
type = "reconstructed",
}
m["qfa-yen-pro"] = {
"Proto-Yeniseian",
27639,
"qfa-yen",
"Latn",
type = "reconstructed",
}
m["qfa-yuk-pro"] = {
"Proto-Yukaghir",
116773294,
"qfa-yuk",
"Latn",
type = "reconstructed",
}
m["qwe-kch"] = {
"Kichwa",
1740805,
"qwe",
"Latn",
ancestors = "qu",
}
m["qwe-pro"] = {
"Proto-Quechuan",
5575757,
"qwe",
"Latn",
type = "reconstructed",
}
m["roa-ang"] = {
"Angevin",
56782,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-bbn"] = {
"Bourbonnais-Berrichon",
2899128,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-brg"] = {
"Bourguignon",
508332,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-can"] = {
"Cantabrian",
917021,
"roa-asl",
"Latn",
}
m["roa-cha"] = {
"Champenois",
430018,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-fcm"] = {
"Franc-Comtois",
510561,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-gal"] = {
"Gallo",
37300,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-gib"] = {
"Gallo-Italic of Basilicata",
3094838,
"roa-git",
ancestors = "pms-old",
"Latn",
}
m["roa-gis"] = {
"Gallo-Italic of Sicily",
2629019,
"roa-git",
"Latn",
ancestors = "pms-old",
}
m["roa-leo"] = {
"Leonese",
34108,
"roa-asl",
"Latn",
}
m["roa-lor"] = {
"Lorrain",
671198,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-oca"] = {
"Old Catalan",
15478520,
"roa-ocr",
"Latn",
sort_key = {remove_diacritics = c.grave .. c.acute .. c.diaer .. c.cedilla .. "·"},
}
m["roa-ole"] = {
"Old Leonese",
125977465,
"roa-asl",
"Latn",
}
m["roa-ona"] = {
"Old Navarro-Aragonese",
2736184,
"roa-nar",
"Latn",
}
m["roa-opt"] = {
"Old Galician-Portuguese",
1072111,
"roa-gap",
"Latn",
strip_diacritics = {remove_diacritics = c.grave .. c.acute .. c.circ},
}
m["roa-orl"] = {
"Orléanais",
28497058,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-poi"] = {
"Poitevin-Saintongeais",
514123,
"roa-oil",
"Latn",
sort_key = s["roa-oil-sortkey"],
}
m["roa-tar"] = {
"Tarantino",
695526,
"roa-itr",
"Latn",
wikimedia_codes = "roa-tara",
}
m["sai-all"] = {
"Allentiac",
19570789,
"sai-hrp",
"Latn",
}
m["sai-and"] = { -- not to be confused with 'cbc' or 'ano'
"Andoquero",
16828359,
"sai-wit",
"Latn",
}
m["sai-ayo"] = {
"Ayomán",
16937754,
"sai-jir",
"Latn",
}
m["sai-bae"] = {
"Baenan",
3401998,
"qfa-unc", -- extinct, poorly attested; only known through 9 words
"Latn",
}
m["sai-bag"] = {
"Bagua",
5390321,
"qfa-unc", -- extinct, poorly attested; possibly Cariban
"Latn",
}
m["sai-bet"] = {
"Betoi",
926551,
"qfa-iso",
"Latn",
}
m["sai-bor-pro"] = {
"Proto-Boran",
nil,
"sai-bor",
"Latn",
}
m["sai-cac"] = {
"Cacán",
945482,
"qfa-unc", -- extinct, poorly attested; no consensus on classification
"Latn",
}
m["sai-caq"] = {
"Caranqui",
2937753,
"sai-bar",
"Latn",
}
m["sai-car-pro"] = {
"Proto-Cariban",
116773196,
"sai-car",
"Latn",
type = "reconstructed",
}
m["sai-cat"] = {
"Catacao",
5051136,
"sai-ctc",
"Latn",
}
m["sai-cer-pro"] = {
"Proto-Cerrado",
116773200,
"sai-cer",
"Latn",
type = "reconstructed",
}
m["sai-chi"] = {
"Chirino",
5390321,
"qfa-unc", -- extinct, only four words known; possibly related to Candoshi-Shapra (cbu)
"Latn",
}
m["sai-chn"] = {
"Chaná",
5072718,
"sai-crn",
"Latn",
}
m["sai-chp"] = {
"Chapacura",
5072884,
"sai-cpc",
"Latn",
}
m["sai-chr"] = {
"Charrua",
5086680,
"sai-crn",
"Latn",
}
m["sai-chu"] = {
"Churuya",
5118339,
"sai-guh",
"Latn",
}
m["sai-cje-pro"] = {
"Proto-Central Jê",
116773198,
"sai-cje",
"Latn",
type = "reconstructed",
}
m["sai-cmg"] = {
"Comechingon",
6644203,
"qfa-unc", -- extinct, poorly attested; no consensus on classification
"Latn",
}
m["sai-cno"] = {
"Chono",
5104704,
"qfa-unc", -- extinct, poorly attested; no consensus on classification, possibly spurious
"Latn",
}
m["sai-cnr"] = {
"Cañari",
5055572,
"qfa-unc", -- extinct, poorly attested; possibly Chimuan or Barbacoan
"Latn",
}
m["sai-coe"] = {
"Coeruna",
6425639,
"sai-wit",
"Latn",
}
m["sai-col"] = {
"Colán",
5141893,
"sai-ctc",
"Latn",
}
m["sai-cop"] = {
"Copallén",
5390321,
"qfa-unc", -- extinct, only four words attested; possibly Cholonan
"Latn",
}
m["sai-crd"] = {
"Coroado Puri",
24191321,
"sai-mje",
"Latn",
}
m["sai-ctq"] = {
"Catuquinaru",
16858455,
"qfa-unc", -- extinct, poorly attested; vocabulary does not resemble other languages
"Latn",
}
m["sai-cul"] = {
"Culli",
2879660,
"qfa-unc", -- extinct, poorly attested; often considered an isolate
"Latn",
}
m["sai-cva"] = {
"Cueva",
5192644,
"qfa-unc", -- extinct, poorly attested; possibly Chocoan
"Latn",
}
m["sai-esm"] = {
"Esmeralda",
3058083,
"qfa-unc", -- extinct, poorly attested; possibly related to Yaruro
"Latn",
}
m["sai-ewa"] = {
"Ewarhuyana",
16898104,
nil,
"Latn",
}
m["sai-gam"] = {
"Gamela",
5403661,
"qfa-unc", -- extinct, poorly attested; possibly an isolate
"Latn",
}
m["sai-gay"] = {
"Gayón",
5528902,
"sai-jir",
"Latn",
}
m["sai-gmo"] = {
"Guamo",
5613495,
"qfa-unc", -- extinct; "Kaufman (1990) finds a connection with the Chapacuran languages convincing." [Wikipedia] Considered an isolate by Campbell (2024).
"Latn",
}
m["sai-gua"] = {
"Guachí",
5613172,
"sai-guc",
"Latn",
}
m["sai-gue"] = {
"Güenoa",
5626799,
"sai-crn",
"Latn",
}
m["sai-hau"] = {
"Haush",
3128376,
"sai-cho",
"Latn",
}
m["sai-jee-pro"] = {
"Proto-Jê",
116773212,
"sai-jee",
"Latn",
type = "reconstructed",
}
m["sai-jko"] = {
"Jeikó",
6176527,
"sai-mje",
"Latn",
}
m["sai-jrj"] = {
"Jirajara",
6202966,
"sai-jir",
"Latn",
}
m["sai-kat"] = { -- contrast xoo, kzw, sai-xoc
"Katembri",
6375925,
"qfa-unc", -- extinct, poorly attested; "Kaufman (1990) has linked it with the nearly extinct Taruma, although this has not been accepted by other scholars." [Wikipedia]
"Latn",
}
m["sai-krp"] = {
"Karipuna (Panoan)",
136296616,
"sai-pan",
"Latn",
}
m["sai-mal"] = {
"Malalí",
6741212,
"sai-mje", -- considered the most divergent Maxakalían language (a subdivision of Macro-Jê), for which we have no entry
"Latn",
}
m["sai-mar"] = {
"Maratino",
6755055,
"qfa-unc", -- extinct, poorly attested; possibly Uto-Aztecan
"Latn",
}
m["sai-mat"] = {
"Matanawi",
6786047,
"qfa-unc", -- extinct; either an isolate or distantly related to the Muran languages; Campbell (2024) lists it as an isolate, Glottolog gives it as unclassified
"Latn",
}
m["sai-mcn"] = {
"Mocana",
3402048,
"qfa-unc", -- extinct, poorly attested; given as part of the Malibu languages (geographic grouping; not a clade)
"Latn",
}
m["sai-men"] = {
"Menien",
16890110,
"sai-mje",
"Latn",
}
m["sai-mil"] = {
"Millcayac",
19573012,
"sai-hrp",
"Latn",
}
m["sai-mlb"] = {
"Malibu",
134374036,
"qfa-unc", -- extinct, poorly attested; given as part of the Malibu languages (geographic grouping; not a clade)
"Latn",
}
m["sai-msk"] = {
"Masakará",
6782426,
"sai-mje",
"Latn",
}
m["sai-muc"] = {
"Mucuchí",
6931290,
nil, -- generally considered Timotean, for which we have no entry
"Latn",
}
m["sai-mue"] = {
"Muellama",
16886936,
"sai-bar",
"Latn",
}
m["sai-muz"] = {
"Muzo",
6644203,
"qfa-unc", -- extinct language of Colombia, poorly attested; may be Pijao (Cariban)
"Latn",
}
m["sai-mys"] = {
"Maynas",
16919393,
"sai-cah", -- per Campbell (2024); formerly considered unclassified
"Latn",
}
m["sai-nat"] = {
"Natú",
9006749,
"qfa-unc", -- extinct, poorly attested; "only Greenberg dares to classify [it]".[Wikipedia, quoting Moseley, Christopher; Asher, R. E.; Tait, Mary (1994), Atlas of the world's languages]
"Latn",
}
m["sai-nje-pro"] = {
"Proto-Northern Jê",
116773245,
"sai-nje",
"Latn",
type = "reconstructed",
}
m["sai-opo"] = {
"Opón",
7099152,
"sai-car",
"Latn",
}
m["sai-oto"] = {
"Otomaco",
16879234,
"sai-otm",
"Latn",
}
m["sai-pal"] = {
"Palta",
3042978,
"qfa-unc", -- extinct, unclassified; possibly Chicham
"Latn",
}
m["sai-pam"] = {
"Pamigua",
5908689,
"sai-tin",
"Latn",
}
m["sai-par"] = {
"Paratió",
16890038,
"qfa-unc", -- extinct, poorly attested; possibly Xukuruan
"Latn",
}
m["sai-ptx"] = {
"Pataxó",
7144304,
"sai-mje",
"Latn",
}
m["sai-peb"] = {
"Peba",
3373890,
"sai-pey",
"Latn",
}
m["sai-pnz"] = {
"Panzaleo",
3123275,
"qfa-unc", -- extinct, unclassified; possibly Paezan
"Latn",
}
m["sai-prh"] = {
"Puruhá",
3410994,
"qfa-unc", -- extinct, poorly attested; possibly in a famil with Cañari
"Latn",
}
m["sai-ptg"] = {
"Patagón",
128807870,
"sai-tar", -- extinct, only known from 4 words, which suggest Cariban lineage (Campbell 2024)
"Latn",
}
m["sai-pur"] = {
"Purukotó",
7261622,
"sai-pem",
"Latn",
}
m["sai-pyg"] = {
"Payaguá",
7156643,
"sai-guc",
"Latn",
}
m["sai-pyk"] = {
"Pykobjê",
98113977,
"sai-nje",
"Latn",
}
m["sai-qmb"] = {
"Quimbaya",
7272043,
"qfa-unc", -- extinct, might not exist; few known words
"Latn",
}
m["sai-qtm"] = {
"Quitemo",
7272651,
"sai-cpc",
"Latn",
}
m["sai-rab"] = {
"Rabona",
6644203,
"qfa-unc", -- extinct, poorly attested, mostly plant names; possibly Candoshi-Shapra
"Latn",
}
m["sai-ram"] = {
"Ramanos",
16902824,
"qfa-unc", -- extinct, poorly attested, possibly an isolate; per Glottolog: "the minuscule wordlist ... shows no convincing resemblances to surrounding languages"
"Latn",
}
m["sai-sac"] = {
"Sácata",
5390321,
"qfa-unc", -- extinct, only 3 words known; possibly Candoshí or Arawakan
"Latn",
}
m["sai-san"] = {
"Sanaviron",
16895999,
"qfa-unc", -- extinct, unclassified; no consensus on classification
"Latn",
}
m["sai-sap"] = {
"Sapará",
7420922,
"sai-car",
"Latn",
}
m["sai-sec"] = {
"Sechura",
7442912,
"qfa-unc", -- extinct, poorly attested; possibly Catacaoan
"Latn",
}
m["sai-sin"] = {
"Sinúfana",
7525275,
"qfa-unc", -- moribund, poorly attested; possibly Chocoan
"Latn",
}
m["sai-sje-pro"] = {
"Proto-Southern Jê",
116773814,
"sai-sje",
"Latn",
type = "reconstructed",
}
m["sai-tab"] = {
"Tabancale",
5390321,
"qfa-unc", -- extinct, only 5 words known; no obvious connections, might be an isolate
"Latn",
}
m["sai-tal"] = {
"Tallán",
16910468,
"qfa-unc", -- extinct, poorly attested; might be Catacaoan
"Latn",
}
m["sai-tap"] = {
"Tapayuna",
30719984,
"sai-nje",
"Latn",
}
m["sai-tar-pro"] = {
"Proto-Taranoan",
116773816,
"sai-tar",
"Latn",
type = "reconstructed",
}
m["sai-teu"] = {
"Teushen",
3519243,
"qfa-unc", -- probably extinct by the 1950's; possibly Chonan
"Latn",
}
m["sai-tim"] = {
"Timote",
7806995,
nil, -- possibly in a small Timotean family
"Latn",
}
m["sai-tpr"] = {
"Taparita",
7684460,
"sai-otm",
"Latn",
}
m["sai-trr"] = {
"Tarairiú",
7685313,
"qfa-unc", -- extinct, too poorly attested to classify
"Latn",
}
m["sai-wai"] = {
"Waitaká",
16918610,
"qfa-unc", -- extinct, possibly Purian
"Latn",
}
m["sai-way"] = {
"Wayumara",
7960726,
"sai-car",
"Latn",
}
m["sai-wit-pro"] = {
"Proto-Witotoan",
116773823,
"sai-wit",
"Latn",
type = "reconstructed",
}
m["sai-wnm"] = {
"Wanham",
16879440,
"sai-cpc",
"Latn",
}
m["sai-xoc"] = { -- contrast xoo, kzw, sai-kat
"Xocó",
12953620,
"qfa-unc", -- extinct and poorly attested; not clear if one or three languages
"Latn",
}
m["sai-yao"] = {
"Yao (South America)",
16979655,
"sai-ven",
"Latn",
}
m["sai-yar"] = { -- not the same family as 'suy'
"Yarumá",
3505859,
"sai-pek",
"Latn",
}
m["sai-yri"] = {
"Yuri",
2669157,
"sai-tyu",
"Latn",
}
m["sai-yup"] = {
"Yupua",
8061430,
"sai-tuc",
"Latn",
}
m["sai-yur"] = {
"Yurumanguí",
1281291,
"qfa-unc", -- extinct, too poorly attested to classify
"Latn",
}
m["sal-pro"] = {
"Proto-Salish",
116773269,
"sal",
"Latn",
type = "reconstructed",
}
m["sdv-daj-pro"] = {
"Proto-Daju",
116773739,
"sdv-daj",
"Latn",
type = "reconstructed",
}
m["sdv-eje-pro"] = {
"Proto-Eastern Jebel",
116773751,
"sdv-eje",
"Latn",
type = "reconstructed",
}
m["sdv-nil-pro"] = {
"Proto-Nilotic",
116773794,
"sdv-nil",
"Latn",
type = "reconstructed",
}
m["sdv-nyi-pro"] = {
"Proto-Nyima",
116773796,
"sdv-nyi",
"Latn",
type = "reconstructed",
}
m["sdv-tmn-pro"] = {
"Proto-Taman",
116773815,
"sdv-tmn",
"Latn",
type = "reconstructed",
}
m["sel-nor"] = {
"Northern Selkup",
30304565,
"sel",
"Cyrl",
translit = "sel-nor-translit",
}
m["sel-pro"] = {
"Proto-Selkup",
128884235,
"sel",
"Latn",
type = "reconstructed",
}
m["sel-sou"] = {
"Southern Selkup",
30304639,
"sel",
"Cyrl",
translit = "sel-sou-translit",
}
m["sem-amm"] = {
"Ammonite",
279181,
"sem-can",
"Phnx",
-- Phnx translit in [[Module:scripts/data]]
}
m["sem-amo"] = {
"Amorite",
35941,
"sem-nwe",
"Xsux, Latn",
}
m["sem-cha"] = {
"Chaha",
35543,
"sem-eth",
"Ethi",
translit = "Ethi-translit",
}
m["sem-dad"] = {
"Dadanitic",
21838040,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-dum"] = {
"Dumaitic",
128810397,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-has"] = {
"Hasaitic",
3541433,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-his"] = {
"Hismaic",
22948260,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-mhr"] = {
"Muher",
33743,
"sem-eth",
"Latn",
}
m["sem-pro"] = {
"Proto-Semitic",
1658554,
"sem",
"Latn",
type = "reconstructed",
}
m["sem-saf"] = {
"Safaitic",
472586,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-sam"] = {
"Samalian",
85847147,
"sem-nwe",
"Phnx",
-- Phnx translit in [[Module:scripts/data]]
}
m["sem-srb"] = {
"Old South Arabian",
35025,
"sem-osa",
"Sarb",
-- Sarb translit in [[Module:scripts/data]]
}
m["sem-tay"] = {
"Taymanitic",
24912301,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-tha"] = {
"Thamudic",
843030,
"sem-cen",
"Narb",
-- Narb translit in [[Module:scripts/data]]
}
m["sem-wes-pro"] = {
"Proto-West Semitic",
98021726,
"sem-wes",
"Latn",
type = "reconstructed",
}
m["sio-pro"] = { -- NB this is not Proto-Siouan-Catawban 'nai-sca-pro'
"Proto-Siouan",
34181,
"sio",
"Latn",
type = "reconstructed",
}
m["sit-aao-pro"] = {
"Proto-Central Naga",
nil,
"sit-aao",
"Latn",
type = "reconstructed",
}
m["sit-bai-pro"] = {
"Proto-Bai",
nil,
"sit-bai",
"Latn",
type = "reconstructed",
}
m["sit-ban"] = {
"Bangru",
56071779,
"sit-hrs",
"Latn",
}
m["sit-bdi-pro"] = {
"Proto-Bodish",
nil,
"sit-bdi",
"Latn",
type = "reconstructed",
}
m["sit-bok"] = {
"Bokar",
4938727,
"sit-tan",
"Latn, Tibt",
override_translit = true,
-- Tibt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["sit-cai"] = {
"Caijia",
5017528,
"sit-cln",
"Latn"
}
m["sit-cha"] = {
"Chairel",
5068066,
"sit-luu",
"Latn",
}
m["sit-ers-pro"] = {
"Proto-Ersuic",
nil,
"sit-ers",
"Latn",
type = "reconstructed",
}
m["sit-hrs-pro"] = {
"Proto-Hrusish",
116773762,
"sit-hrs",
"Latn",
type = "reconstructed",
}
m["sit-jap"] = {
"Japhug",
3162245,
"sit-egy",
"Latn",
}
m["sit-kha-pro"] = {
"Proto-Kham",
116773773,
"sit-kha",
"Latn",
type = "reconstructed",
}
m["sit-khb-pro"] = {
"Proto-Kho-Bwa",
nil,
"sit-khb",
"Latn",
type = "reconstructed",
}
m["sit-khp-pro"] = {
"Proto-Puroik",
nil,
"sit-khb",
"Latn",
type = "reconstructed",
}
m["sit-khw-pro"] = {
"Proto-Western Kho-Bwa",
nil,
"sit-khw",
"Latn",
type = "reconstructed",
}
m["sit-kon-pro"] = {
"Proto-Northern Naga",
nil,
"sit-kon",
"Latn",
type = "reconstructed",
}
m["sit-liz"] = {
"Lizu",
6660653,
"sit-ers",
"Latn", -- and Ersu Shaba
}
m["sit-lnj"] = {
"Longjia",
17096251,
"sit-cln",
"Latn"
}
m["sit-lrn"] = {
"Luren",
16946370,
"sit-cln",
"Latn"
}
m["sit-luu-pro"] = {
"Proto-Luish",
116773783,
"sit-luu",
"Latn",
type = "reconstructed",
}
m["sit-nas-pro"] = {
"Proto-Naish",
nil,
"sit-nas",
"Latn",
type = "reconstructed",
}
m["sit-prn"] = {
"Puiron",
7259048,
"sit-zem",
}
m["sit-pro"] = {
"Proto-Sino-Tibetan",
24839178,
"sit",
"Latn",
type = "reconstructed",
}
m["sit-sit"] = {
"Situ",
19840830,
"sit-egy",
"Latn",
}
m["sit-tam-pro"] = {
"Proto-Tamangic",
117469295,
"sit-tam",
"Latn",
type = "reconstructed",
}
m["sit-tan-pro"] = {
"Proto-Tani",
116773284,
"sit-tan",
"Latn", -- needs verification
type = "reconstructed",
}
m["sit-tgm"] = {
"Tangam",
17041370,
"sit-tan",
"Latn",
}
m["sit-tng-pro"] = {
"Proto-Tangkhulic",
nil,
"sit-tng",
"Latn",
type = "reconstructed"
}
m["sit-tos"] = {
"Tosu",
7827899,
"sit-ers",
"Latn", -- also Ersu Shaba
}
m["sit-tsh"] = {
"Tshobdun",
19840950,
"sit-egy",
"Latn",
}
m["sit-zbu"] = {
"Zbu",
19841106,
"sit-egy",
"Latn",
}
m["sla-pro"] = {
"Proto-Slavic",
747537,
"sla",
"Latn",
type = "reconstructed",
strip_diacritics = {
remove_diacritics = c.grave .. c.acute .. c.tilde .. c.macron .. c.dgrave .. c.invbreve,
remove_exceptions = {'ś'},
},
sort_key = {
from = {"č", "ď", "ě", "ę", "ь", "ľ", "ň", "ǫ", "ř", "š", "ś", "ť", "ъ", "ž"},
to = {"c²", "d²", "e²", "e³", "i²", "l²", "nj", "o²", "r²", "s²", "s³", "t²", "u²", "z²"},
}
}
m["smi-pro"] = {
"Proto-Sami",
7251862,
"smi",
"Latn",
type = "reconstructed",
sort_key = {
from = {"ā", "č", "δ", "[ëē]", "ŋ", "ń", "ō", "š", "θ", "%([^()]+%)"},
to = {"a", "c²", "d", "e", "n²", "n³", "o", "s²", "t²"}
},
}
m["son-pro"] = {
"Proto-Songhay",
116773277,
"son",
"Latn",
type = "reconstructed",
}
m["sqj-pro"] = {
"Proto-Albanian",
18210846,
"sqj",
"Latn",
type = "reconstructed",
}
m["ssa-klk-pro"] = {
"Proto-Kuliak",
116773779,
"ssa-klk",
"Latn",
type = "reconstructed",
}
m["ssa-kom-pro"] = {
"Proto-Koman",
116773775,
"ssa-kom",
"Latn",
type = "reconstructed",
}
m["ssa-pro"] = {
"Proto-Nilo-Saharan",
116773236,
"ssa",
"Latn",
type = "reconstructed",
}
m["syd-pro"] = {
"Proto-Samoyedic",
7251863,
"syd",
"Latn",
type = "reconstructed",
}
m["tai-pro"] = {
"Proto-Tai",
6583709,
"tai",
"Latn",
type = "reconstructed",
}
m["tai-swe-pro"] = {
"Proto-Southwestern Tai",
116773280,
"tai-swe",
"Latn",
type = "reconstructed",
}
m["tbq-bdg-pro"] = {
"Proto-Bodo-Garo",
116773195,
"tbq-bdg",
"Latn",
type = "reconstructed",
}
m["tbq-blg"] = {
"Bailang",
2879843,
"tbq-lob",
"Hani",
sort_key = "Hani-sortkey",
}
m["tbq-brm-pro"] = {
"Proto-Burmish",
nil,
"tbq-brm",
"Latn",
type = "reconstructed",
}
m["tbq-gkh"] = {
"Gokhy",
5578069,
"tbq-sil",
"Latn",
}
m["tbq-kuk-pro"] = {
"Proto-Kuki-Chin",
116773220,
"tbq-kuk",
"Latn",
type = "reconstructed",
}
m["tbq-lal-pro"] = {
"Proto-Lalo",
116773781,
"tbq-lal",
"Latn",
type = "reconstructed",
}
m["tbq-laz"] = {
"Laze",
17007626,
"sit-nas",
"Latn",
}
m["tbq-lob-pro"] = {
"Proto-Lolo-Burmese",
116773224,
"tbq-lob",
"Latn",
type = "reconstructed",
}
m["tbq-lol-pro"] = {
"Proto-Loloish",
7251855,
"tbq-lol",
"Latn",
type = "reconstructed",
}
m["tbq-mil"] = {
"Milang",
6850761,
"sit-gsi",
"Deva, Latn",
}
m["tbq-mor"] = {
"Moran",
6909216,
"tbq-bdg",
"Latn",
}
m["tbq-ngo"] = {
"Ngochang",
56582,
"tbq-brm",
"Latn",
}
-- tbq-pro is now etymology-only
m["trk-dkh"] = {
"Dukhan",
12809273,
"trk-ssb",
"Latn, Cyrl, Mong",
-- Mong translit, display_text and strip_diacritics in [[Module:scripts/data]]
}
-- As described in Mahmud al-Kashgari's 11th century ''Dīwān Lughāt al-Turk''.
m["trk-eog"] = {
"Early Old Oghuz",
nil,
"trk-ogz",
"Arab",
strip_diacritics = {Arab = "ar-stripdiacritics"},
}
m["trk-oat"] = {
"Old Anatolian Turkish",
7083390,
"trk-ogz",
"Arab",
strip_diacritics = {Arab = "ar-stripdiacritics"},
ancestors = "trk-eog",
}
m["trk-pro"] = {
"Proto-Turkic",
3657773,
"trk",
"Latn",
type = "reconstructed",
standard_chars = {
Latn = " ()-abdegiklmnoprstuxyzïöüāčēīĺŋōŕšūǖȫẹ" .. c.macron,
}
}
m["tup-gua-pro"] = {
"Proto-Tupi-Guarani",
116773288,
"tup-gua",
"Latn",
type = "reconstructed",
}
m["tup-kab"] = {
"Kabishiana",
15302988,
"tup",
"Latn",
}
m["tup-kaw"] = {
"Kawahiva",
6346712,
"tup-gua",
"Latn",
}
m["tup-pro"] = {
"Proto-Tupian",
10354700,
"tup",
"Latn",
type = "reconstructed",
}
m["tuw-alk"] = {
"Alchuka",
113553616,
"tuw-jrc",
"Latn, Hans",
sort_key = {Hans = "Hani-sortkey"},
}
m["tuw-bal"] = {
"Bala",
86730632,
"tuw-jrc",
"Latn, Hans",
sort_key = {Hans = "Hani-sortkey"},
}
m["tuw-kkl"] = {
"Kyakala",
118875708,
"tuw-jrc",
"Latn, Hans",
sort_key = {Hans = "Hani-sortkey"},
}
m["tuw-kli"] = {
"Kili",
6406892,
"tuw-ewe",
"Cyrl",
}
m["tuw-pro"] = {
"Proto-Tungusic",
85872335,
"tuw",
"Latn",
type = "reconstructed",
}
m["tuw-sol"] = {
"Solon",
30004,
"tuw-ewe",
}
m["urj-fin-pro"] = {
"Proto-Finnic",
11883720,
"urj-fin",
"Latn",
type = "reconstructed",
}
m["urj-koo"] = {
"Old Komi",
86679962,
"kv",
"Perm, Cyrs",
translit = "urj-koo-translit",
-- Cyrs strip_diacritics, sort_key in [[Module:scripts/data]]; previously, Cyrs strip_diacritics not present
}
m["urj-kuk"] = {
"Kukkuzi",
107410460,
"urj-fin",
"Latn",
ancestors = "vot",
}
m["urj-kya"] = {
"Komi-Yazva",
2365210,
"kv",
"Cyrl",
translit = "kv-translit",
override_translit = true,
strip_diacritics = {remove_diacritics = c.acute},
}
m["urj-mdv-pro"] = {
"Proto-Mordvinic",
116773232,
"urj-mdv",
"Latn",
type = "reconstructed",
}
m["urj-prm-pro"] = {
"Proto-Permic",
116773257,
"urj-prm",
"Latn",
type = "reconstructed",
}
m["urj-pro"] = {
"Proto-Uralic",
288765,
"urj",
"Latn",
type = "reconstructed",
}
m["urj-ugr-pro"] = {
"Proto-Ugric",
156631,
"urj-ugr",
"Latn",
type = "reconstructed",
}
m["xnd-pro"] = {
"Proto-Na-Dene",
116773233,
"xnd",
"Latn",
type = "reconstructed",
}
m["xgn-pro"] = {
"Proto-Mongolic",
2493677,
"xgn",
"Latn",
type = "reconstructed",
sort_key = {
from = {"č", "i", "ï", "ǰ", "ŋ", "ö", "š", "ü"},
to = {"c", "i" .. p[1], "i", "j", "n" .. p[1], "o" .. p[1], "s" .. p[1], "u" .. p[1]},
},
}
m["yok-bvy"] = {
"Buena Vista Yokuts",
4985474,
"yok",
"Latn",
}
m["yok-dly"] = {
"Delta Yokuts",
70923266,
"yok",
"Latn",
}
m["yok-gsy"] = {
"Gashowu Yokuts",
3098708,
"yok",
"Latn",
}
m["yok-kry"] = {
"Kings River Yokuts",
6413014,
"yok",
"Latn",
}
m["yok-nvy"] = {
"Northern Valley Yokuts",
85789777,
"yok",
"Latn",
}
m["yok-ply"] = {
"Palewyami Yokuts",
2387391,
"yok",
"Latn",
}
m["yok-svy"] = {
"Southern Valley Yokuts",
12642473,
"yok",
"Latn",
}
m["yok-tky"] = {
"Tule-Kaweah Yokuts",
7851988,
"yok",
"Latn",
}
m["ypk-pro"] = {
"Proto-Yupik",
116773295,
"ypk",
"Latn",
type = "reconstructed",
display_text = s["esx-displaytext"],
strip_diacritics = s["esx-stripdiacritics"],
}
m["yrk-for"] = {
"Forest Nenets",
1295107,
"yrk",
"Cyrl",
translit = "yrk-for-translit",
strip_diacritics = {remove_diacritics = c.grave .. c.acute .. c.macron .. c.breve .. c.dotabove},
}
m["yrk-tun"] = {
"Tundra Nenets",
36452,
"yrk",
"Cyrl",
strip_diacritics = {
from = {"ӑ", "а̄", "э̇", "ӣ", "ы̄", "ӯ", "ю̄", "я̆", "я̄"},
to = {"а", "а", "э", "и", "ы", "у", "ю", "я", "я"},
},
translit = "yrk-tun-translit",
}
m["zhx-min-pro"] = {
"Proto-Min",
19646347,
"zhx-min",
"Latn",
type = "reconstructed",
}
m["zhx-sht"] = {
"Shaozhou Tuhua",
1920769,
"zhx",
"Nshu, Hants",
generate_alternants = "zh-generatealternants",
sort_key = {Hani = "Hani-sortkey"},
}
m["zhx-sic"] = {
"Sichuanese",
2278732,
"zhx-man",
"Hants",
generate_alternants = "zh-generatealternants",
translit = "zh-translit",
sort_key = "Hani-sortkey",
}
m["zhx-tai"] = {
"Taishanese",
2208940,
"zhx-yue",
"Hants",
generate_alternants = "zh-generatealternants",
translit = "zh-translit",
sort_key = "Hani-sortkey",
}
m["zle-ono"] = {
"Old Novgorodian",
162013,
"zle",
"Cyrs, Glag",
translit = {Cyrs = "Cyrs-translit", Glag = "Glag-translit"},
-- Cyrs strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["zle-ort"] = {
"Old Ruthenian",
13211,
"zle",
"Arab, Cyrs, Latn",
ancestors = "orv",
translit = {
Cyrs = "zle-ort-translit",
Arab = "zle-ort-Arab-translit",
},
strip_diacritics = {
Cyrs = {
remove_diacritics = m_langdata.chars_substitutions["Cyrs_remove_diacritics"],
remove_exceptions = {"Ї", "ї"},
},
Arab = "ar-stripdiacritics",
},
-- Cyrs sort_key in [[Module:scripts/data]]
}
m["zls-chs"] = {
"Church Slavonic",
33251,
"zls",
"Cyrs, Glag, Latn",
ancestors = "cu",
translit = {
Cyrs = "Cyrs-translit",
Glag = "Glag-translit"
},
-- Cyrs strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["zlw-ocs"] = {
"Old Czech",
593096,
"zlw",
"Latn",
}
m["zlw-opl"] = {
"Old Polish",
149838,
"zlw-lch",
"Latn",
strip_diacritics = {remove_diacritics = c.ringabove},
}
m["zlw-osk"] = {
"Old Slovak",
12776676,
"zlw",
"Latn",
}
m["zlw-slv"] = {
"Slovincian",
36822,
"zlw-pom",
"Latn",
strip_diacritics = {remove_diacritics = c.macron .. c.breve},
}
return require("Module:languages").finalizeData(m, "language")
dw5rxrt2l3v52omvn971c4y3m78x6ee
Module:languages/data/3/e
828
8078
54908
2026-09-28T23:23:01Z
Deadend0914
7211
Gesceop tramet þe hafaþ 'local m_langdata = require("Module:languages/data") -- Loaded on demand, as it may not be needed (depending on the data). local function u(...) u = require("Module:string utilities").char return u(...) end local c = m_langdata.chars local p = m_langdata.puaChars local s = m_langdata.shared local m = {} m["ebg"] = { "Ebughu", 35294, "nic-lcr", "Latn", } m["ebk"] = { "Eastern Bontoc", 62664215, "phi", "Latn", } m["ebr"] = { "Ebrié", 36644, "alv-...'
54908
Scribunto
text/plain
local m_langdata = require("Module:languages/data")
-- Loaded on demand, as it may not be needed (depending on the data).
local function u(...)
u = require("Module:string utilities").char
return u(...)
end
local c = m_langdata.chars
local p = m_langdata.puaChars
local s = m_langdata.shared
local m = {}
m["ebg"] = {
"Ebughu",
35294,
"nic-lcr",
"Latn",
}
m["ebk"] = {
"Eastern Bontoc",
62664215,
"phi",
"Latn",
}
m["ebr"] = {
"Ebrié",
36644,
"alv-ptn",
"Latn",
}
m["ebu"] = {
"Embu",
35318,
"bnt-kka",
"Latn",
}
m["ecr"] = {
"Eteocretan",
35461,
"qfa-unc",
"Polyt",
-- Polyt translit, display_text, strip_diacritics, sort_key in [[Module:scripts/data]]
}
m["ecs"] = {
"Ecuadorian Sign Language",
3436769,
"sgn",
"Latn", -- when documented
}
m["ecy"] = {
"Eteocypriot",
35309,
"qfa-unc",
"Cprt",
}
m["eee"] = {
"E",
35386,
"qfa-mix",
"Hani, Latn",
sort_key = {Hani = "Hani-sortkey"},
}
m["efa"] = {
"Efai",
3813297,
"nic-ief",
"Latn",
}
m["efe"] = {
"Efe",
56354,
"csu-mle",
"Latn",
}
m["efi"] = {
"Efik",
35377,
"nic-ief",
"Latn",
}
m["ega"] = {
"Ega",
3914927,
"alv",
"Latn",
}
m["egl"] = {
"Emilian",
1057898,
"roa-emr",
ancestors = "egl-old",
"Latn",
wikimedia_codes = "eml",
}
m["ego"] = {
"Eggon",
35300,
"nic-pls",
"Latn",
}
m["egy"] = {
"Egyptian",
50868,
"egx",
"Latn, Egyp, Egyh",
sort_key = {
remove_diacritics = "'%-%s",
from = {"ꜣ", "j", "y", "ꜥ", "w", "b", "p", "f", "m", "n", "r", "ḥ", "ḫ", "ẖ", "h", "z", "š", "s", "q", "k", "g", "ṯ", "t", "ḏ", "d", "%."},
to = {p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[13], p[14], p[15], p[12], p[16], p[18], p[17], p[19], p[20], p[21], p[23], p[22], p[25], p[24], p[26]}
},
}
m["ehu"] = {
"Ehueun",
3441392,
"alv-nwd",
"Latn",
}
m["eip"] = {
"Eipomek",
5349839,
"ngf-mek",
"Latn",
}
m["eit"] = {
"Eitiep",
5350030,
"paa-kom",
"Latn",
}
m["eiv"] = {
"Askopan",
56324,
"paa-nbo",
"Latn",
}
m["eja"] = {
"Ejamat",
6269820,
"alv-jfe",
"Latn",
}
m["eka"] = {
"Ekajuk",
35250,
"nic-eko",
"Latn",
}
m["eke"] = {
"Ekit",
3509628,
"nic-ief",
"Latn",
}
m["ekg"] = {
"Ekari",
5350305,
"ngf-pan",
"Latn",
}
m["eki"] = {
"Eki",
5350418,
"nic-ief",
"Latn",
}
m["ekl"] = {
"Kolhe",
6426945,
"mun",
"Latn",
}
m["ekm"] = {
"Elip",
12952414,
"nic-ymb",
"Latn",
}
m["eko"] = {
"Koti",
29930,
"bnt-mak",
"Latn",
}
m["ekp"] = {
"Ekpeye",
35254,
"alv-igb",
"Latn",
}
m["ekr"] = {
"Yace",
36901,
"alv-ido",
"Latn",
}
m["eky"] = {
"Eastern Kayah",
25559417,
"kar",
"Kali",
}
m["ele"] = {
"Elepi",
5359444,
"paa-mar",
"Latn",
}
m["elh"] = {
"El Hugeirat",
5351410,
"nub-hil",
"Latn",
}
m["eli"] = {
"Nding",
36176,
"alv-tal",
"Latn",
}
m["elk"] = {
"Elkei",
5364210,
"paa-wap",
"Latn",
}
m["elm"] = {
"Eleme",
3914427,
"nic-ogo",
"Latn",
}
m["elo"] = {
"El Molo",
56719,
"cus-eas",
"Latn",
}
m["elu"] = {
"Elu",
3364594,
"poz-aay",
"Latn",
}
m["elx"] = {
"Elamite",
35470,
"qfa-iso", --ancient language of Iran
"Xsux",
}
m["ema"] = {
"Emai",
35428,
"alv-eeo",
"Latn",
}
m["emb"] = {
"Embaloh",
5369424,
"poz",
"Latn",
}
m["eme"] = {
"Emerillon",
3588942,
"tup-gua",
"Latn",
}
m["emg"] = {
"Eastern Meohang",
12952840,
"sit-kie",
"Deva",
}
m["emi"] = {
"Mussau-Emira",
6943093,
"poz-stm",
"Latn",
}
m["emk"] = {
"Eastern Maninkakan",
11002130,
"dmn-mnk",
"Latn, Arab, Nkoo",
}
m["emm"] = {
"Mamulique",
3285082,
"nai-pak",
"Latn",
}
m["emn"] = {
"Eman",
5368975,
"nic-tvc",
"Latn",
}
m["emp"] = {
"Northern Emberá",
2391297,
"sai-chc",
"Latn",
}
m["ems"] = {
"Alutiiq",
27992,
"ypk",
"Latn",
}
m["emu"] = {
"Eastern Muria",
12952883,
"dra-mur",
"Deva",
}
m["emw"] = {
"Emplawas",
5374265,
"poz-tim",
"Latn",
}
m["emx"] = {
"Erromintxela",
1122188,
"qfa-mix",
"Latn",
ancestors = "rom, eu",
}
m["emy"] = {
"Epigraphic Mayan",
301355,
"myn",
"Latn, Maya",
}
m["ena"] = {
"Apali",
3504201,
"ngf-sog",
"Latn",
}
m["enb"] = {
"Markweeta",
56874,
"sdv-nma",
"Latn",
}
m["enc"] = {
"En",
3504110,
"qfa-buy",
"Latn",
}
m["end"] = {
"Ende",
2067656,
"poz-cet",
"Latn",
}
m["enf"] = {
"Forest Enets",
30249597,
"syd-ene",
"Cyrl",
}
m["enh"] = {
"Tundra Enets",
25559411,
"syd-ene",
"Cyrl",
}
m["enl"] = {
"Enlhet",
15462671,
"sai-mas",
"Latn",
}
m["enm"] = {
"Middle English",
36395,
"gmw-ang",
"Latn",
strip_diacritics = {remove_diacritics = c.acute .. c.circ .. c.macron .. c.breve .. c.dotabove .. c.diaer .. c.dacute .. c.dotbelow .. c.tacute},
sort_key = {
remove_diacritics = c.acute .. c.circ .. c.macron .. c.breve .. c.dotabove .. c.diaer .. c.dacute .. c.dotbelow .. c.tacute,
from = {"[ꟓꟕ]", "[æðᵹꟑȝœẜþꟃƿ]"},
to = {
{
["ꟓ"] = "þþ", ["ꟕ"] = "ƿƿ", -- finalized by the next substitution
},
{
["æ"] = "ae", ["ð"] = "d" .. p[1], ["ᵹ"] = "g", ["ꟑ"] = "g", ["ȝ"] = "g" .. p[1],
["œ"] = "oe", ["ẜ"] = "s", ["þ"] = "t" .. p[1], ["ꟃ"] = "w", ["ƿ"] = "w",
},
},
},
standard_chars = {
Latn = "AaÆæBbCcDdÐðEeFfGgȜȝHhIiJjKkLlMmNnOoPpQqRrSsTtÞþUuVvWwXxYyZz",
c.punc,
},
}
m["enn"] = {
"Engenni",
3915365,
"alv-dlt",
"Latn",
}
m["eno"] = {
"Enggano",
2669164,
"poz",
"Latn",
}
m["enq"] = {
"Enga",
1143040,
"ngf-enc",
"Latn",
}
m["enr"] = {
"Emem",
5370369,
"paa-epw",
"Latn",
}
m["enu"] = {
"Enu",
5380858,
"tbq-bka",
}
m["env"] = {
"Enwan",
3438334,
"alv-yek",
"Latn",
}
m["enw"] = {
"Enwang",
11134434,
"nic-lcr",
"Latn",
}
m["enx"] = {
"Enxet",
15462609,
"sai-mas",
"Latn",
}
m["eot"] = {
"Eotile",
3915347,
"alv-ptn",
"Latn",
}
m["epi"] = {
"Epie",
35291,
"alv-dlt",
"Latn",
}
m["era"] = {
"Eravallan",
5385061,
"dra-tam",
"Taml",
}
m["erg"] = {
"Sie",
426254,
"poz-vns",
"Latn",
}
m["erh"] = {
"Eruwa",
3441244,
"alv-swd",
"Latn",
}
m["eri"] = {
"Ogea",
7079984,
"ngf-nur",
"Latn",
}
m["erk"] = {
"South Efate",
3449070,
"poz-vnc",
"Latn",
}
m["err"] = {
"Erre",
10488401,
"qfa-iso", -- Evans (1997) put it in an Arnhem Land family
"Latn",
}
m["ers"] = {
"Ersu",
12952417,
"sit-ers",
"Latn", -- also Ersu Shaba
}
m["ert"] = {
"Eritai",
56376,
"paa-clp",
"Latn",
}
m["erw"] = {
"Erokwanas",
5395296,
"poz-hce",
"Latn",
}
m["ese"] = {
"Ese Ejja",
2980381,
"sai-tac",
"Latn",
}
m["esh"] = {
"Eshtehardi",
12952418,
"xme-ttc",
"Arab, Latn",
ancestors = "xme-ttc-sou",
}
-- "esi" and "esk" moved to etymology-only per [[WT:LT]] and [[Wiktionary:Beer_parlour/2023/August#Issues_regarding_the_Inuit_languages]]
m["esl"] = {
"Egyptian Sign Language",
5348443,
"sgn",
}
m["esm"] = {
"Esuma",
16927555,
"alv-kwa",
"Latn",
}
m["esn"] = {
"Salvadoran Sign Language",
7406492,
"sgn",
"Latn", -- when documented
}
m["eso"] = {
"Estonian Sign Language",
3196221,
"sgn",
"Latn", -- when documented
}
m["esq"] = {
"Esselen",
1294243,
"qfa-dis", -- isolate or Hokan
"Latn",
}
m["ess"] = {
"Central Siberian Yupik",
27993,
"ypk",
"Cyrl, Latn",
}
m["esu"] = {
"Yup'ik",
21117,
"ypk",
"Latn",
}
m["esy"] = {
"Eskayan",
867086,
"art",
"Latn", -- also its own native script
}
m["etb"] = {
"Etebi",
11002851,
"nic-ief",
"Latn",
}
m["etc"] = {
"Etchemin",
5402493,
"alg-eas",
"Latn",
}
m["eth"] = {
"Ethiopian Sign Language",
3501903,
"sgn-asl",
}
m["etn"] = {
"Eton (Vanuatu)",
3059362,
"poz-vnc",
"Latn",
}
m["eto"] = {
"Eton (Cameroon)",
35317,
"bnt-btb",
"Latn",
}
m["etr"] = {
"Edolo",
5340184,
"ngf-bos",
"Latn",
}
m["ets"] = {
"Yekhee",
3915848,
"alv-yek",
"Latn",
}
m["ett"] = {
"Etruscan",
35726,
"qfa-tyn",
"Ital",
-- Ital translit in [[Module:scripts/data]]
}
m["etu"] = {
"Ejagham",
35296,
"nic-eko",
"Latn",
}
m["etx"] = {
"Eten",
3915392,
"nic-beo",
"Latn",
}
m["etz"] = {
"Semimi",
10950308,
"paa-mai",
"Latn",
}
m["eve"] = {
"Even",
29960,
"tuw-ewe",
"Cyrl, Latn",
translit = {Cyrl = "eve-translit"},
strip_diacritics = {remove_diacritics = c.macron .. c.dotabove .. c.dotbelow},
sort_key = {
Cyrl = {
from = {
"ӫ", -- 2 chars
"ё", "ӈ", "ө" -- 1 char
},
to = {
"о" .. p[2],
"е" .. p[1], "н" .. p[1], "о" .. p[1]
},
},
},
}
m["evh"] = {
"Uvbie",
3441344,
"alv-swd",
"Latn",
}
m["evn"] = {
"Evenki",
30004,
"tuw-ewe",
"Cyrl, Latn",
translit = "evn-translit",
strip_diacritics = {remove_diacritics = c.macron .. c.dotabove .. c.dotbelow},
sort_key = {
from = {"ё", "ӈ"},
to = {"е" .. p[1], "н" .. p[1]}
},
}
m["ewo"] = {
"Ewondo",
35459,
"bnt-btb",
"Latn",
}
m["ext"] = {
"Extremaduran",
30007,
"roa-asl",
"Latn",
}
m["eya"] = {
"Eyak",
27480,
"xnd",
"Latn",
}
m["eyo"] = {
"Keiyo",
56856,
"sdv-nma",
"Latn",
}
m["eza"] = {
"Ezaa",
11921436,
"alv-igb",
"Latn",
ancestors = "izi",
}
m["eze"] = {
"Uzekwe",
3502244,
"nic-ucn",
"Latn",
}
return require("Module:languages").finalizeData(m, "language")
gqs0r2b6epvmorkjpe2oprwz8o2498u
Module:families
828
8079
54909
2026-09-28T23:23:32Z
Deadend0914
7211
Gesceop tramet þe hafaþ 'local export = {} local families_by_name_module = "Module:families/canonical names" local families_data_module = "Module:families/data" local json_module = "Module:JSON" local language_like_module = "Module:language-like" local languages_module = "Module:languages" local load_module = "Module:load" local table_module = "Module:table" local get_by_code -- Defined below. local gmatch = string.gmatch local insert = table.insert local ipairs = ipairs local make_obj...'
54909
Scribunto
text/plain
local export = {}
local families_by_name_module = "Module:families/canonical names"
local families_data_module = "Module:families/data"
local json_module = "Module:JSON"
local language_like_module = "Module:language-like"
local languages_module = "Module:languages"
local load_module = "Module:load"
local table_module = "Module:table"
local get_by_code -- Defined below.
local gmatch = string.gmatch
local insert = table.insert
local ipairs = ipairs
local make_object -- Defined below.
local pairs = pairs
local require = require
local setmetatable = setmetatable
local type = type
--[==[
Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==]
local function category_name_has_suffix(...)
category_name_has_suffix = require(language_like_module).categoryNameHasSuffix
return category_name_has_suffix(...)
end
local function category_name_to_code(...)
category_name_to_code = require(language_like_module).categoryNameToCode
return category_name_to_code(...)
end
local function deep_copy(...)
deep_copy = require(table_module).deepCopy
return deep_copy(...)
end
local function get_lang(...)
get_lang = require(languages_module).getByCode
return get_lang(...)
end
local function keys_to_list(...)
keys_to_list = require(table_module).keysToList
return keys_to_list(...)
end
local function load_data(...)
load_data = require(load_module).load_data
return load_data(...)
end
local function make_lang_object(...)
make_lang_object = require(languages_module).makeObject
return make_lang_object(...)
end
local function to_json(...)
to_json = require(json_module).toJSON
return to_json(...)
end
--[==[
Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==]
local families_by_name
local function get_families_by_name()
families_by_name, get_families_by_name = load_data(families_by_name_module), nil
return families_by_name
end
local families_data
local function get_families_data()
families_data, get_families_data = load_data(families_data_module), nil
return families_data
end
local families_suffixes
local function get_families_suffixes()
families_suffixes, get_families_suffixes = {
"languages",
"lects"
}, nil
return families_suffixes
end
local Family = {}
Family.__index = Family
--[==[
Return the family code of the family, e.g. {"ine"} for the Indo-European languages.
]==]
function Family:getCode()
return self._code
end
--[==[
Return the canonical name of the family. This is the name used to represent that language family on Wiktionary,
and is guaranteed to be unique to that family alone. Example: {"Indo-European"} for the Indo-European languages.
]==]
function Family:getCanonicalName()
local name = self._name
if name == nil then
name = self._data[1]
self._name = name
end
return name
end
--[==[
Return the display form of the family. For families, this is usually the same as the value returned by
{getCategoryName("nocap")}, i.e. it reads <code>"<var>name</var> languages"</code> (e.g.
{"Indo-Iranian languages"}). For full and etymology-only languages, this is the same as the canonical name, and
for scripts, it reads <code>"<var>name</var> script"</code> (e.g. {"Arabic script"}). The displayed text used in
{makeCategoryLink()} is always the same as the display form.
]==]
function Family:getDisplayForm()
local name = self._data[1]
if category_name_has_suffix(name, families_suffixes or get_families_suffixes()) then
name = name .. " languages"
end
return name
end
function Family:getAliases()
Family.getAliases = require(language_like_module).getAliases
return self:getAliases()
end
function Family:getVarieties(flatten)
Family.getVarieties = require(language_like_module).getVarieties
return self:getVarieties(flatten)
end
function Family:getOtherNames()
Family.getOtherNames = require(language_like_module).getOtherNames
return self:getOtherNames()
end
function Family:getAllNames()
Family.getAllNames = require(language_like_module).getAllNames
return self:getAllNames()
end
--[==[
Return a list of the pseudo-families (if any) that a family belongs to. The returned value is a list of Family
objects. Pseudo-families are groupings of languages that are not clades but share some geographic, ethnic or other
characteristic (e.g. [[:Category:Papuan languages]], [[:Category:Jewish languages]]).
]==]
function Family:getPseudoFamilies()
Family.getPseudoFamilies = require(language_like_module).getPseudoFamilies
return self:getPseudoFamilies()
end
--[==[Returns a table of types as a lookup table (with the types as keys).
The possible types are
* {family}: This object is a family.
* {full}: This object is a "full" family. This includes all families but a couple of etymology-only
families for Old and Middle Iranian languages.
* {etymology-only}: This object is an etymology-only family, similar to etymology-only languages. There
are currently only two such families, for Old Iranian languages and Middle Iranian
languages (which do not represent proper clades and have no proto-languages, hence
cannot be full families).
]==]
function Family:getTypes()
local types = self._types
if types == nil then
types = {family = true}
if self:getFullCode() == self:getCode() then
types.full = true
else
types["etymology-only"] = true
end
local rawtypes = self._data.type
if rawtypes then
for t in gmatch(rawtypes, "[^,]+") do
types[t] = true
end
end
self._types = types
end
return types
end
--[==[Given a list of types as strings, returns true if the family has all of them.]==]
function Family:hasType(...)
Family.hasType = require(language_like_module).hasType
return self:hasType(...)
end
--[==[Returns a {Family} object for the superfamily that the family belongs to.]==]
function Family:getFamily()
if self._familyObject == nil then
local familyCode = self:getFamilyCode()
if familyCode then
self._familyObject = get_by_code(familyCode)
else
self._familyObject = false
end
end
return self._familyObject or nil
end
--[==[Returns the code of the family's superfamily.]==]
function Family:getFamilyCode()
if not self._familyCode then
self._familyCode = self._data[3]
end
return self._familyCode
end
--[==[Returns the canonical name of the family's superfamily.]==]
function Family:getFamilyName()
if self._familyName == nil then
local family = self:getFamily()
if family then
self._familyName = family:getCanonicalName()
else
self._familyName = false
end
end
return self._familyName or nil
end
--[==[Check whether the family belongs to {superfamily} (which can be a family code or object), and returns a boolean. If more than one is given, returns {true} if the family belongs to any of them. A family is '''not''' considered to belong to itself.]==]
function Family:inFamily(...)
for _, superfamily in ipairs{...} do
if type(superfamily) == "table" then
superfamily = superfamily:getCode()
end
local family, code = self:getFamily()
while family do
code = family:getCode()
if code == superfamily then
return true
end
family = family:getFamily()
-- If family is parent to itself, return false.
if family and family:getCode() == code then
return false
end
end
return false
end
end
function Family:getParent()
if self._parentObject == nil then
local parentCode = self:getParentCode()
if parentCode then
self._parentObject = get_lang(parentCode, nil, true, true)
else
self._parentObject = false
end
end
return self._parentObject or nil
end
function Family:getParentCode()
if not self._parentCode then
self._parentCode = self._data.parent
end
return self._parentCode
end
function Family:getParentName()
if self._parentName == nil then
local parent = self:getParent()
if parent then
self._parentName = parent:getCanonicalName()
else
self._parentName = false
end
end
return self._parentName or nil
end
function Family:getParentChain()
if not self._parentChain then
self._parentChain = {}
local parent = self:getParent()
while parent do
insert(self._parentChain, parent)
parent = parent:getParent()
end
end
return self._parentChain
end
function Family:hasParent(...)
--checkObject("family", nil, ...)
for _, other_family in ipairs{...} do
for _, parent in ipairs(self:getParentChain()) do
if type(other_family) == "string" then
if other_family == parent:getCode() then return true end
else
if other_family:getCode() == parent:getCode() then return true end
end
end
end
return false
end
--[==[
If the family is etymology-only, this iterates through its parents until a full family is found, and the
corresponding object is returned. If the family is a full family, then it simply returns itself.
]==]
function Family:getFull()
if not self._fullObject then
local fullCode = self:getFullCode()
if fullCode ~= self:getCode() then
self._fullObject = get_lang(fullCode, nil, nil, true)
else
self._fullObject = self
end
end
return self._fullObject
end
--[==[
If the family is etymology-only, this iterates through its parents until a full family is found, and the
corresponding code is returned. If the family is a full family, then it simply returns the family code.
]==]
function Family:getFullCode()
return self._fullCode or self:getCode()
end
--[==[
If the family is etymology-only, this iterates through its parents until a full family is found, and the
corresponding canonical name is returned. If the family is a full family, then it simply returns the canonical name
of the family.
]==]
function Family:getFullName()
if self._fullName == nil then
local full = self:getFull()
if full then
self._fullName = full:getCanonicalName()
else
self._fullName = false
end
end
return self._fullName or nil
end
--[==[
Return a {Language} object (see [[Module:languages]]) for the proto-language of this family, if one exists.
Otherwise, return {nil}.
]==]
function Family:getProtoLanguage()
if self._protoLanguageObject == nil then
self._protoLanguageObject = get_lang(self._data.protoLanguage or self:getCode() .. "-pro", nil, true) or false
end
return self._protoLanguageObject or nil
end
function Family:getProtoLanguageCode()
if self._protoLanguageCode == nil then
local protoLanguage = self:getProtoLanguage()
self._protoLanguageCode = protoLanguage and protoLanguage:getCode() or false
end
return self._protoLanguageCode or nil
end
function Family:getProtoLanguageName()
if not self._protoLanguageName then
self._protoLanguageName = self:getProtoLanguage():getCanonicalName()
end
return self._protoLanguageName
end
function Family:hasAncestor(...)
-- Go up the family tree until a protolanguage is found.
local family = self
local protolang = family:getProtoLanguage()
while not protolang do
family = family:getFamily()
protolang = family:getProtoLanguage()
-- Return false if the family is its own family, to avoid an infinite loop.
if family:getFamilyCode() == family:getCode() then
return false
end
end
-- If the protolanguage is not in the family, it must therefore be ancestral to it. Check if it is a match.
for _, otherlang in ipairs{...} do
if (
type(otherlang) == "string" and protolang:getCode() == otherlang or
type(otherlang) == "table" and protolang:getCode() == otherlang:getCode()
) and not protolang:inFamily(self) then
return true
end
end
-- If not, check the protolanguage's ancestry.
return protolang:hasAncestor(...)
end
local function fetch_descendants(self, format)
local languages = require("Module:languages/code to canonical name")
local etymology_languages = require("Module:etymology languages/code to canonical name")
local families = require("Module:families/code to canonical name")
local descendants = {}
-- Iterate over all three datasets.
for _, data in ipairs{languages, etymology_languages, families} do
for code in pairs(data) do
local lang = get_lang(code, nil, true, true)
if lang:inFamily(self) then
if format == "object" then
insert(descendants, lang)
elseif format == "code" then
insert(descendants, code)
elseif format == "name" then
insert(descendants, lang:getCanonicalName())
end
end
end
end
return descendants
end
function Family:getDescendants()
if not self._descendantObjects then
self._descendantObjects = fetch_descendants(self, "object")
end
return self._descendantObjects
end
function Family:getDescendantCodes()
if not self._descendantCodes then
self._descendantCodes = fetch_descendants(self, "code")
end
return self._descendantCodes
end
function Family:getDescendantNames()
if not self._descendantNames then
self._descendantNames = fetch_descendants(self, "name")
end
return self._descendantNames
end
function Family:hasDescendant(...)
for _, lang in ipairs{...} do
if type(lang) == "string" then
lang = get_lang(lang, nil, true)
end
if lang:inFamily(self) then
return true
end
end
return false
end
--[==[
Return the name of the main category of that family. Example: {"Germanic languages"} for the Germanic languages,
whose category is at [[:Category:Germanic languages]].
Unless optional argument `nocap` is given, the family name at the beginning of the returned value will be
capitalized. This capitalization is correct for category names, but not if the family name is lowercase and
the returned value of this function is used in the middle of a sentence. (For example, the pseudo-family with
the code {qfa-mix} has the name {"mixed"}, which should remain lowercase when used as part of the category name
[[:Category:Terms derived from mixed languages]] but should be capitalized in [[:Category:Mixed languages]].)
If you are considering using {getCategoryName("nocap")}, use {getDisplayForm()} instead.
]==]
function Family:getCategoryName(nocap)
local name = self._data.categoryName or self:getDisplayForm()
if not nocap then
name = mw.getContentLanguage():ucfirst(name)
end
return name
end
function Family:makeCategoryLink()
return "[[:Category:" .. self:getCategoryName() .. "|" .. self:getDisplayForm() .. "]]"
end
--[==[Returns the Wikidata item id for the family or <code>nil</code>. This corresponds to the the second field in the data modules.]==]
function Family:getWikidataItem()
Family.getWikidataItem = require(language_like_module).getWikidataItem
return self:getWikidataItem()
end
--[==[
Returns the name of the Wikipedia article for the family. `project` specifies the language and project to retrieve
the article from, defaulting to {"enwiki"} for the English Wikipedia. Normally if specified it should be the project
code for a specific-language Wikipedia e.g. "zhwiki" for the Chinese Wikipedia, but it can be any project, including
non-Wikipedia ones. If the project is the English Wikipedia and the property {wikipedia_article} is present in the data
module it will be used first. In all other cases, a sitelink will be generated from {:getWikidataItem} (if set). The
resulting value (or lack of value) is cached so that subsequent calls are fast. If no value could be determined, and
`noCategoryFallback` is {false}, {:getCategoryName} is used as fallback; otherwise, {nil} is returned. Note that if
`noCategoryFallback` is {nil} or omitted, it defaults to {false} if the project is the English Wikipedia, otherwise
to {true}. In other words, under normal circumstances, if the English Wikipedia article couldn't be retrieved, the
return value will fall back to a link to the family's category, but this won't normally happen for any other project.
]==]
function Family:getWikipediaArticle(noCategoryFallback, project)
Family.getWikipediaArticle = require(language_like_module).getWikipediaArticle
return self:getWikipediaArticle(noCategoryFallback, project)
end
function Family:makeWikipediaLink()
return "[[w:" .. self:getWikipediaArticle() .. "|" .. self:getCanonicalName() .. "]]"
end
--[==[Returns the name of the Wikimedia Commons category page for the family.]==]
function Family:getCommonsCategory()
Family.getCommonsCategory = require(language_like_module).getCommonsCategory
return self:getCommonsCategory()
end
function Family:toJSON(opts)
local ret = {
canonicalName = self:getCanonicalName(),
categoryName = self:getCategoryName("nocap"),
code = self:getCode(),
parent = self:getParentCode(),
full = self:getFullCode(),
family = self:getFamilyCode(),
protoLanguage = self:getProtoLanguageCode(),
aliases = self:getAliases(),
varieties = self:getVarieties(),
otherNames = self:getOtherNames(),
type = keys_to_list(self:getTypes()),
wikidataItem = self:getWikidataItem(),
wikipediaArticle = self:getWikipediaArticle(true),
}
-- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`.
return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts)
end
function Family:getData()
return self._data
end
function export.makeObject(code, data)
local data_type = type(data)
if data_type ~= "table" then
error(("bad argument #2 to 'makeObject' (table expected, got %s)"):format(data_type))
end
return setmetatable({_data = data, _code = code, _fullCode = code}, Family)
end
make_object = export.makeObject
--[==[
Finds the family whose code matches the one provided. If it exists, it returns a {Family} object representing the
family. Otherwise, it returns {nil}.]==]
function export.getByCode(code)
local data = (families_data or get_families_data())[code]
if data == nil then
return nil
elseif data.parent == nil then
return make_object(code, data)
end
return make_lang_object(code, data)
end
get_by_code = export.getByCode
--[==[
Look for the family whose canonical name (the name used to represent that family on Wiktionary) matches the one
provided. If it exists, it returns a {Family} object representing the family. Otherwise, it returns {nil}. The
canonical name of families should always be unique (it is an error for two families on Wiktionary to share the same
canonical name), so this is guaranteed to give at most one result.]==]
function export.getByCanonicalName(name)
if name == nil then
return nil
end
local code = (families_by_name or get_families_by_name())[name]
if code == nil then
return nil
end
return get_by_code(code)
end
--[==[
Look for the family whose category name (the name used in categories for that family) matches the one provided.
If it exists, it returns a {Family} object representing the family. Otherwise, it returns {nil}. In almost all cases,
the category name for a family is its canonical name plus the word "languages", e.g. "Indo-European" has the category
name "Indo-European languages". Where a canonical name ends with "languages" or "lects", the category name is identical
to the canonical name.]==]
function export.getByCategoryName(name)
if name == nil then
return nil
end
local code = category_name_to_code(
name,
" languages",
families_by_name or get_families_by_name(),
families_suffixes or get_families_suffixes()
)
if code == nil then
return nil
end
return get_by_code(code)
end
return export
fhlpo09ymhi7e748v1r3pkilvfhbwm5
Module:families/data
828
8080
54910
2026-09-28T23:24:07Z
Deadend0914
7211
Gesceop tramet þe hafaþ '--[=[ This module contains definitions for all language family codes on Wiktionary. ]=]-- local m = {} m["aav"] = { "Austroasiatic", 33199, aliases = {"Austro-Asiatic"}, } m["aav-khs"] = { "Khasian", 3073734, "aav", aliases = {"Khasic"}, } m["aav-nic"] = { "Nicobarese", 217380, "aav", } m["aav-pkl"] = { "Pnar-Khasi-Lyngngam", nil, "aav-khs", } m["afa"] = { "Afroasiatic", 25268, aliases = {"Afro-Asiatic"}, } m["alg"] = { "Algonquian", 333...'
54910
Scribunto
text/plain
--[=[
This module contains definitions for all language family codes on Wiktionary.
]=]--
local m = {}
m["aav"] = {
"Austroasiatic",
33199,
aliases = {"Austro-Asiatic"},
}
m["aav-khs"] = {
"Khasian",
3073734,
"aav",
aliases = {"Khasic"},
}
m["aav-nic"] = {
"Nicobarese",
217380,
"aav",
}
m["aav-pkl"] = {
"Pnar-Khasi-Lyngngam",
nil,
"aav-khs",
}
m["afa"] = {
"Afroasiatic",
25268,
aliases = {"Afro-Asiatic"},
}
m["alg"] = {
"Algonquian",
33392,
"aql",
}
m["alg-abp"] = {
"Abenaki-Penobscot",
197936,
"alg-eas",
}
m["alg-ara"] = {
"Arapahoan",
2153686,
"alg",
}
m["alg-eas"] = {
"Eastern Algonquian",
2257525,
"alg",
}
m["alg-sfk"] = {
"Sac-Fox-Kickapoo",
1440172,
"alg",
}
m["alv"] = {
"Atlantic-Congo",
771124,
"nic",
}
m["alv-aah"] = {
"Ayere-Ahan",
750953,
"alv-von",
}
m["alv-ada"] = {
"Adamawa",
32906,
"alv-sav",
}
m["alv-bag"] = {
"Baga",
2746083,
"alv-mel",
}
m["alv-bak"] = {
"Bak",
1708174,
"alv-sng",
}
m["alv-bam"] = {
"Bambukic",
4853456,
"alv-ada",
aliases = {"Yungur-Jen"},
}
m["alv-bny"] = {
"Banyum",
2892477,
"alv-nyn",
}
m["alv-bua"] = {
"Bua",
4982094,
"alv-mbd",
}
m["alv-bwj"] = {
"Bikwin-Jen",
84542501,
"alv-bam",
}
m["alv-cng"] = {
"Cangin",
1033184,
"alv-fwo",
}
m["alv-ctn"] = {
"Central Tano",
1658486,
"alv-ptn",
aliases = {"Akan"},
}
m["alv-dlt"] = {
"Delta Edoid",
nil,
"alv-edo",
}
m["alv-dur"] = {
"Duru",
5316788,
"alv-lni",
}
m["alv-ede"] = {
"Ede",
35368,
"alv-yor",
}
m["alv-edk"] = {
"Edekiri",
5336735,
"alv-yrd",
}
m["alv-edo"] = {
"Edoid",
1287469,
"alv-von",
}
m["alv-eeo"] = {
"Edo-Esan-Ora",
12630439,
"alv-nce",
}
m["alv-fli"] = {
"Fali",
3450166,
"alv",
}
m["alv-fwo"] = {
"Fula-Wolof",
12631267,
"alv-sng",
}
m["alv-gbe"] = {
"Gbe",
668284,
"alv-von",
}
m["alv-gda"] = {
"Ga-Dangme",
3443338,
"alv-kwa",
}
m["alv-gng"] = {
"Guang",
684009,
"alv-ptn",
}
m["alv-gtm"] = {
"Ghana-Togo Mountain",
493020,
"alv-kwa",
aliases = {"Togo Remnant", "Central Togo"},
}
m["alv-hei"] = {
"Heiban",
108752116,
"alv-the",
}
m["alv-ido"] = {
"Idomoid",
974196,
"alv-von",
}
m["alv-igb"] = {
"Igboid",
1429100,
"alv-von",
}
m["alv-jfe"] = {
"Jola-Felupe",
1708174,
"alv-jol",
aliases = {"Ejamat"},
}
m["alv-jol"] = {
"Jola",
35176,
"alv-bak",
aliases = {"Diola"},
}
m["alv-kim"] = {
"Kim",
6409701,
"alv-mbd",
}
m["alv-kis"] = {
"Kissi",
35696,
"alv-mel",
}
m["alv-krb"] = {
"Karaboro",
4213541,
"alv-snf",
}
m["alv-ktg"] = {
"Ka-Togo",
5972796,
"alv-gtm",
}
m["alv-kul"] = {
"Kulango",
16977424,
"alv-sav",
aliases = {"Kulango-Lorhon", "Kulango-Lorom"},
}
m["alv-kwa"] = {
"Kwa",
33430,
"nic-vco",
}
m["alv-lag"] = {
"Lagoon",
111210042,
"alv-kwa",
}
m["alv-lek"] = {
"Leko",
6520642,
other_names = {"Sambaic"}, -- appears to be an alias in Glottolog
"alv-lni",
}
m["alv-lim"] = {
"Limba",
35825,
"alv",
}
m["alv-lni"] = {
"Leko-Nimbari",
1708170,
"alv-ada",
other_names = {"Central Adamawa"},
aliases = {"Chamba-Mumuye"},
}
m["alv-mbd"] = {
"Mbum-Day",
6799816,
"alv-ada",
}
m["alv-mbm"] = {
"Mbum",
6799814,
"alv-mbd",
}
m["alv-mel"] = {
"Mel",
12122355,
"alv",
}
m["alv-mum"] = {
"Mumuye",
84607009,
"alv-mye",
}
m["alv-mye"] = {
"Mumuye-Yendang",
6935539,
"alv-lni",
}
m["alv-nal"] = {
"Nalu",
nil,
"alv-sng",
}
m["alv-nce"] = {
"North-Central Edoid",
16110869,
"alv-edo",
}
m["alv-ngb"] = {
"Nupe-Gbagyi",
12638649,
"alv-nup",
aliases = {"Nupe-Gbari"},
}
m["alv-ntg"] = {
"Na-Togo",
nil,
"alv-gtm",
}
m["alv-nup"] = {
"Nupoid",
1429143,
"alv-von",
}
m["alv-nwd"] = {
"Northwestern Edoid",
16111012,
"alv-edo",
}
m["alv-nyn"] = {
"Nyun",
nil,
"alv-fwo",
}
m["alv-pap"] = {
"Papel",
7132562,
"alv-bak",
}
m["alv-pph"] = {
"Phla-Pherá",
3849625,
"alv-gbe",
}
m["alv-ptn"] = {
"Potou-Tano",
1475003,
"alv-kwa",
}
m["alv-sav"] = {
"Savanna",
4403672,
"nic-vco",
aliases = {"Savannas"},
}
m["alv-sma"] = {
"Supyire-Mamara",
4446348,
"alv-snf",
aliases = {"Suppire-Mamara"},
}
m["alv-snf"] = {
"Senufo",
33795,
"alv",
aliases = {"Senufic", "Senoufo", "Sénoufo"},
}
m["alv-sng"] = {
"Senegambian",
1708753,
"alv",
}
m["alv-snr"] = {
"Senari",
4416084,
"alv-snf",
}
m["alv-swd"] = {
"Southwestern Edoid",
12633903,
"alv-edo",
}
m["alv-tal"] = {
"Talodi",
12643302,
"alv-the",
}
m["alv-tdj"] = {
"Tagwana-Djimini",
7675362,
"alv-snf",
}
m["alv-ten"] = {
"Tenda",
3217535,
"alv-fwo",
}
m["alv-the"] = {
"Talodi-Heiban",
1521145,
"alv",
}
m["alv-von"] = {
"Volta-Niger",
34177,
"nic-vco",
}
m["alv-wan"] = {
"Wara-Natyoro",
7968830,
"alv-sav",
}
m["alv-wjk"] = {
"Waja-Kam",
nil,
"alv-ada",
}
m["alv-yek"] = {
"Yekhee",
nil,
"alv-nce",
}
m["alv-yor"] = {
"Yoruba",
nil,
"alv-edk",
}
m["alv-yrd"] = {
"Yoruboid",
1789745,
"alv-von",
}
m["alv-yun"] = {
"Yungur",
84601642,
"alv-bam",
aliases = {"Bena-Mboi"},
}
m["apa"] = {
"Apachean",
27758,
"ath",
aliases = {"Southern Athabaskan"},
}
m["aqa"] = {
"Alacalufan",
1288430,
pseudo_families = "sai",
}
m["aql"] = {
"Algic",
721612,
aliases = {"Algonquian-Ritwan", "Algonquian-Wiyot-Yurok"},
pseudo_families = "nai",
}
m["art"] = {
"constructed",
33215,
"qfa-not",
aliases = {"artificial", "planned"},
}
m["ath"] = {
"Athabaskan",
27475,
"xnd",
}
m["ath-nor"] = {
"North Athabaskan",
20738,
"ath",
aliases = {"Northern Athabaskan"},
}
m["ath-pco"] = {
"Pacific Coast Athabaskan",
20654,
"ath",
}
m["auf"] = {
"Arawan",
626772,
aliases = {"Arahuan", "Arauán", "Arawa", "Arauan", "Arawán"},
pseudo_families = "sai",
}
--[=[
Exceptional language and family codes for Australian Aboriginal languages
can use the prefix "aus-", though "aus" is no longer itself a family code.
]=]--
m["aus-arn"] = {
"Arnhem",
2581700,
aliases = {"Gunwinyguan", "Macro-Gunwinyguan"},
}
m["aus-bub"] = {
"Bunuban",
2495148,
aliases = {"Bunaban"},
}
m["aus-cww"] = {
"Central New South Wales",
5061507,
"aus-pam",
}
m["aus-dal"] = {
"Daly",
2478079,
}
m["aus-dyb"] = {
"Dyirbalic",
1850666,
"aus-pam",
}
m["aus-gar"] = {
"Garawan",
5521951,
}
m["aus-gun"] = {
"Gunwinyguan",
2581700,
"aus-arn",
aliases = {"Gunwingguan"},
}
m["aus-jar"] = {
"Jarrakan",
2039423,
}
m["aus-kar"] = {
"Karnic",
4215578,
"aus-pam",
}
m["aus-mir"] = {
"Mirndi",
4294095,
}
m["aus-nga"] = {
"Ngayarda",
16153490,
"aus-psw",
}
m["aus-nyu"] = {
"Nyulnyulan",
2039408,
}
m["aus-pam"] = {
"Pama-Nyungan",
33942,
}
m["aus-pmn"] = {
"Paman",
2640654,
"aus-pam",
}
m["aus-psw"] = {
"Southwest Pama-Nyungan",
2258160,
"aus-pam",
}
m["aus-rnd"] = {
"Arandic",
4784071,
"aus-pam",
}
m["aus-tnk"] = {
"Tangkic",
1823065,
}
m["aus-wdj"] = {
"Iwaidjan",
4196968,
aliases = {"Yiwaidjan"},
}
m["aus-wor"] = {
"Worrorran",
2038619,
}
m["aus-yid"] = {
"Yidinyic",
4205849,
"aus-pam",
}
m["aus-yng"] = {
"Yangmanic",
42727644,
}
m["aus-yol"] = {
"Yolngu",
2511254,
"aus-pam",
aliases = {"Yolŋu", "Yolngu Matha"},
}
m["aus-yuk"] = {
"Yuin-Kuric",
3833021,
"aus-pam",
}
m["awd"] = {
"Arawak",
626753,
aliases = {"Arawakan", "Maipurean", "Maipuran"},
}
m["awd-nwk"] = {
"Nawiki",
nil,
"awd",
aliases = {"Newiki"},
pseudo_families = "sai",
}
m["awd-taa"] = {
"Ta-Arawak",
7672731,
"awd",
aliases = {"Ta-Arawakan", "Ta-Maipurean"},
}
m["azc"] = {
"Uto-Aztecan",
34073,
aliases = {"Uto-Aztekan"},
}
m["azc-cup"] = {
"Cupan",
19866871,
"azc-tak",
}
m["azc-dur"] = {
"Durango Nahuatl",
2386361,
"azc-nah",
aliases = {"Mexicanero"}
}
m["azc-hua"] = {
"Huasteca Nahuatl",
3832950,
"azc-nah",
}
m["azc-nah"] = {
"Nahuan",
11965602,
"azc",
aliases = {"Aztecan"},
pseudo_families = "cai",
}
m["azc-num"] = {
"Numic",
2657541,
"azc",
pseudo_families = "nai",
}
m["azc-pim"] = {
"Piman",
7194600,
"azc",
aliases = {"Tepiman"},
pseudo_families = "nai",
}
m["azc-tak"] = {
"Takic",
1280305,
"azc",
pseudo_families = "nai",
}
m["azc-trc"] = {
"Taracahitic",
4245032,
"azc",
aliases = {"Taracahitan"},
pseudo_families = "nai",
}
m["bad"] = {
"Banda",
806234,
"nic-ubg",
}
m["bad-cnt"] = {
"Central Banda",
3438391,
"bad",
}
m["bai"] = {
"Bamileke",
806005,
"nic-gre",
}
m["bat"] = {
"Baltic",
33136,
"ine-bsl",
}
m["bat-eas"] = {
"East Baltic",
149944,
"bat",
}
m["bat-wes"] = {
"West Baltic",
149946,
"bat",
}
m["ber"] = {
"Berber",
25448,
"afa",
aliases = {"Tamazight"},
}
m["bnt"] = {
"Bantu",
33146,
"nic-bds",
}
m["bnt-baf"] = {
"Bafia",
799784,
"bnt",
}
m["bnt-bbo"] = {
"Bafo-Bonkeng",
nil,
"bnt-saw",
}
m["bnt-bdz"] = {
"Boma-Dzing",
1729203,
"bnt",
}
m["bnt-bek"] = {
"Bekwilic",
nil,
"bnt-ndb",
}
m["bnt-bki"] = {
"Bena-Kinga",
16113307,
"bnt-bne",
}
m["bnt-bmo"] = {
"Bangi-Moi",
nil,
"bnt-bnm",
}
m["bnt-bne"] = {
"Northeast Bantu",
7057832,
"bnt",
}
m["bnt-bnm"] = {
"Bangi-Ntomba",
806477,
"bnt-bte",
}
m["bnt-boa"] = {
"Boan",
4931250,
"bnt",
aliases = {"Buan", "Ababuan"},
}
m["bnt-bot"] = {
"Botatwe",
4948532,
"bnt",
}
m["bnt-bsa"] = {
"Basaa",
809739,
"bnt",
}
m["bnt-bsh"] = {
"Bushoong",
5001551,
"bnt-bte",
}
m["bnt-bso"] = {
"Southern Bantu",
980498,
"bnt",
}
m["bnt-bta"] = {
"Bati-Angba",
4869303,
"bnt-boa",
other_names = {"Late Bomokandian"},
aliases = {"Bwa"},
}
m["bnt-btb"] = {
"Beti",
35118,
"bnt",
}
m["bnt-bte"] = {
"Bangi-Tetela",
4855181,
"bnt",
}
m["bnt-bun"] = {
"Buja-Ngombe",
4986733,
"bnt-mbb",
}
m["bnt-chg"] = {
"Chaga",
33016,
"bnt-cht",
}
m["bnt-cht"] = {
"Chaga-Taita",
nil,
"bnt-bne",
}
m["bnt-clu"] = {
"Chokwe-Luchazi",
3339273,
"bnt",
}
m["bnt-com"] = {
"Comorian",
33077,
"bnt-sab",
}
m["bnt-glb"] = {
"Great Lakes Bantu",
5599420,
"bnt-bne",
}
m["bnt-haj"] = {
"Haya-Jita",
25502360,
"bnt-glb",
}
m["bnt-kak"] = {
"Kako",
nil,
"bnt-pob",
}
m["bnt-kav"] = {
"Kavango",
116544179,
"bnt-ksb",
}
m["bnt-kbi"] = {
"Komo-Bira",
6428591,
"bnt-boa",
}
m["bnt-kel"] = {
"Kele",
1738162,
"bnt-kts",
aliases = {"Sheke"},
}
m["bnt-kil"] = {
"Kilombero",
6408121,
"bnt",
}
m["bnt-kka"] = {
"Kikuyu-Kamba",
16114410,
"bnt-bne",
aliases = {"Thagiicu"},
}
m["bnt-kmb"] = {
"Kimbundu",
16947687,
"bnt",
}
m["bnt-kng"] = {
"Kongo",
6429214,
"bnt",
}
m["bnt-kpw"] = {
"Kpwe",
36428,
"bnt-saw",
}
m["bnt-ksb"] = {
"Kavango-Southwest Bantu",
6379098,
"bnt",
}
m["bnt-kts"] = {
"Kele-Tsogo",
6385577,
"bnt",
}
m["bnt-lbn"] = {
"Luban",
4536504,
"bnt",
}
m["bnt-leb"] = {
"Lebonya",
6511395,
"bnt",
}
m["bnt-lgb"] = {
"Lega-Binja",
6517694,
"bnt",
}
m["bnt-lok"] = {
"Logooli-Kuria",
nil,
"bnt-glb",
}
m["bnt-lub"] = {
"Luba",
nil,
"bnt-lbn",
}
m["bnt-lun"] = {
"Lunda",
6704091,
"bnt",
}
m["bnt-mak"] = {
"Makua",
6740431,
"bnt-bso",
aliases = {"Makhuwa"},
}
m["bnt-mbb"] = {
"Mboshi-Buja",
6799764,
"bnt",
}
m["bnt-mbe"] = {
"Mbole-Enya",
6799728,
"bnt",
}
m["bnt-mbi"] = {
"Mbinga",
nil,
"bnt-rur",
}
m["bnt-mbo"] = {
"Mboshi",
6799763,
"bnt-mbb",
}
m["bnt-mbt"] = {
"Mbete",
1346910,
"bnt-tmb",
aliases = {"Mbere"},
}
m["bnt-mby"] = {
"Mbeya",
nil,
"bnt-ruk",
}
m["bnt-mij"] = {
"Mijikenda",
6845474,
"bnt-sab",
}
m["bnt-mka"] = {
"Makaa",
nil,
"bnt-ndb",
}
m["bnt-mne"] = {
"Manenguba",
31147471,
"bnt",
aliases = {"Mbo", "Ngoe"},
}
m["bnt-mnj"] = {
"Makaa-Njem",
1603899,
"bnt-pob",
}
m["bnt-mon"] = {
"Mongo",
nil,
"bnt-bnm",
}
m["bnt-mra"] = {
"Mbugwe-Rangi",
6799795,
"bnt",
}
m["bnt-msl"] = {
"Masaba-Luhya",
12636428,
"bnt-glb",
}
m["bnt-mwi"] = {
"Mwika",
nil,
"bnt-ruk",
}
m["bnt-ncb"] = {
"Northeast Coast Bantu",
7057848,
"bnt-bne",
}
m["bnt-ndb"] = {
"Ndzem-Bomwali",
nil,
"bnt-mnj",
}
m["bnt-ngn"] = {
"Ngondi-Ngiri",
7022532,
"bnt-mbb",
}
m["bnt-ngu"] = {
"Nguni",
961559,
"bnt-bso",
aliases = {"Ngoni"},
}
m["bnt-nya"] = {
"Nyali",
7070832,
"bnt-leb",
}
m["bnt-nyb"] = {
"Nyanga-Buyi",
7070882,
"bnt",
}
m["bnt-nyg"] = {
"Nyoro-Ganda",
12638666,
"bnt-glb",
}
m["bnt-nys"] = {
"Nyasa",
7070921,
"bnt",
}
m["bnt-nze"] = {
"Nzebi",
1755498,
"bnt-tmb",
aliases = {"Njebi"},
}
m["bnt-ova"] = {
"Ovambo",
36489,
"bnt-swb",
aliases = {"Oshivambo", "Oshiwambo", "Owambo"},
}
m["bnt-par"] = {
"Pare",
nil,
"bnt-ncb",
}
m["bnt-pen"] = {
"Pende",
7162373,
"bnt",
}
m["bnt-pob"] = {
"Pomo-Bomwali",
nil,
"bnt",
}
m["bnt-ruk"] = {
"Rukwa",
7378902,
"bnt",
}
m["bnt-run"] = {
"Rungwe",
nil,
"bnt-ruk",
}
m["bnt-rur"] = {
"Rufiji-Ruvuma",
7377947,
"bnt",
}
m["bnt-ruv"] = {
"Ruvu",
nil,
"bnt-ncb",
}
m["bnt-rvm"] = {
"Ruvuma",
nil,
"bnt-rur",
}
m["bnt-sab"] = {
"Sabaki",
2209395,
"bnt-ncb",
}
m["bnt-saw"] = {
"Sawabantu",
532003,
"bnt",
}
m["bnt-sbi"] = {
"Sabi",
7396071,
"bnt",
}
m["bnt-seu"] = {
"Seuta",
nil,
"bnt-ncb",
}
m["bnt-shh"] = {
"Shi-Havu",
nil,
"bnt-glb",
}
m["bnt-sho"] = {
"Shona",
2904660,
"bnt",
}
m["bnt-sir"] = {
"Sira",
1436372,
"bnt",
aliases = {"Shira-Punu"},
}
m["bnt-ske"] = {
"Soko-Kele",
nil,
"bnt-bte",
}
m["bnt-sna"] = {
"Sena",
nil,
"bnt-nys",
}
m["bnt-sts"] = {
"Sotho-Tswana",
2038386,
"bnt-bso",
}
m["bnt-swb"] = {
"Southwest Bantu",
116543539,
"bnt-ksb",
}
m["bnt-swh"] = {
"Swahili",
nil,
"bnt-sab",
}
m["bnt-tek"] = {
"Teke",
36528,
"bnt-tmb",
}
m["bnt-tet"] = {
"Tetela",
7706059,
"bnt-bte",
}
m["bnt-tkc"] = {
"Central Teke",
36473,
"bnt-tek",
}
m["bnt-tkm"] = {
"Takama",
nil,
"bnt-bne",
}
m["bnt-tmb"] = {
"Teke-Mbede",
7695332,
"bnt",
aliases = {"Teke-Mbere"},
}
m["bnt-tso"] = {
"Tsogo",
2458420,
other_names = {"Okani"}, --appears to be an alias in Glottolog
"bnt-kts",
}
m["bnt-tsr"] = {
"Tswa-Ronga",
12643962,
"bnt-bso",
}
m["bnt-yak"] = {
"Yaka",
8047027,
"bnt",
}
m["bnt-yko"] = {
"Yasa-Kombe",
nil,
"bnt-saw",
}
m["bnt-zbi"] = {
"Zamba-Binza",
nil,
"bnt-bnm",
}
m["btk"] = {
"Batak",
1998595,
"poz-nws",
}
m["cai"] = {
"Mesoamerican",
2478413,
"qfa-not",
}
--[=[
Exceptional language and family codes for Mesoamerican ("Central American Indian") languages
may use the prefix "cai-", though "cai" is not a proper family (only a pseudo-family).
]=]--
--[=[
Exceptional language and family codes for Caucasian languages can use
the prefix "cau-", though "cau" is no longer itself a family code.
]=]--
m["cau-abz"] = {
"Abkhaz-Abaza",
4663617,
"cau-nwc",
other_names = {"Abkhaz-Tapanta"},
aliases = {"Abazgi"},
}
m["cau-and"] = {
"Andian",
492152,
"cau-ava",
aliases = {"Andic"},
}
m["cau-ava"] = {
"Avaro-Andian",
4055404,
"cau-nec",
aliases = {"Avar-Andian", "Avar-Andi", "Avar-Andic"},
}
m["cau-cir"] = {
"Circassian",
858543,
"cau-nwc",
aliases = {"Cherkess"},
}
m["cau-drg"] = {
"Dargwa",
5222637,
"cau-nec",
other_names = {"Dargin"},
}
m["cau-esm"] = {
"Eastern Samur",
nil,
"cau-sam",
}
m["cau-ets"] = {
"East Tsezian",
121437666,
"cau-tsz",
aliases = {"East Tsezic", "East Didoic"},
}
m["cau-lzg"] = {
"Lezghian",
2144370,
"cau-nec",
aliases = {"Lezgi", "Lezgian", "Lezgic"},
}
m["cau-nkh"] = {
"Nakh",
24441,
"cau-nec",
aliases = {"North-Central Caucasian"},
}
m["cau-nec"] = {
"Northeast Caucasian",
27387,
aliases = {"Dagestanian", "Nakho-Dagestanian", "Caspian"},
}
m["cau-nwc"] = {
"Northwest Caucasian",
33852,
aliases = {"Abkhazo-Adyghean", "Abkhaz-Adyghe", "Pontic"},
}
m["cau-sam"] = {
"Samur",
15229151,
"cau-lzg",
}
m["cau-ssm"] = {
"Southern Samur",
nil,
"cau-sam",
}
m["cau-tsz"] = {
"Tsezian",
1651530,
"cau-nec",
aliases = {"Tsezic", "Didoic"},
}
m["cau-vay"] = {
"Vainakh",
4102486,
"cau-nkh",
aliases = {"Veinakh", "Vaynakh"},
}
m["cau-wsm"] = {
"Western Samur",
nil,
"cau-sam",
}
m["cau-wts"] = {
"West Tsezian",
121437697,
"cau-tsz",
aliases = {"West Tsezic", "West Didoic"},
}
m["cba"] = {
"Chibchan",
520478,
"qfa-mch", -- or none if Macro-Chibchan is considered undemonstrated
-- In both Central America and South America
}
m["ccs"] = {
"Kartvelian",
34030,
aliases = {"South Caucasian"},
}
m["ccs-gzn"] = {
"Georgian-Zan",
34030,
"ccs",
aliases = {"Karto-Zan"},
}
m["ccs-zan"] = {
"Zan",
2606912,
"ccs-gzn",
aliases = {"Zanuri", "Colchian"},
}
m["cdc"] = {
"Chadic",
33184,
"afa",
}
m["cdc-cbm"] = {
"Central Chadic",
2251547,
"cdc",
aliases = {"Biu-Mandara"},
}
m["cdc-est"] = {
"East Chadic",
2276221,
"cdc",
}
m["cdc-mas"] = {
"Masa",
2136092,
"cdc",
}
m["cdc-wst"] = {
"West Chadic",
2447774,
"cdc",
}
m["cdd"] = {
"Caddoan",
1025090,
pseudo_families = "nai",
}
m["cel"] = {
"Celtic",
25293,
"ine",
}
m["cel-bry"] = {
"Brythonic",
156877,
"cel-ins",
aliases = {"Brittonic"},
}
m["cel-brs"] = {
"Southwestern Brythonic",
2612853,
"cel-bry",
aliases = {"Southwestern Brittonic"},
}
m["cel-brw"] = {
"Western Brythonic",
593069,
"cel-bry",
aliases = {"Western Brittonic"},
}
m["cel-gae"] = {
"Goidelic",
56433,
"cel-ins",
aliases = {"Gaelic"},
protoLanguage = "pgl",
}
m["cel-his"] = {
"Hispano-Celtic",
4204136,
"cel",
}
m["cel-ins"] = {
"Insular Celtic",
214506,
"cel",
}
m["chi"] = {
"Chimakuan",
1073088,
pseudo_families = "nai",
}
m["chm"] = {
"Mari",
973685,
"urj",
}
m["cmc"] = {
"Chamic",
2997506,
"poz-mcm",
}
m["crp"] = {
"creole or pidgin",
19682167,
"qfa-cnt",
}
m["csu"] = {
"Central Sudanic",
190822,
"ssa",
}
m["csu-bba"] = {
"Bongo-Bagirmi",
3505042,
"csu",
}
m["csu-bbk"] = {
"Bongo-Baka",
4941917,
"csu-bba",
}
m["csu-bgr"] = {
"Bagirmi",
4841948,
"csu-bba",
aliases = {"Bagirmic"},
}
m["csu-bkr"] = {
"Birri-Kresh",
nil,
"csu",
}
m["csu-ecs"] = {
"Eastern Central Sudanic",
16911698,
"csu",
aliases = {"East Central Sudanic", "Central Sudanic East", "Lendu-Mangbetu"},
}
m["csu-kab"] = {
"Kaba",
6343715,
"csu-bba",
}
m["csu-lnd"] = {
"Lendu",
6522357,
"csu-ecs",
aliases = {"Lenduic"},
}
m["csu-maa"] = {
"Mangbetu",
6748874,
"csu-ecs",
aliases = {"Mangbetu-Asoa", "Mangbetu-Asua"},
}
m["csu-mle"] = {
"Mangbutu-Lese",
17009406,
"csu-ecs",
aliases = {"Mangbutu-Efe", "Mangbutu", "Membi-Mangbutu-Efe"},
}
m["csu-mma"] = {
"Moru-Madi",
6915156,
"csu-ecs",
}
m["csu-sar"] = {
"Sara",
2036691,
"csu-bba",
}
m["csu-val"] = {
"Vale",
7909520,
"csu-bba",
}
m["cus"] = {
"Cushitic",
33248,
"afa",
}
m["cus-cen"] = {
"Central Cushitic",
56569,
"cus",
}
m["cus-eas"] = {
"East Cushitic",
56568,
"cus",
}
m["cus-hec"] = {
"Highland East Cushitic",
56524,
"cus-eas",
}
m["cus-som"] = {
"Somaloid",
56774,
"cus-eas",
aliases = {"Sam", "Macro-Somali"},
}
m["cus-sou"] = {
"South Cushitic",
56525,
"cus",
}
m["day"] = {
"Land Dayak",
2760613,
"poz",
}
m["del"] = {
"Lenape",
2665761,
"alg-eas",
aliases = {"Delaware"},
}
m["den"] = {
"Slavey",
13272,
"ath-nor",
aliases = {"Slave", "Slavé"},
}
m["dmn"] = {
"Mande",
33681,
"nic",
}
m["dmn-bbu"] = {
"Bisa-Busa",
12627956,
"dmn-mde",
}
m["dmn-emn"] = {
"East Manding",
nil,
"dmn-man",
}
m["dmn-jje"] = {
"Jogo-Jeri",
nil,
"dmn-mjo",
}
m["dmn-man"] = {
"Manding",
35772,
"dmn-mmo",
}
m["dmn-mda"] = {
"Mano-Dan",
nil,
"dmn-mse",
}
m["dmn-mdc"] = {
"Central Mande",
5972907,
"dmn-mdw",
}
m["dmn-mde"] = {
"Eastern Mande",
12633080,
"dmn",
}
m["dmn-mdw"] = {
"Western Mande",
16113831,
"dmn",
}
m["dmn-mjo"] = {
"Manding-Jogo",
12636153,
"dmn-mdc",
}
m["dmn-mmo"] = {
"Manding-Mokole",
nil,
"dmn-mva",
}
m["dmn-mnk"] = {
"Maninka",
36186,
"dmn-emn",
}
m["dmn-mnw"] = {
"Northwestern Mande",
5972910,
"dmn-mdw",
}
m["dmn-mok"] = {
"Mokole",
16935447,
"dmn-mmo",
}
m["dmn-mse"] = {
"Southeastern Mande",
5972912,
"dmn-mde",
}
m["dmn-msw"] = {
"Southwestern Mande",
12633904,
"dmn-mdw",
}
m["dmn-mva"] = {
"Manding-Vai",
nil,
"dmn-mjo",
}
m["dmn-nbe"] = {
"Nwa-Beng",
nil,
"dmn-mse",
}
m["dmn-sam"] = {
"Samo",
36327,
"dmn-bbu",
aliases = {"Samuic"},
}
m["dmn-smg"] = {
"Samogo",
7410000,
"dmn-mnw",
aliases = {"Duun-Seenku"},
}
m["dmn-snb"] = {
"Soninke-Bobo",
16111680,
"dmn-mnw",
}
m["dmn-sya"] = {
"Susu-Yalunka",
nil,
"dmn-mdc",
}
m["dmn-vak"] = {
"Vai-Kono",
nil,
"dmn-mva",
}
m["dmn-wmn"] = {
"West Manding",
nil,
"dmn-man",
}
m["dra"] = {
"Dravidian",
33311,
}
m["dra-cen"] = {
"Central Dravidian",
12628823,
"dra",
}
m["dra-gki"] = {
"Gondi-Kui",
12631610,
"dra-sdt",
}
m["dra-gon"] = {
"Gondi",
55639812,
"dra-gki",
}
m["dra-imd"] = {
"Irula-Muduga",
nil,
"dra-tkn",
}
m["dra-kan"] = {
"Kannadoid",
6363888,
"dra-tkn",
protoLanguage = "dra-okn",
}
m["dra-kki"] = {
"Konda-Kui",
nil,
"dra-gki",
}
m["dra-kml"] = {
"Kurux-Malto",
68002822,
"dra-nor",
}
m["dra-knk"] = {
"Kolami-Naiki",
10547037,
"dra-cen",
}
m["dra-kod"] = {
"Kodagu",
67983106,
"dra-tkd",
}
m["dra-kor"] = {
"Koraga",
33394,
"dra-tlk",
}
m["dra-mal"] = {
"Malayalamoid",
6741581,
"dra-tml",
}
m["dra-mdy"] = {
"Madiya",
27602,
"dra-gon",
}
m["dra-mlo"] = {
"Malto",
nil,
"dra-kml",
}
m["dra-mur"] = {
"Muria",
6938499,
"dra-gon",
}
m["dra-nor"] = {
"North Dravidian",
16110967,
"dra",
}
m["dra-pgd"] = {
"Parji-Gadaba",
10620428,
"dra-cen",
}
m["dra-sdo"] = {
"South Dravidian I",
16112843, -- Wikipedia's "South Dravidian" is South Dravidian I in this scheme.
"dra-sou",
aliases = {"South Dravidian"}, -- This is why I and II are used.
}
m["dra-sdt"] = {
"South Dravidian II",
12633975,
"dra-sou",
aliases = {"South-Central Dravidian"},
}
m["dra-sou"] = {
"South Dravidian",
128886618,
"dra",
aliases = {"Southern Dravidian"},
}
m["dra-tam"] = {
"Tamiloid",
7681417,
"dra-tml",
protoLanguage = "oty",
}
m["dra-tel"] = {
"Teluguic",
nil,
"dra-sdt",
protoLanguage = "dra-ote",
}
m["dra-tkd"] = {
"Tamil-Kodagu",
25494510,
"dra-tkn",
}
m["dra-tkn"] = {
"Tamil-Kannada",
6478506,
"dra-sdo",
}
m["dra-tkt"] = {
"Toda-Kota",
67983857,
"dra-tkd",
}
m["dra-tlk"] = {
"Tulu-Koraga",
nil,
"dra-sdo",
}
m["dra-tml"] = {
"Tamil-Malayalam",
10690507,
"dra-tkd",
}
m["egx"] = {
"Egyptian",
50868,
"afa",
protoLanguage = "egy",
}
m["ero"] = {
"Horpa",
56854,
"sit-wgy",
}
m["esx"] = {
"Eskimo-Aleut",
25946,
pseudo_families = "nai",
}
m["esx-esk"] = {
"Eskimo",
25946,
"esx",
}
m["esx-inu"] = {
"Inuit",
27796,
"esx-esk",
}
m["euq"] = {
"Vasconic",
4669240,
}
m["gba"] = {
"Gbaya",
3099986,
"alv-sav",
}
m["gba-eas"] = {
"Eastern Gbaya",
nil,
"gba",
}
m["gba-sou"] = {
"Southern Gbaya",
nil,
"gba",
}
m["gba-wes"] = {
"Western Gbaya",
nil,
"gba",
}
m["gem"] = {
"Germanic",
21200,
"ine",
}
m["gio"] = {
"Gelao",
56401,
"qfa-kra",
}
m["gme"] = {
"East Germanic",
108662,
"gem",
}
m["gmq"] = {
"North Germanic",
106085,
"gem",
}
m["gmq-eas"] = {
"East Scandinavian",
3090263,
"gmq",
protoLanguage = "non-oen",
}
m["gmq-ins"] = {
"Insular Scandinavian",
nil,
"gmq-wes",
}
m["gmq-wes"] = {
"West Scandinavian",
1792570,
"gmq",
protoLanguage = "non-own",
}
m["gmw"] = {
"West Germanic",
26721,
"gem",
}
m["gmw-afr"] = {
"Anglo-Frisian",
5329170,
"gmw-nsg",
}
m["gmw-ang"] = {
"Anglic",
1346342,
"gmw-afr",
protoLanguage = "ang",
}
m["gmw-fri"] = {
"Frisian",
25325,
"gmw-afr",
protoLanguage = "ofs",
}
m["gmw-frk"] = {
"Low Franconian",
153050,
"gmw",
protoLanguage = "frk",
}
m["gmw-hgm"] = {
"High German",
52040,
"gmw",
protoLanguage = "goh",
}
m["gmw-ian"] = {
"Irish Anglo-Norman",
120719384,
"gmw-ang",
protoLanguage = "enm",
}
m["gmw-lgm"] = {
"Low German",
25433,
"gmw-nsg",
protoLanguage = "osx",
}
m["gmw-nsg"] = {
"North Sea Germanic",
30134,
"gmw",
aliases = {"Ingvaeonic"},
}
m["gn"] = {
"Guarani",
35876,
"tup-gua",
aliases = {"Guaraní"},
}
m["grb"] = {
"Grebo proper",
35257,
"kro-grb",
}
m["grk"] = {
"Hellenic",
2042538,
"ine",
aliases = {"Greek"},
}
m["him"] = {
"Western Pahari",
10939493,
"inc-pah",
aliases = {"Himachali"},
}
m["hmn"] = {
"Hmongic",
3307894,
"hmx",
}
m["hmx"] = {
"Hmong-Mien",
33322,
aliases = {"Miao-Yao"},
}
m["hmx-mie"] = {
"Mienic",
7992695,
"hmx",
}
m["hok"] = {
"Hokan",
33406,
-- NOTE: Some Hokan languages are in Central America; they have `pseudo_families = "cai"`,
-- which overrides the following.
pseudo_families = "nai",
}
m["hyx"] = {
"Armenian",
8785,
"ine",
}
m["iir"] = {
"Indo-Iranian",
33514,
"ine",
}
m["iir-nur"] = {
"Nuristani",
161804,
"iir",
}
m["nur-nor"] = {
"Northern Nuristani",
nil,
"iir-nur",
}
m["nur-sou"] = {
"Southern Nuristani",
nil,
"iir-nur",
}
m["ijo"] = {
"Ijoid",
1325759,
"nic",
other_names = {"Ijaw"}, -- Ijaw may be a subfamily
}
m["inc"] = {
"Indo-Aryan",
33577,
"iir",
aliases = {"Indic"},
}
m["inc-bas"] = {
"Bengali-Assamese",
4179137,
"inc-eas",
aliases = {"Assamese-Bengali", "Gauda-Kamarupa"},
}
m["inc-bhi"] = {
"Bhil",
4901727,
"inc-cen",
}
m["inc-bih"] = {
"Bihari",
135305,
"inc-eas",
}
m["inc-cen"] = {
"Central Indo-Aryan",
10979187,
"inc",
protoLanguage = "inc-asa",
}
m["inc-chi"] = {
"Chitrali",
11732797,
"inc-dar",
}
m["inc-dar"] = {
"Dardic",
161101,
"inc",
protoLanguage = "inc-ash",
}
m["inc-dre"] = {
"Eastern Dardic",
nil,
"inc-dar",
}
m["inc-dng"] = {
"Dangari",
nil,
"inc-shn",
}
m["inc-eas"] = {
"Eastern Indo-Aryan",
12593391,
"inc",
protoLanguage = "inc-aav",
}
m["inc-hal"] = {
"Halbic",
16910593,
"inc-eas",
aliases = {"Halbi"},
}
m["inc-hie"] = {
"Eastern Hindi",
4126648,
"inc-cen",
aliases = {"Purabiyā"},
protoLanguage = "inc-oaw",
}
m["inc-hiw"] = {
"Western Hindi",
12600937,
"inc-cen",
protoLanguage = "inc-ohi",
}
m["inc-hnd"] = {
"Hindustani",
11051,
"inc-hiw",
aliases = {"Hindi-Urdu"},
protoLanguage = "hi-mid",
}
m["inc-ins"] = {
"Insular Indo-Aryan",
12179302,
"inc",
protoLanguage = "inc-apa",
}
m["inc-kas"] = {
"Kashmiric",
nil,
"inc-dre",
aliases = {"Kashmiri"},
}
m["inc-koh"] = {
"Kohistani",
13018610,
"inc-dre",
}
m["inc-krd"] = {
"KRDS languages",
6356154,
"inc-eas",
aliases = {"Kamta, Rajbanshi, Deshi and Surjapuri", "KRNB languages", "Kamta, Rajbanshi and Northern Deshi Bangla"},
}
m["inc-kun"] = {
"Kunar",
nil,
"inc-dar",
}
m["inc-mid"] = {
"Middle Indo-Aryan",
3236316,
"inc",
aliases = {"Middle Indic"},
}
m["inc-nwe"] = {
"Northwestern Indo-Aryan",
16111018,
"inc",
protoLanguage = "inc-apa",
}
m["inc-nor"] = {
"Northern Indo-Aryan",
946077,
"inc",
protoLanguage = "inc-aka",
}
m["inc-old"] = {
"Old Indo-Aryan",
118976896,
"inc",
aliases = {"Old Indic"},
}
m["inc-pac"] = {
"Central Pahari",
nil,
"inc-pah",
}
m["inc-pae"] = {
"Eastern Pahari",
nil,
"inc-pah",
}
m["inc-pah"] = {
"Pahari",
946077,
"inc-nor",
aliases = {"Pahadi"},
protoLanguage = "inc-aka",
}
m["inc-pan"] = {
"Punjabic",
2656685,
"inc-nwe",
aliases = {"Greater Punjabic"},
protoLanguage = "inc-opa",
}
m["inc-pas"] = {
"Pashayi",
36670,
"inc-dar",
aliases = {"Pashai"},
}
m["inc-rom"] = {
"Romani",
13201,
"inc-wes",
aliases = {"Romany", "Gypsy", "Gipsy"},
}
m["inc-sad"] = {
"Sadanic",
109546827,
"inc-bih",
aliases = {"Sadani"},
}
m["inc-shn"] = {
"Shinaic",
12646125,
"inc-dre",
}
m["inc-snd"] = {
"Sindhic",
7522212,
"inc-nwe",
protoLanguage = "inc-avr",
}
m["inc-sou"] = {
"Southern Indo-Aryan",
10856062,
"inc",
protoLanguage = "inc-ama",
}
m["inc-tha"] = {
"Tharu",
34035,
"inc-eas",
}
m["inc-wes"] = {
"Western Indo-Aryan",
nil,
"inc",
protoLanguage = "inc-agu",
}
m["ine"] = {
"Indo-European",
19860,
aliases = {"Indo-Germanic"},
}
m["ine-ana"] = {
"Anatolian",
147085,
"ine",
}
m["ine-bsl"] = {
"Balto-Slavic",
147356,
"ine",
}
m["ine-luw"] = {
"Luwic",
115748615,
"ine-ana",
aliases = {"Luvic"},
}
m["ine-toc"] = {
"Tocharian",
37029,
"ine",
aliases = {"Tokharian"},
}
m["ira"] = {
"Iranian",
33527,
"iir",
}
m["ira-csp"] = {
"Caspian",
5049123,
"ira-mpr",
}
m["ira-cen"] = {
"Central Iranian",
nil,
"ira",
}
m["ira-kms"] = {
"Komisenian",
nil,
"ira-mpr",
aliases = {"Semnani"},
}
m["ira-lur"] = {
"Luric",
nil, -- ?
"ira-swi",
}
m["ira-mid"] = {
"Middle Iranian",
6841465,
"ira",
}
m["ira-mny"] = {
"Munji-Yidgha",
nil,
"ira-sym",
aliases = {"Yidgha-Munji"},
}
m["ira-msh"] = {
"Mazanderani-Shahmirzadi",
nil,
"ira-csp",
}
m["ira-nei"] = {
"Northeastern Iranian",
10775567,
"ira",
}
m["ira-nwi"] = {
"Northwestern Iranian",
390576,
"ira-wes",
}
m["ira-old"] = {
"Old Iranian",
23301845,
"ira",
}
m["ira-orp"] = {
"Ormuri-Parachi",
nil,
"ira-sei",
}
m["ira-pat"] = {
"Pathan",
nil,
"ira-sei",
}
m["ira-sbc"] = {
"Sogdo-Bactrian",
nil,
"ira-nei",
}
m["ira-mpr"] = {
"Medo-Parthian",
nil,
"ira-nwi",
aliases = {"Partho-Median"},
}
m["ira-sgi"] = {
"Sanglechi-Ishkashimi",
18711232,
"ira-sei",
}
m["ira-shr"] = {
"Shughni-Roshani",
11732824,
"ira-shy",
}
m["ira-shy"] = {
"Shughni-Yazghulami",
nil,
"ira-sym",
}
m["ira-sgc"] = {
"Sogdic",
nil,
"ira-sbc",
aliases = {"Sogdian"},
}
m["ira-sei"] = {
"Southeastern Iranian",
3833002,
"ira",
}
m["ira-swi"] = {
"Southwestern Iranian",
390424,
"ira-wes",
}
m["ira-sym"] = {
"Shughni-Yazghulami-Munji",
nil,
"ira-sei",
}
m["ira-wes"] = {
"Western Iranian",
129850,
"ira",
}
m["ira-zgr"] = {
"Zaza-Gorani",
167854,
"ira-mpr",
aliases = {"Zaza-Gurani", "Gorani-Zaza"},
}
m["iro"] = {
"Iroquoian",
33623,
pseudo_families = "nai",
}
m["iro-nor"] = {
"North Iroquoian",
nil,
"iro",
}
m["itc"] = {
"Italic",
131848,
"ine",
}
m["itc-laf"] = {
"Latino-Faliscan",
33478,
"itc",
aliases = {"Latinian"},
}
m["itc-sbl"] = {
"Osco-Umbrian",
515194,
"itc",
aliases = {"Sabellic", "Sabellian"},
}
m["jpx"] = {
"Japonic",
33612,
aliases = {"Japanese", "Japanese-Ryukyuan"},
}
m["jpx-nry"] = {
"Northern Ryukyuan",
20862796,
"jpx-ryu",
}
m["jpx-ryu"] = {
"Ryukyuan",
56393,
"jpx",
}
m["jpx-sry"] = {
"Southern Ryukyuan",
18392243,
"jpx-ryu",
}
m["kar"] = {
"Karen",
1364815,
"sit",
}
m["kca"] = {
"Khanty",
33563,
"urj-ugr",
aliases = {"Khantyic", "Khantic"},
}
--[=[
Exceptional language and family codes for Khoisan and Kordofanian languages can use
the prefix "khi-" and "kdo-" respectively, though they are no longer family codes themselves.
]=]--
m["khi-kal"] = {
"Kalahari Khoe",
nil,
"khi-kho",
}
m["khi-khk"] = {
"Khoekhoe",
nil,
"khi-kho",
}
m["khi-kkw"] = {
"Khoe-Kwadi",
60785084,
aliases = {"Kwadi-Khoe"},
}
m["khi-kho"] = {
"Khoe",
2736449,
"khi-kkw",
aliases = {"Central Khoisan"},
}
m["khi-kxa"] = {
"Kx'a",
6450587,
aliases = {"Kxa", "Ju-ǂHoan"},
}
m["khi-tuu"] = {
"Tuu",
631046,
aliases = {"Kwi", "Taa-Kwi", "Southern Khoisan", "Taa-ǃKwi", "Taa-ǃUi", "ǃUi-Taa"},
}
m["kro"] = {
"Kru",
33535,
"nic-vco",
}
m["kro-aiz"] = {
"Aizi",
4699431,
"kro",
}
m["kro-bet"] = {
"Bété",
32956,
"kro-ekr",
}
m["kro-did"] = {
"Dida",
32685,
"kro-ekr",
}
m["kro-ekr"] = {
"Eastern Kru",
5972899,
"kro",
}
m["kro-grb"] = {
"Grebo",
5601537,
"kro-wkr",
}
m["kro-wee"] = {
"Wee",
nil,
"kro-wkr",
}
m["kro-wkr"] = {
"Western Kru",
5972897,
"kro",
}
m["ku"] = {
"Kurdish",
36368,
"ira-nwi",
}
m["kv"] = {
"Komi",
36126, -- "Komi language" in Wikipedia but refers specifically to Komi-Zyrian; no Wikidata item for Komi family
"urj-prm",
}
m["map"] = {
"Austronesian",
49228,
}
m["map-ata"] = {
"Atayalic",
716610,
"map",
}
m["mjg"] = {
"Monguor",
34214,
"xgn-shr",
}
m["mkh"] = {
"Mon-Khmer",
33199,
"aav",
}
m["mkh-asl"] = {
"Aslian",
3111082,
"mkh",
}
m["mkh-ban"] = {
"Bahnaric",
56309,
"mkh",
}
m["mkh-kat"] = {
"Katuic",
56697,
"mkh",
}
m["mkh-khm"] = {
"Khmuic",
1323245,
"mkh",
}
m["mkh-kmr"] = {
"Khmeric",
nil,
"mkh",
}
m["mkh-mnc"] = {
"Monic",
3217497,
"mkh",
}
m["mkh-mng"] = {
"Mangic",
3509556,
"mkh",
}
m["mkh-nbn"] = {
"North Bahnaric",
56309,
"mkh-ban",
}
m["mkh-pal"] = {
"Palaungic",
2391173,
"mkh",
}
m["mkh-pea"] = {
"Pearic",
3073022,
"mkh",
}
m["mkh-pkn"] = {
"Pakanic",
nil,
"mkh-mng",
}
m["mkh-vie"] = {
"Vietic",
2355546,
"mkh",
}
m["mno"] = {
"Manobo",
3217483,
"phi",
}
m["mns"] = {
"Mansi",
33759,
"urj-ugr",
aliases = {"Mansic"},
}
m["mun"] = {
"Munda",
33892,
"aav",
}
m["myn"] = {
"Mayan",
33738,
pseudo_families = "cai",
}
m["nai"] = {
"North American Indigenous",
51739,
"qfa-not",
}
--[=[
Exceptional language and family codes for North American Indigenous/Indian languages
can use the prefix "nai-", though "nai" is not a proper family (only a pseudo-family).
]=]--
m["nai-cat"] = {
"Catawban",
3446638,
"nai-sca",
}
m["nai-chu"] = {
"Chumash",
1288420,
aliases = {"Chumashan"},
}
m["nai-ckn"] = {
"Chinookan",
610586,
}
m["nai-coo"] = {
"Coosan",
940278,
}
m["nai-jcq"] = {
"Jicaquean",
12179308,
"hok",
pseudo_families = "cai",
}
m["nai-ker"] = {
"Keresan",
35878,
}
m["nai-klp"] = {
"Kalapuyan",
1569040,
}
m["nai-kta"] = {
"Kiowa-Tanoan",
386288,
}
m["nai-len"] = {
"Lencan",
36189,
aliases = {"Lenca"},
pseudo_families = "cai",
}
m["nai-mdu"] = {
"Maiduan",
33502,
}
m["nai-miz"] = {
"Mixe-Zoquean",
954016,
aliases = {"Mixe-Zoque"},
pseudo_families = "cai",
}
m["nai-min"] = {
"Misumalpan",
281693,
"qfa-mch",
aliases = {"Misuluan", "Misumalpa"},
pseudo_families = "cai",
}
m["nai-mus"] = {
"Muskogean",
902978,
aliases = {"Muskhogean"},
}
m["nai-pak"] = {
"Pakawan",
65085487,
"hok",
}
m["nai-pal"] = {
"Palaihnihan",
1288332,
}
m["nai-plp"] = {
"Plateau Penutian",
2307476,
}
m["nai-pom"] = {
"Pomoan",
2618420,
"hok",
aliases = {"Pomo", "Kulanapan"},
}
m["nai-sca"] = {
"Siouan-Catawban",
34181,
}
m["nai-shp"] = {
"Sahaptian",
114782,
"nai-plp",
}
m["nai-shs"] = {
"Shastan",
2991735,
"hok",
}
m["nai-tot"] = {
"Totozoquean",
7828419,
pseudo_families = "cai",
}
m["nai-ttn"] = {
"Totonacan",
34039,
aliases = {"Totonac-Tepehua", "Totonacan-Tepehuan"},
varieties = {"Totonac"},
pseudo_families = "cai",
}
m["nai-tqn"] = {
"Tequistlatecan",
1568317,
"hok",
aliases = {"Tequistlatec", "Chontal", "Chontalan", "Oaxacan Chontal", "Chontal of Oaxaca"},
pseudo_families = "cai",
}
m["nai-tsi"] = {
"Tsimshianic",
34134,
}
m["nai-utn"] = {
"Utian",
13371763,
"nai-you",
aliases = {"Miwok-Costanoan", "Mutsun"},
}
m["nai-wtq"] = {
"Wintuan",
1294259,
aliases = {"Wintun"},
}
m["nai-xin"] = {
"Xincan",
1546494,
aliases = {"Xinca"},
pseudo_families = "cai",
}
m["nai-ykn"] = {
"Yukian",
2406722,
aliases = {"Yuki-Wappo"},
}
m["nai-you"] = {
"Yok-Utian",
2886186,
}
m["nai-yuc"] = {
"Yuman-Cochimí",
579137,
}
m["ngf"] = {
"Trans-New Guinea",
34018,
pseudo_families = "paa",
}
m["ngf-ais"] = {
"Aisian",
nil,
"ngf-eso",
}
m["ngf-ang"] = {
"Angan",
3217366,
"ngf",
aliases = {"Kratke Range"}, -- Usher
}
m["ngf-ank"] = {
"Angal-Kewa",
12626916, -- exist in dewiki and hrwiki
"ngf-sak",
}
m["ngf-ask"] = {
"Asmat-Kamoro",
3031400,
"ngf",
-- Wikipedia uses Asmat-Kamoro to refer to a narrower group excluding the Sabakor languages (Buruwai and Kamberau,
-- which Glottolog splits into North Kamrau and South Kamrau [sic]), and uses Asmat-Kamrau to refer to what we and
-- Glottolog call Asmat-Kamoro. Glottolog does not recognize the narrower grouping.
aliases = {"Asmat-Kamrau", -- Wikipedia
"Asmat-Kamrau Bay", -- Usher
},
}
m["ngf-asm"] = {
"Asmat",
4807421,
"ngf-ask",
}
m["ngf-ata"] = {
"Ankave-Tainae-Akoye",
nil,
"ngf-ang",
aliases = {"Southwest Kratke Range"}, -- Usher
}
m["ngf-awd"] = {
"Awyu-Dumut", -- [[w:Awyu-Dumut languages]] redirects to [[w:Greater Awyu languages]]
4830163, -- exist in eswiki, hrwiki and ruwiki
"ngf-gaw",
aliases = {"Central Digul River"}, -- Usher
}
m["ngf-awy"] = {
"Awyu",
96372866,
"ngf-awd",
}
m["ngf-bda"] = {
"Becking-Dawi",
nil, -- Q55993716 ([[Category:Becking–Dawi languages]]) exists in enwiki
"ngf-gaw",
aliases = {"Becking and Dawi Rivers"}, -- Usher
}
m["ngf-bin"] = {
"Binanderean",
3217374, -- Wikidata doesn't distinguish Binanderean from Greater Binanderean
"ngf-gbi",
aliases = {"Oro"}, -- Usher (2020)
}
m["ngf-boa"] = {
"Boane",
nil,
"ngf-era",
aliases = {"Boana", -- Glottolog's name
"Wain"}, -- not in Usher; "Wain" often excludes Mungkip, perhaps because it's poorly documented
}
m["ngf-bos"] = {
"Bosavi",
4947122,
"ngf",
aliases = {"Papuan Plateau"}, -- alternative name given by Wikipedia
}
m["ngf-bsi"] = {
"Baruya-Simbari",
nil,
"ngf-ang",
aliases = {"Northwest Kratke Range"}, -- Usher
}
m["ngf-cda"] = {
"Central Dani",
nil,
"ngf-dan",
aliases = {"Dani"}, -- Usher
}
m["ngf-chw"] = {
"Chimbu-Wahgi",
3217383,
"ngf",
aliases = {"Simbu-Western Highlands"}, -- alternative name given by Wikipedia
}
m["ngf-dag"] = {
"Dagan",
5208454,
"ngf", -- not accepted as TNG by Glottolog but accepted by all others
aliases = {"Meneao Range"},
}
m["ngf-dal"] = {
"Dallman",
nil,
"ngf-huo",
aliases = {"Kinalakna-Kumukio", -- Pawley-Hammarström, who exclude Nomu, but they only had a numeral list of that language to work from
"Northeast Huon", -- Usher
},
}
m["ngf-dan"] = {
"Dani",
3217389,
"ngf",
-- Wikipedia renames the Dani languages to the Baliem Valley languages and sometimes (but not consistently)
-- reserves the name Dani (or "Dani proper") for a narrower group excluding Wano and the poorly attested Ngalik
-- languages (Nduga, Silimo, and the Yali dialect cluster, which we, following Ethnologue and Glottolog, split into
-- Anggurk Yali, Ninia Yali and Pass Valley Yali). Glottolog does not recognize the narrower grouping.
aliases = {"Baliem Valley", -- Wikipedia
"Balim Valley", -- Usher
},
}
m["ngf-dum"] = {
"Dumut", -- [[w:Dumut languages]] redirects to [[w:Greater Awyu languages]]
nil,
"ngf-awd",
aliases = {"Wambon"}, -- Usher
}
m["ngf-ehu"] = {
"Eastern Huon", -- Glottolog adds Ono and Sialum, Pawley-Hammarström adds Dedua
10567087,
"ngf-huo",
aliases = {"East Huon"}, -- Usher
}
m["ngf-eku"] = {
"East Kutubuan",
5328752,
"ngf", -- Not in TNG per Glottolog but accepted by all others. Sometimes grouped with Fasu to form a Kutubuan family.
aliases = {"East Kutubu"}, -- Glottolog's name
}
m["ngf-enc"] = {
"Engic",
nil,
"ngf-eng",
aliases = {"Engan", -- Glottolog
"Engan proper", -- Wikipedia
"North Engan", -- alternative name given by Wikipedia
"Trans-Enga", -- Usher
},
}
m["ngf-eng"] = {
"Engan",
3217449,
"ngf",
aliases = {"Enga-Kewa-Huli", -- Glottolog, Pawley-Hammarström
"Enga-Southern Highlands", -- Usher
},
}
m["ngf-era"] = {
"Erap",
nil,
"ngf-fin",
aliases = {"Erap River"}, -- Usher?
}
m["ngf-eso"] = {
"East Sogeram",
nil,
"ngf-sog",
}
m["ngf-est"] = {
"East Strickland",
5329440,
"ngf",
aliases = {"Strickland River"}, -- alternative name given by Wikipedia
}
m["ngf-eva"] = {
"Evapia",
nil,
"ngf-rai",
aliases = {"Evapia River"}, -- Usher
}
m["ngf-fgi"] = {
"Fore-Gimi",
nil,
"ngf-gor",
aliases = {"South Goroka"}, -- Usher
}
m["ngf-fhu"] = {
"Finisterre-Huon",
3217453,
"ngf",
aliases = {"Finisterre Range-Huon Peninsula"}, -- per Usher
}
m["ngf-fin"] = {
"Finisterre",
5450373,
"ngf-fhu",
aliases = {"Finisterre-Saruwaged", -- Glottolog's name
"Finisterre Range"}, -- per Usher
}
m["ngf-gah"] = {
"Gahuku",
nil,
"ngf-gor",
aliases = {"Alekano-Asaro River"}, -- Usher
}
m["ngf-gau"] = {
"Gauwa",
nil,
"ngf-kai",
aliases = {"West Kainantu"}, -- Usher
}
m["ngf-gaw"] = {
"Greater Awyu",
12627424,
"ngf",
aliases = {"Digul River"}, -- used by Usher (2020)
}
m["ngf-gbi"] = {
"Greater Binanderean",
3217374, -- Wikidata doesn't distinguish Binanderean from Greater Binanderean
"ngf", -- not placed in Trans-New Guinea in Usher (2020)
aliases = {"Guhu-Oro"}, -- Guhu-Oro is used in Usher (2020)
}
m["ngf-gko"] = {
"Gaena-Korafe",
11732347, -- considered a single Korafe language by Wikipedia
"ngf-bin",
aliases = {"Gaina-Korafe"}, -- Usher
}
m["ngf-gmo"] = {
"Gusap-Mot",
16110857,
"ngf-fin",
aliases = {"Mot River"}, -- Usher?
}
m["ngf-gor"] = {
"Goroka",
15478597,
"ngf-kgo",
}
m["ngf-gsu"] = {
"Gogodala-Suki",
5577428,
"ngf", -- Possibly in the proposed Papuan Gulf family. Not in TNG per Glottolog but accepted by all others.
aliases = {"Suki-Gogodala", -- Glottolog's name
"Suki-Aramia River", -- Used in Usher (2020)
},
}
m["ngf-gum"] = {
"Gum",
5618008,
"ngf-mab",
}
m["ngf-gvd"] = {
"Grand Valley Dani", -- considered a single language by Wikipedia
5595219,
"ngf-cda",
}
m["ngf-hag"] = {
"Hagen", -- [[w:Hagen languages]] redirects to [[w:Chimbu–Wahgi languages]]
nil,
"ngf-chw",
aliases = {"Melpa-Kaugel River"}, -- Usher
}
m["ngf-han"] = {
"Hanseman",
5651020,
"ngf-mab",
aliases = {"Hansemann Range"}, -- Usher
}
m["ngf-huo"] = {
"Huon",
5946109,
"ngf-fhu",
aliases = {"Huon Peninsula"}, -- per Usher
}
m["ngf-jim"] = {
"Jimi", -- [[w:Jimi languages]] and [[w:Jimi River languages]] redirect to [[w:Chimbu–Wahgi languages]]
nil,
"ngf-chw",
aliases = {"Jimi River"}, -- Usher
}
m["ngf-kab"] = {
"Kabwum",
nil,
"ngf-huo",
aliases = {"Timbe-Selepet-Komba", -- Pawley-Hammarström,
"Northwest Huon", -- Usher
},
}
m["ngf-kai"] = {
"Kainantu", -- Kambaira: under "unclassified Kainantu" (Glottolog), Tairora (Pawley-Hammarström), Gauwa (Usher)
15478590,
"ngf-kgo",
aliases = {"Gadsup-Auyana-Awa-Tairora"}, -- Wurm,
}
m["ngf-kak"] = {
"Kalam-Kobon",
6350303,
"ngf-ksa",
aliases = {"Kalam",
"Kaironk River"}, -- Usher (2020)
}
m["ngf-kau"] = {
"Kaukombar",
nil,
"ngf-nad",
aliases = {"Kaukombaran", -- Glottolog following Z'graggen (1975)
"Kaukombar River"}, -- Usher's term
}
m["ngf-kbm"] = {
"Kosorong-Burum-Mindik",
nil,
"ngf-huo",
aliases = {"Bulum River"}, -- Usher
}
m["ngf-kgo"] = {
"Kainantu-Goroka",
3217463,
"ngf",
aliases = {"Eastern Highlands"}, -- per Usher (2020)
}
m["ngf-khu"] = {
"Kewa-Huli",
nil,
"ngf-eng",
aliases = {"Huli-Southern Highlands"}, -- Usher
}
m["ngf-kma"] = {
"Kâte-Mape",
nil,
"ngf-ehu",
aliases = {"Kate-Mape-Sene", -- Pawley-Hammarström (with Sene),
"Southeast Huon", -- Usher
},
}
m["ngf-kme"] = {
"Kapau-Menya",
nil,
"ngf-ang",
aliases = {"Southeast Kratke Range"}, -- Usher
}
m["ngf-koi"] = {
"Koiarian",
11154240,
"ngf", -- not accepted as TNG by Glottolog but accepted by all others
aliases = {"Koiari-Managalas Plateau"},
}
m["ngf-kok"] = {
"Kokon", -- Usher calls it South Mabuso but includes Gum in it
nil,
"ngf-mab",
}
m["ngf-kow"] = {
"Kowan",
6435004,
"ngf-mad",
aliases = {"Isumrud Strait"}, -- per Usher (2020)
}
m["ngf-ksa"] = {
"Kalam-Southern Adelbert",
nil,
"ngf-mad",
aliases = {"Kalamic-South Adelbert", -- Glottolog
"West Madang"}, -- Usher (2020)
}
m["ngf-kto"] = {
"Kube-Tobo", -- per Glottolog, one language "Kulungtfu-Yuanggeng-Tobo"
1173235, -- code for Tobo-Kube language
"ngf-huo",
aliases = {"Tobo-Kube"},
}
m["ngf-kts"] = {
"Komyandaret-Tsaukambo",
nil,
"ngf-bda",
aliases = {"Becking River"}, -- Usher
}
m["ngf-kum"] = {
"Kumil",
nil,
"ngf-nad",
aliases = {"Kumilan", -- Pawley-Hammarström following Z'graggen (1975)
"Kumil River"}, -- Usher's term
}
m["ngf-kya"] = {
"Kamano-Yagaria",
nil,
"ngf-gor",
aliases = {"Henganofi", -- Usher
"Kamano-Yagaria-Keigana",
},
}
m["ngf-lok"] = {
"Lowland Ok",
nil,
"ngf-okk",
}
m["ngf-mab"] = {
"Mabuso",
6721668,
"ngf-mad",
}
m["ngf-mad"] = {
"Madang",
11217556,
"ngf",
aliases = {"Madang-Adelbert Range"}, -- Z'graggen (1975), corresponding to today's Madang except in lacking Kalam and Gants
}
m["ngf-mek"] = {
"Mek",
6810515,
"ngf",
aliases = {"Goliath"}, -- outdated alternative name given by Wikipedia
}
m["ngf-min"] = {
"Mindjim",
86749913,
"ngf-mad",
aliases = {"Lower Minjim", -- Glottolog, placed in Rai Coast by Glottolog and Pawley-Hammarström; Glottolog's
-- Mindjim has 6 languages, including "Upper Minjim" (Rerau and Sgi Bara)
"Mindjim River", -- Usher
"Minjim", "Minjim River",
},
}
-- Add if Molet is separated from Asaro'o
-- m["ngf-moa"] = {
-- "Molet-Asaro'o",
-- nil,
-- "ngf-war",
-- }
m["ngf-mok"] = {
"Mountain Ok", -- [[w:Mountain Ok languages]] redirects to [[w:Ok languages]]
nil,
"ngf-okk",
}
m["ngf-mom"] = {
"Mombum",
6897077,
"ngf", -- not accepted as TNG by Glottolog but accepted by all others
aliases = {"Mombum-Koneraw", "Komolom", "Muli Strait"}, -- Pawley-Hammarström uses Komolom, Usher uses Muli Strait
}
m["ngf-msu"] = {
"Mian-Suganga", -- considred a single Mian language by Wikipedia
12952846,
"ngf-mok",
aliases = {"Mianic"}, -- Glottolog
}
m["ngf-nad"] = {
"Northern Adelbert", -- not accepted by Pawley-Hammarström
16952821, -- code for Croisilles linkage
"ngf-mad",
aliases = {"Adelbert Range-Isumrud Strait", -- Usher (2020)
"North Adelbert",
"Pihom-Isumrud"}, -- Ross?
}
m["ngf-nbi"] = {
"North Binanderean",
nil,
"ngf-bin",
aliases = {"Suena-Zia"}, -- Usher
}
m["ngf-nde"] = {
"Ndeiram", -- [[w:Ndeiram River languages]] redirects to [[w:Greater Awyu languages]]
nil,
"ngf-awd",
aliases = {"Ndeiram River"}, -- Usher?
}
m["ngf-ngn"] = {
"Ngalik-Nduga", -- [[w:Ngalik languages]] redirects to [[w:Baliem Valley languages]] = Dani languages
nil,
"ngf-dan",
aliases = {"Ngalik"}, -- Usher
}
m["ngf-nso"] = {
"North Sogeram",
nil,
"ngf-sog",
aliases = {"Mum-Sirva", -- Usher
"North Central Sogeram", -- used by those who accept Central Sogeram (= North Sogeram + Apali and Manat)
"North-Central Sogeram", -- rarer than without the dash
"Sikan"}, -- Z’graggen (1975?)
}
m["ngf-num"] = {
"Numugen",
nil,
"ngf-nad",
aliases = {"Numugenan", -- Glottolog following Z'graggen 1975
"Numugen River"}, -- Usher's term
}
m["ngf-nur"] = {
"Nuru", -- Usher excludes Yangulam, Pawley-Hammarström include Jilim and Rerau
nil,
"ngf-rai",
aliases = {"Nuru River"}, -- Usher?
}
m["ngf-nwh"] = {
"Northwest Hanseman", -- Usher
nil,
"ngf-han",
aliases = {"Wamas-Samosa-Murupi-Mosimo"}, -- Glottolog, Greenhill, and Pawley-Hammarström following Z'graggen; the most common name, but very unwieldy
}
m["ngf-oen"] = {
"Outer Engan", -- considered a single Nete language by Wikipedia
6998869,
"ngf-enc",
aliases = {"Nete-Bisorio"}, -- Usher
}
m["ngf-okk"] = {
"Ok",
7081687,
"ngf",
}
m["ngf-omo"] = {
"Omosan", -- not included in (Greater) Northern Adelbert by Glottolog, but a sister
nil,
"ngf-nad",
}
m["ngf-oro"] = {
"Orokaivic",
7103752, -- considered a single Orokaiva language by Wikipedia
"ngf-bin",
aliases = {"Central Oro"}, -- Usher
}
m["ngf-pan"] = {
"Paniai Lakes",
6035631,
"ngf",
aliases = {"Wissel Lakes", "Wissel Lakes-Kemandoga River"}, -- alternative names given by Wikipedia
}
m["ngf-pek"] = {
"Peka",
nil,
"ngf-rai",
aliases = {"Peka River"}, -- Usher?
}
m["ngf-pom"] = {
"Pomoikan",
nil,
"ngf-sad",
}
m["ngf-rai"] = {
"Rai Coast",
7283663,
"ngf-mad",
aliases = {"South Madang"}, -- Usher
}
m["ngf-sab"] = {
"Sabakor", -- [[w:Sabakor languages]] redirects to [[w:Asmat–Kamrau languages]]
nil, -- 55994614 is for [[Category:Kamrau Bay languages]], which exists on enwiki
"ngf-ask",
aliases = {"Kamrau Bay"}, -- Usher
}
m["ngf-sad"] = {
"Southern Adelbert",
12633980,
"ngf-ksa",
aliases = {"South Adelbert", -- Glottolog
"Southern Adelbert Range", -- Z'graggen (1980)
"Sogeram and Tomul Rivers"}, -- Usher (2020)?
}
m["ngf-sak"] = {
"Sau-Angal-Kewa",
nil,
"ngf-khu",
aliases = {"Southern Highlands"}, -- Usher
}
m["ngf-san"] = {
"Sankwep",
nil,
"ngf-huo",
aliases = {"Nabak-Momolili", -- Pawley-Hammarström,
"Southwest Huon", -- Usher
},
}
m["ngf-sbh"] = {
"South Bird's Head",
7566330,
"ngf",
}
m["ngf-sim"] = {
"Simbu",
nil,
"ngf-chw",
}
m["ngf-sog"] = {
"Sogeram",
86750419,
"ngf-sad",
aliases = {"Sogeram River", -- Usher
"Wanang"},
}
m["ngf-sop"] = {
"Sopac",
nil,
"ngf-ehu",
aliases = {"Momare-Migabac", -- Pawley-Hammarström,
"Masaweng River", -- Usher
},
}
m["ngf-taa"] = {
"Tainae-Akoye",
nil,
"ngf-ata",
aliases = {"Akoye-Tainae"}, -- Usher
}
m["ngf-tai"] = {
"Tairora",
nil,
"ngf-kai",
aliases = {"Tairoric", -- Glottolog,
"East Kainantu", -- Usher
},
}
m["ngf-tib"] = {
"Tiboran",
nil,
"ngf-nad",
aliases = {"Nuclear Tibor", -- Glottolog, excluding Wanambre/Mokati
"Tiboran River", -- Usher (2020)
"Tibor", -- Pick (2020) and Glottolog including Wanambre/Mokati
}
}
m["ngf-tna"] = {
"Tangko-Nakai",
nil,
"ngf-okk",
aliases = {"Central Ok"}, -- Usher
}
m["ngf-uru"] = {
"Uruwa",
nil,
"ngf-fin",
aliases = {"Uruwa River"}, -- Usher?
}
m["ngf-usi"] = {
"Utu-Silopi",
nil,
"ngf-han",
aliases = {"Silopi-Utu"}, -- Usher
}
m["ngf-waa"] = {
"Wantoat-Awara", -- not in Usher but Wantoat and Awara form a dialect chain
nil,
"ngf-wan",
aliases = {"Awara-Wantoat"}, -- per Wikipedia
}
m["ngf-wah"] = {
"Wahgi", -- [[w:Wahgi languages]] redirects to [[w:Chimbu–Wahgi languages]]
nil,
"ngf-chw",
aliases = {"Wahgi Valley"}, -- Usher
}
m["ngf-wan"] = {
"Wantoatic",
nil,
"ngf-fin",
aliases = {"Wantoat",
"Wantoat River", -- Usher?
},
}
m["ngf-war"] = {
"Warup",
12645082,
"ngf-fin",
aliases = {"Warup River"}, -- Usher?
}
m["ngf-woj"] = {
"Wojokesic",
nil,
"ngf-ang",
aliases = {"Northeast Kratke Range"}, -- Usher
}
m["ngf-wok"] = {
"West Ok",
nil,
"ngf-okk",
aliases = {"Kwer-Kopkaka-Burumakok"}, -- Glottolog, Pawley-Hammarström
}
m["ngf-wso"] = {
"West Sogeram",
nil,
"ngf-sog",
aliases = {"Mand-Nend", -- Usher
"Atan", -- Wurm following Z'graggen
},
}
m["ngf-yag"] = {
"Yaganon", -- placed in Rai Coast by Glottolog and Pawley-Hammarström
35323986,
"ngf-mad",
aliases = {"Yaganon River"}, -- Usher
}
m["ngf-yal"] = {
"Yali", -- considered a single language by Wikipedia
8047468,
"ngf-ngn",
aliases = {"Ngalik"}, -- Glottolog, Pawley-Hammarström
}
m["ngf-yar"] = {
"Yareban",
16977672,
"ngf", -- not accepted as TNG by Glottolog but accepted by all others
aliases = {"Musa River"},
}
m["ngf-ynu"] = {
"Yau-Nungon",
12953319, -- for the single Yau language in Wikipedia ([[w:Yau language (Trans–New Guinea)]])
"ngf-uru",
}
m["ngf-yup"] = {
"Yupna",
nil,
"ngf-fin",
aliases = {"Yupna River"}, -- Usher?
}
m["nic"] = {
"Niger-Congo",
33838,
aliases = {"Niger-Kordofanian"},
}
m["nic-alu"] = {
"Alumic",
4737355,
"nic-plt",
}
m["nic-bas"] = {
"Basa",
4866154,
"nic-knj",
}
m["nic-bbe"] = {
"Eastern Beboid",
nil,
"nic-beb",
}
m["nic-bco"] = {
"Benue-Congo",
33253,
"nic-vco",
}
m["nic-bcr"] = {
"Bantoid-Cross",
806983,
"nic-bco",
}
m["nic-bdn"] = {
"Northern Bantoid",
nil,
"nic-bod",
aliases = {"North Bantoid"},
}
m["nic-bds"] = {
"Southern Bantoid",
3183152,
"nic-bod",
aliases = {"Wide Bantu", "Bin"},
}
m["nic-beb"] = {
"Beboid",
813549,
"nic-bds",
}
m["nic-ben"] = {
"Bendi",
4887065,
"nic-bcr",
}
m["nic-beo"] = {
"Beromic",
4894642,
"nic-plt",
}
m["nic-bod"] = {
"Bantoid",
806992,
"nic-bcr",
}
m["nic-buk"] = {
"Buli-Koma",
nil,
"nic-ovo",
}
m["nic-bwa"] = {
"Bwa",
12628562,
"nic-gur",
other_names = {"Bwamu", "Bomu"},
}
m["nic-cde"] = {
"Central Delta",
3813191,
"nic-cri",
}
m["nic-cri"] = {
"Cross River",
1141096,
"nic-bcr",
}
m["nic-dag"] = {
"Dagbani",
nil,
"nic-wov",
}
m["nic-dak"] = {
"Dakoid",
1157745,
"nic-bdn",
}
m["nic-dge"] = {
"Escarpment Dogon",
5397128,
"qfa-dgn",
}
m["nic-dgw"] = {
"West Dogon",
nil,
"qfa-dgn",
}
m["nic-eko"] = {
"Ekoid",
1323395,
"nic-bds",
}
m["nic-eov"] = {
"Eastern Oti-Volta",
nil,
"nic-ovo",
aliases = {"Samba"},
}
m["nic-fru"] = {
"Furu",
5509783,
"nic-bds",
}
m["nic-gne"] = {
"Eastern Gurunsi",
12633072,
"nic-gns",
aliases = {"Eastern Grũsi"},
}
m["nic-gnn"] = {
"Northern Gurunsi",
nil,
"nic-gns",
aliases = {"Northern Grũsi"},
}
m["nic-gnw"] = {
"Western Gurunsi",
nil,
"nic-gns",
aliases = {"Western Grũsi"},
}
m["nic-gns"] = {
"Gurunsi",
721007,
"nic-gur",
aliases = {"Grũsi"},
}
m["nic-gre"] = {
"Eastern Grassfields",
5330160,
"nic-grf",
}
m["nic-grf"] = {
"Grassfields",
750932,
"nic-bds",
aliases = {"Grassfields Bantu", "Wide Grassfields"},
}
m["nic-grm"] = {
"Gurma",
30587833,
"nic-ovo",
}
m["nic-grs"] = {
"Southwest Grassfields",
7571285,
"nic-grf",
}
m["nic-gur"] = {
"Gur",
33536,
"alv-sav",
aliases = {"Voltaic"},
}
m["nic-ief"] = {
"Ibibio-Efik",
2743643,
"nic-lcr",
}
m["nic-jer"] = {
"Jera",
nil,
"nic-kne",
}
m["nic-jkn"] = {
"Jukunoid",
1711622,
"nic-pla",
}
m["nic-jrn"] = {
"Jarawan",
1683430,
"nic-mba",
}
m["nic-jrw"] = {
"Jarawa",
35423,
"nic-jrn",
}
m["nic-kam"] = {
"Kambari",
6356294,
"nic-knj",
}
m["nic-ktl"] = {
"Katloid",
nil,
"nic",
}
m["nic-kau"] = {
"Kauru",
nil,
"nic-kne",
}
m["nic-kmk"] = {
"Kamuku",
6359821,
"nic-knj",
}
m["nic-kne"] = {
"East Kainji",
5328687,
"nic-knj",
}
m["nic-knj"] = {
"Kainji",
681495,
"nic-pla",
}
m["nic-knn"] = {
"Northwest Kainji",
7060098,
"nic-knj",
}
m["nic-ktl"] = {
"Katloid",
6377681,
"nic",
aliases = {"Katla", "Katla-Tima"},
}
m["nic-lcr"] = {
"Lower Cross River",
3813193,
"nic-cri",
}
m["nic-mam"] = {
"Mamfe",
2005898,
"nic-bds",
aliases = {"Nyang"},
}
m["nic-mba"] = {
"Mbam",
687826,
"nic-bds",
}
m["nic-mbc"] = {
"Mba",
6799561,
"nic-ubg",
}
m["nic-mbw"] = {
"West Mbam",
nil,
"nic-mba",
}
m["nic-mmb"] = {
"Mambiloid",
1888151,
other_names = {"North Bantoid"}, -- per Wikipedia, North Bantoid is the parent family
"nic-bdn",
}
m["nic-mom"] = {
"Momo",
6897393,
"nic-grf",
}
m["nic-mre"] = {
"Moré",
nil,
"nic-wov",
}
m["nic-ngd"] = {
"Ngbandi",
36439,
"nic-ubg",
}
m["nic-nge"] = {
"Ngemba",
7022271,
"nic-gre",
}
m["nic-ngk"] = {
"Ngbaka",
3217499,
"nic-ubg",
}
m["nic-nin"] = {
"Ninzic",
7039282,
"nic-plt",
}
m["nic-nka"] = {
"Nkambe",
7042520,
"nic-gre",
}
m["nic-nkb"] = {
"Baka",
nil,
"nic-nkw",
}
m["nic-nke"] = {
"Eastern Ngbaka",
nil,
"nic-ngk",
}
m["nic-nkg"] = {
"Gbanziri",
nil,
"nic-nkw",
}
m["nic-nkk"] = {
"Kpala",
nil,
"nic-nkw",
}
m["nic-nkm"] = {
"Mbaka",
nil,
"nic-nkw",
}
m["nic-nkw"] = {
"Western Ngbaka",
nil,
"nic-ngk",
}
m["nic-npd"] = {
"North Plateau Dogon",
nil,
"qfa-dgn",
}
m["nic-nun"] = {
"Nun",
13654297,
"nic-gre",
}
m["nic-nwa"] = {
"Nanga-Walo",
nil,
"qfa-dgn",
}
m["nic-ogo"] = {
"Ogoni",
2350726,
"nic-cri",
aliases = {"Ogonoid"},
}
m["nic-ovo"] = {
"Oti-Volta",
1157178,
"nic-gur",
}
m["nic-pla"] = {
"Platoid",
453244,
"nic-bco",
aliases = {"Central Nigerian"},
}
m["nic-plc"] = {
"Central Plateau",
5061668,
"nic-plt",
}
m["nic-pld"] = {
"Plains Dogon",
nil,
"qfa-dgn",
}
m["nic-ple"] = {
"East Plateau",
5329154,
"nic-plt",
}
m["nic-pls"] = {
"South Plateau",
7568236,
"nic-plt",
aliases = {"Jilic-Eggonic"},
}
m["nic-plt"] = {
"Plateau",
1267471,
"nic-pla",
}
m["nic-ras"] = {
"Rashad",
3401986,
"nic",
}
m["nic-rnc"] = {
"Central Ring",
nil,
"nic-rng",
}
m["nic-rng"] = {
"Ring",
2269051,
"nic-grf",
aliases = {"Ring Road"},
}
m["nic-rnn"] = {
"Northern Ring",
nil,
"nic-rng",
}
m["nic-rnw"] = {
"Western Ring",
nil,
"nic-rng",
}
m["nic-ser"] = {
"Sere",
7453058,
"nic-ubg",
}
m["nic-shi"] = {
"Shiroro",
7498953,
"nic-knj",
aliases = {"Pongu"},
}
m["nic-sis"] = {
"Sisaala",
36532,
"nic-gnw",
}
m["nic-tar"] = {
"Tarokoid",
2394472,
"nic-plt",
}
m["nic-tiv"] = {
"Tivoid",
752377,
"nic-bds",
}
m["nic-tvc"] = {
"Central Tivoid",
nil,
"nic-tiv",
}
m["nic-tvn"] = {
"Northern Tivoid",
nil,
"nic-tiv",
}
m["nic-ubg"] = {
"Ubangian",
33932,
"nic-vco", -- or none
}
m["nic-uce"] = {
"East-West Upper Cross River",
nil,
"nic-ucr",
}
m["nic-ucn"] = {
"North-South Upper Cross River",
nil,
"nic-ucr",
}
m["nic-ucr"] = {
"Upper Cross River",
4108624,
"nic-cri",
aliases = {"Upper Cross"},
}
m["nic-vco"] = {
"Volta-Congo",
37228,
"alv",
}
m["nic-wov"] = {
"Western Oti-Volta",
nil,
"nic-ovo",
aliases = {"Moré-Dagbani"}
}
m["nic-ykb"] = {
"Yukubenic",
16909196,
"nic-plt",
aliases = {"Oohum"},
}
m["nic-ymb"] = {
"Yambasa",
nil,
"nic-mba",
}
m["nic-yon"] = {
"Yom-Nawdm",
nil,
"nic-ovo",
aliases = {"Moré-Dagbani"}
}
m["njo"] = {
"Ao",
28433,
"sit-aao",
aliases = {"Ao Naga"},
}
m["nub"] = {
"Nubian",
1517194,
"sdv-nes",
}
m["nub-hil"] = {
"Hill Nubian",
5762211,
"nub",
aliases = {"Kordofan Nubian"},
}
m["omq"] = {
"Oto-Manguean",
33669,
pseudo_families = "cai",
}
m["omq-cha"] = {
"Chatino",
35111,
"omq-zap",
}
m["omq-chi"] = {
"Chinantecan",
35828,
"omq",
}
m["omq-cui"] = {
"Cuicatec",
616024,
"omq-mix",
}
m["omq-maz"] = {
"Mazatec",
36230,
"omq",
aliases = {"Mazatecan"},
}
m["omq-mix"] = {
"Mixtecan",
21083066,
"omq",
}
m["omq-mxt"] = {
"Mixtec",
36363,
"omq-mix",
}
m["omq-otp"] = {
"Oto-Pamean",
1270220,
"omq",
}
m["omq-pop"] = {
"Popolocan",
5132273,
"omq",
}
m["omq-tri"] = {
"Triqui",
780200,
"omq-mix",
aliases = {"Trique"},
}
m["omq-zap"] = {
"Zapotecan",
8066463,
"omq",
}
m["omq-zpc"] = {
"Zapotec",
13214,
"omq-zap",
}
m["omv"] = {
"Omotic",
33860,
"afa",
}
m["omv-aro"] = {
"Aroid",
3699526,
"omv",
aliases = {"Ari-Banna", "South Omotic", "Somotic"},
}
m["omv-diz"] = {
"Dizoid",
430251,
"omv",
aliases = {"Maji", "Majoid"},
}
m["omv-eom"] = {
"East Ometo",
20527288,
"omv-ome",
}
m["omv-gon"] = {
"Gonga",
4143043,
"omv",
aliases = {"Kefoid"},
}
m["omv-mao"] = {
"Mao",
1351495,
"omv",
}
m["omv-nom"] = {
"North Ometo",
nil,
"omv-ome",
}
m["omv-ome"] = {
"Ometo",
36310,
"omv",
}
m["oto"] = {
"Otomian",
130372545,
"omq-otp",
}
m["oto-otm"] = {
"Otomi",
36355,
"oto",
}
m["paa"] = {
"Papuan",
236425,
"qfa-not",
}
m["paa-aia"] = {
"Aian",
4767739, -- Annaberg languages
"paa-ram",
aliases = {"Middle Ramu", -- Foley (with Rao),
"Annaberg", -- with Rao
"Aram-Aren", -- Usher
},
}
m["paa-alp"] = {
"Alor-Pantar",
3502429,
"paa-tap",
}
m["paa-amu"] = {
"Amto-Musan",
480281,
aliases = {"Samaia River"},
}
m["paa-ani"] = {
"Anim",
55603991,
aliases = {"Fly River"},
}
m["paa-ara"] = {
"Arapesh",
4784223,
"paa-koa",
aliases = {"Arapeshan"}, -- Foley
}
m["paa-arf"] = {
"Arafundi",
4783702,
}
m["paa-ata"] = {
"Ataitan",
4812652,
"paa-ram",
aliases = {"Tangu", -- Foley
"Tanggu", -- alternative name given by Wikipedia
"Moam River", -- Usher
},
}
m["paa-baa"] = {
"Bayono-Awbono",
2424781,
}
m["paa-bai"] = {
"Baining",
748487,
aliases = {"East New Britain"},
}
m["paa-baw"] = {
"Bosngun-Awar",
nil,
"paa-ott",
aliases = {"East Ramu Coast", -- Usher
"Bosman-Awar", -- Wikipedia
},
}
m["paa-bew"] = {
"Bewani", -- [[w:Bewani languages]] redirects to [[w:Border languages (New Guinea)]]; but Croatian Wikipedia has an entry
16113460,
"paa-bor",
aliases = {"Poal River"}, -- Usher
}
m["paa-boa"] = {
"Boazi",
48803717,
"paa-mby",
aliases = {"Lake Murray"}, -- Usher
}
m["paa-bor"] = {
"Border",
1752158,
aliases = {"Upper Tami",
"Tami River-Bewani Range", -- Usher
},
}
m["paa-bul"] = {
"Bulaka River",
4987195,
aliases = {"Yelmek-Maklew", "Jabga"}, -- Yelmek-Maklew in Evans (2018) and Gregor (2021)
}
m["paa-bvi"] = {
"Betaf-Vitou", -- Glottolog
nil,
"paa-tor",
aliases = {"Vitou-Betaf", -- Wikipedia
"Fitou-Tena", -- Usher
"Manirem",
},
}
m["paa-clp"] = {
"Central Lakes Plain", -- [[w:Central Lakes Plain languages]] redirects to [[w:Lakes Plain languages]]
nil, -- Q86780132 is for the corresponding category, which exists in enwiki
"paa-lpl",
aliases = {"East Tariku", -- Glottolog
"Central Lakes Plains", -- Usher
},
}
m["paa-dtu"] = {
"Doso-Turumsa",
16917784,
-- possibly related to East Strickland languages
aliases = {"Soari River"}, -- Usher's name
}
m["paa-ebh"] = {
"East Bird's Head",
338064,
aliases = {"Mantion-Meax", "Mantion-Meyah", -- Mantion-Meax is Wikipedia's term
"Southeast Bird's Head", -- Usher (2020)
},
}
m["paa-eel"] = {
"Eastern Eleman",
nil,
"paa-ele",
aliases = {"East Eleman"},
}
m["paa-egb"] = {
"East Geelvink Bay",
1497678,
aliases = {"Geelvink Bay", "East Cenderawasih"}, -- Geelvink Bay per Glottolog
}
m["paa-eke"] = {
"East Keram",
nil,
"paa-ker",
}
m["paa-ele"] = {
"Eleman",
3034298,
aliases = {"Kerema Bay"},
}
m["paa-elp"] = {
"East Lakes Plain", -- [[w:East Lakes Plain languages]] redirects to [[w:Lakes Plain languages]]; but Croatian Wikipedia has an entry
12633078,
"paa-lpl",
aliases = {"East Lakes Plains"}, -- Usher
}
m["paa-epw"] = {
"Eastern Pauwasi",
16115496,
aliases = {"East Pauwasi"},
}
m["paa-etf"] = {
"Eastern Trans-Fly",
5330530,
aliases = {"Oriomo"}, -- in increasing recent use, probably originating in Evans (2018)
}
m["paa-eti"] = {
"East Timor",
15496066,
"paa-tap",
aliases = {"Oirata-Makasae", -- Wikipedia's name
"Eastern Timor", -- alternative name given by Wikipedia
"Fataluku-Makasai", "Oirata-Makasai", -- alternative names given by Wikidata
},
}
m["paa-fas"] = {
"Fas",
3502658,
aliases = {"Baibai-Fas"}, -- Glottolog's name
}
m["paa-flp"] = {
"Far West Lakes Plain", -- [[w:Wapoga River languages]] redirects to [[w:Lakes Plain languages]]
nil, -- Q86808337 is for the corresponding Wapoga languages category, which exists in enwiki
"paa-lpl",
aliases = {"Rasawa", -- Clouse (1997)
"Wapoga River", -- Usher, including Kehu/Keuw (unclassified by others)
},
}
m["paa-gkw"] = {
"Greater Kwerba",
12635134,
aliases = {"West Foja Range", -- Usher
"Kwerbic", -- Wikipedia
"Kwerba", -- Foley (2018)
},
}
m["paa-gto"] = {
"Galela-Tobelo",
nil,
"paa-nnh",
aliases = {"Mainland North Halmaheran", -- Glottolog
"Mainland North Halmahera", "Northeast Halmahera", -- alternative names
"Northeast Halmaheran", -- Wikipedia, from Verhoeve 1988
},
}
m["paa-hya"] = {
"Heyo-Yahang",
nil,
"paa-mam",
aliases = {"Yahang-Heyo"}, -- Wikipedia's name
}
m["paa-ing"] = {
"Inland Gulf",
6034783,
"paa-ani",
aliases = {"Inland Gulf of Papua"}, -- Glottolog
}
m["paa-isk"] = {
"Inner Sko",
65043889,
"paa-sko",
aliases = {"Skouic", -- Glottolog
"West Vanimo Coast", -- Usher
"Western Skou", -- Wikipedia
"Inner Skou", "Nuclear Skou", -- alternative names given by Wikipedia
},
}
m["paa-iwa"] = {
"Iwam",
15147853,
"paa-sep",
}
m["paa-kae"] = {
"Kamula-Elevala",
130390498,
-- often placed in TNG
aliases = {"Kamula-Elevala River"},
}
m["paa-kan"] = {
"Kanum", -- removed from Tonda by Glottolog
nil,
"paa-ton",
}
m["paa-kay"] = {
"Kayagaric",
7566330,
aliases = {"Kayagar", -- formerly common
"Cook River"}, -- per Usher (2020)
}
m["paa-ker"] = {
"Keram",
48768173,
-- often grouped within or coordinate with the Ramu languages
aliases = {"Keram River"},
}
m["paa-kiw"] = {
"Kiwaian",
338449,
aliases = {"Kiwai"}, -- formerly common, still sees some use
}
m["paa-kko"] = {
"Kaure-Kosare", -- rejected by Pawley-Hammarström but accepted by Glottolog, Foley (2018) and Usher (2020)
48767891,
aliases = {"Nawa River"}, -- Usher's term
}
m["paa-koa"] = {
"Kombio-Arapesh",
16115049,
"paa-trr",
aliases = {"Kombio-Arapeshan", -- Laycock, who includes Wom
"Kombio-Arapesh-Urat", -- Glottolog, including Urat
},
}
m["paa-kol"] = {
"Kolopom",
6427807,
}
m["paa-kom"] = {
"Kombio",
65044238,
"paa-koa",
aliases = {"Kombian", -- Laycock
"Kombio-Yambes", -- Glottolog
},
}
m["paa-kun"] = {
"Kunimaipan",
134973258,
aliases = {"Northwest Wharton Range"}, -- per Usher (2020)
-- often considered a subfamily of Goilalan
}
m["paa-kwa"] = {
"Kwalean",
6450053,
aliases = {"Humene-Uare"},
}
m["paa-kwe"] = {
"Kwerba proper",
12635134,
"paa-gkw",
aliases = {"Kwerba", -- Usher
"Kwerbaic", -- Glottolog
},
}
m["paa-kwo"] = {
"Kwomtari",
2075415,
aliases = {"Kwomtari-Nai"}, -- Senu River is a larger unproven proposal
}
m["paa-lla"] = {
"Loloda-Laba", -- a single language in Glottolog (Loloda-Laba) and Wikipedia (Loloda)
11732388, -- for the Loloda language
"paa-gto",
aliases = {"Loloda"}, -- Wikipedia's name
}
m["paa-lma"] = {
"Left May",
614468,
aliases = {"Arai River"}, -- per Usher (2020)
-- Sometimes in a putative Arai-Samaia family along with Amto-Musan and the Pyu language
}
m["paa-lmu"] = {
"Lepki-Murkim", -- Kembra accepted by Glottolog and Usher; not by Foley (2020) but does not exclude the possibility
-- of a relationship
85776285,
-- independent family per Glottolog, part of South Pauwasi River family (under Pauwasi) per Usher (2020)
aliases = {"Lepki-Murkim-Kembra"}, -- Glottolog
}
m["paa-lpl"] = {
"Lakes Plain",
6478969,
aliases = {"Lakes Plains"},
}
m["paa-lra"] = {
"Lower Ramu",
65089469,
"paa-ram",
aliases = {"Ottilien-Misegian"}, -- alternative name given by Wikipedia
}
m["paa-lse"] = {
"Lower Sepik",
7061700,
aliases = {"Nor-Pondo"},
}
m["paa-mai"] = {
"Mairasi",
6736896,
aliases = {"Mairasic"}, -- per Glottolog
}
m["paa-mal"] = {
"Mailuan",
6735839,
aliases = {"Cloudy Bay"},
}
m["paa-mam"] = {
"Maimai", -- Foley's Maimai is expanded
53679325, -- this is the code for the expanded Maimai with 6 languages, as opposed to the 3 in "Nuclear Maimai"
"paa-trr",
aliases = {"Nuclear Maimai", -- Glottolog's name
"Maimai proper", -- Wikipedia's name
},
}
m["paa-man"] = {
"Manubaran",
6752335,
aliases = {"Mount Brown"},
}
m["paa-mar"] = {
"Marienberg",
1570589,
"paa-trr",
aliases = {"Marienberg Hills"}, -- Usher
}
m["paa-may"] = {
"Maybratic",
4830892, -- the code for the Maybrat language in Wikipedia, which subsumes the two languages of this family
-- putatively included in West Papuan but generally considered an isolated family
aliases = {"Maybrat-Karon"},
}
m["paa-mbi"] = {
"Mbaham-Iha",
85784512,
"qfa-dis", -- Papuan languages; Glottolog groups Karas (Kalamang) with Mbaham-Iha into a (mainland) West Bomberai
-- family and stops there; Wikipedia, following Usher and Schapper (2022), groups Karas, Mbaham-Iha
-- and the large Timor-Alor-Pantar family into a (Greater) West Bomberai family, saying that Karas is no
-- closer to Mbaham-Iha than to Timor-Alor-Pantar.
aliases = {"Mbahaam-Iha", -- used by Wikidata
"Nuclear West Bomberai", -- Glottolog's name
},
}
m["paa-mby"] = {
"Marind-Boazi-Yaqay",
3217484,
"paa-ani",
aliases = {"Marind-Boazi-Yaqai", -- Glottolog
"Marind-Yakhai", -- Usher, without Boazi
"Marind-Yaqai", -- Wikidata
"Marind", -- alternative name given by Wikipedia
"Marind-Arandai", -- alternative name given by Spanish Wikipedia
},
}
m["paa-mmu"] = {
"Mandi-Muniwara",
nil,
"paa-mar",
aliases = {"West Marienberg Hills"}, -- Usher
}
m["paa-mon"] = {
"Monumbo", -- per Glottolog: "No evidence for the Bogia (Monumbo) languages being related to other Torricelli languages was ever presented"
16928417,
aliases = {"Bogia", -- Glottolog
"Bogia Bay", -- Usher (2020)
},
}
m["paa-mri"] = {
"Marindic", -- [[w:Marindic languages]] redirects to [[w:Marind–Yaqai languages]]
nil,
"paa-mby",
aliases = {"Marind"}, -- Usher; a single language
}
m["paa-nam"] = {
"Nambu",
6961418,
"paa-yam",
aliases = {"East Morehead River"}, -- Usher
}
m["paa-nbo"] = {
"North Bougainville",
749496,
}
m["paa-ndu"] = {
"Ndu",
3217498,
"paa-sep", -- Not accepted by Glottolog
aliases = {"Ndu-Nggala"}, -- Usher
}
m["paa-ngk"] = {
"Ngkolmpu", -- considered a single language by Wikipedia
5908646,
"paa-kan",
aliases = {"Ngkantr", -- Glottolog
"Ngkolmpu Kanum", -- Wikipedia
"Ngkontar", -- alternative name given by Wikipedia
"Kanum", -- used by Wikidata
},
}
m["paa-nha"] = {
"North Halmahera",
3217358,
-- possibly in a proposed West Papuan family or an independent family
}
m["paa-nim"] = {
"Nimboran",
12638426,
aliases = {"Nimboranic", -- per Glottolog
"Grime River", -- per Usher (2020)
}
}
m["paa-nnd"] = {
"Nuclear Ndu",
nil,
"paa-ndu",
aliases = {"Ndu", -- Usher, with Boiken/Boikin
"Ndu proper", -- Wikipedia
},
}
m["paa-nnh"] = {
"Northern North Halmahera",
nil,
"paa-nha",
aliases = {"Northern North Halmaheran", -- Glottolog
"Halmahera", -- Usher
"Core Halmaheran", -- Wikipedia
},
}
m["paa-nto"] = {
"Namla-Tofanma",
16918187,
-- independent family per Glottolog and Foley (2018), part of West Pauwasi family (under Pauwasi) per Usher (2020)
}
m["paa-ott"] = {
"Ottilien",
7109477,
"paa-lra",
aliases = {"Ramu Coast", -- Usher
"Watam-Awar-Gamay", -- alternative name given by Wikipedia
},
}
m["paa-pah"] = {
"Pahoturi River",
17049141,
aliases = {"Pahoturi"}, -- per Glottolog
}
m["paa-pal"] = {
"Palei", -- Laycock adds Agi and Nabi/Nambi(-Metan)
65089113,
"paa-wpa",
aliases = {"Nuclear Palai"},
}
m["paa-pia"] = {
"Piawi", -- per Wikipedia, grouped with Arafundi languages to form Upper Yuat, which is a sister to Madang
7190400,
aliases = {"Schraeder Range", -- Usher?
"Waibuk"},
}
m["paa-pio"] = {
"Piore River",
65043152,
"paa-sko",
aliases = {"Barupu Lagoon", -- Glottolog
"Lagoon", -- alternative name given by Wikipedia
},
}
m["paa-por"] = {
"Porapora", -- Foley includes Ambakich (which we, Glottolog, and Usher treat as Keram)
65044258,
"paa-ram",
aliases = {"Agoan", -- Glottolog
"Porapora River", -- Usher
"core Grass", -- alternative name given by Wikipedia
},
}
m["paa-ram"] = {
"Ramu",
3442808,
aliases = {"Ramu River"}, -- per Usher (2020)
}
m["paa-rsa"] = {
"Rasawa-Saponi", -- [[w:Rasawa-Saponi languages]] redirects to [[w:Lakes Plain languages]]
nil, -- Q9859418 is for the coresponding category, which exists in the Piedmontese Wikipedia (?!)
"paa-flp",
aliases = {"Rombak River"}, -- Usher
}
m["paa-rub"] = {
"Ruboni",
6875319,
"paa-lra",
aliases = {"Misegian", -- Wikipedia's name
"Mikarew", -- alternative name given by Wikipedia
"Ruboni Range"}, -- Usher
}
m["paa-saa"] = {
"Samarokena-Airoran",
96417699,
"paa-gkw",
aliases = {"Apauwar Coast"}, -- Usher
}
m["paa-sah"] = {
"Sahu",
nil,
"paa-nnh",
}
m["paa-sbo"] = {
"South Bougainville",
3217380,
}
m["paa-sen"] = {
"Sentani",
17044584,
-- no consensus on higher affiliations, if any
aliases = {"Sentanic", "Demta-Sentani", "Demta-Lake Sentani"}, -- Sentanic per Glottolog, Demta-Sentani per Wikipedia
}
m["paa-sep"] = {
"Sepik",
3508772,
}
m["paa-shi"] = {
"Serra Hills",
65043154,
"paa-sko",
}
m["paa-sko"] = {
"Sko",
953509,
aliases = {"Skou"},
}
m["paa-sng"] = {
"Senagi",
2066550,
}
m["paa-taa"] = {
"Taikat-Awyi", -- [[w:Taikat languages]] redirects to [[w:Border languages (New Guinea)]]; but Croatian Wikipedia has an entry
12643265,
"paa-bor",
aliases = {"Taikat", -- Foley
"Upper Tami River", -- Usher
},
}
m["paa-tam"] = {
"Tamolan",
7681634,
"paa-ram",
aliases = {"Guam River"}, -- Usher
}
m["paa-tap"] = {
"Timor-Alor-Pantar",
16590002,
}
m["paa-teb"] = {
"Teberan",
7692052,
-- Often grouped with Trans-New Guinea, but per Pawley-Hammarström (2018), it has "weaker or disputed claims to membership in TNG".
aliases = {"Dadibi-Folopa"},
}
m["paa-tir"] = {
"Tirio",
7809225,
"paa-ani",
aliases = {"Nuclear Lower Fly", -- Pawley-Hammarström ("Lower Fly" includes Abom)
"Nuclear Tirio", -- Glottolog ("Tirio" includes Abom)
"Lower Fly River", -- Usher (without Abom)
},
}
m["paa-tki"] = {
"Turama-Kikori",
7853680,
aliases = {"Turama-Kikorian", "Rumu-Omati River"},
}
m["paa-ton"] = {
"Tonda",
8581005,
"paa-yam",
aliases = {"West Morehead River"}, -- Usher
}
m["paa-too"] = {
"Tor-Orya",
16590099,
aliases = {"Orya-Tor"},
}
m["paa-tor"] = {
"Tor", -- [[w:Tor languages]] redirects to [[w:Orya–Tor languages]]
nil,
"paa-too",
}
m["paa-trr"] = {
"Torricelli",
1333831,
}
m["paa-tti"] = {
"Ternate-Tidore",
nil,
"paa-nnh",
}
m["paa-wal"] = {
"Walio",
16919872,
-- Often placed in Sepik (e.g. by Laycock and Z'graggen (1975)), but not by Foley (2018), and not accepted by Glottolog.
aliases = {"Walioic", -- Glottolog
"Central Leonhard Schultze River",
},
}
m["paa-wap"] = {
"Wapei", -- Glottolog includes Nabi/Nambi(-Metan) in Wapeic
65089115,
"paa-wpa",
aliases = {"Wapeic"}, -- Glottolog
}
m["paa-war"] = {
"Waris", -- [[w:Waris languages]] redirects to [[w:Border languages (New Guinea)]]; but Croatian Wikipedia has an entry
12645076,
"paa-bor",
aliases = {"Warisic", -- Glottolog
"Bapi River", -- Usher (without Manem or Senggi)
},
}
m["paa-wbh"] = {
"West Bird's Head",
5330530,
-- Kuwani is sometimes included; probably related to North Halmahera languages.
}
m["paa-wel"] = {
"Western Eleman",
nil,
"paa-ele",
aliases = {"West Eleman"},
}
m["paa-wig"] = {
"West Inland Gulf",
nil,
"paa-ing",
aliases = {"West Inland Gulf of Papua"}, -- Glottolog
}
m["paa-wke"] = {
"West Keram",
nil,
"paa-ker",
aliases = {"Koam", "Mongol-Langam", "Ulmapo"}, -- Koam used by Foley, Ulmapo used by Glottolog
}
m["paa-wko"] = {
"Wára-Kómnzo", -- since we split out Kómnzo as a separate language
11732474, -- for the Wara language
"paa-ton",
aliases = {"Anta-Komnzo-Wára-Wérè-Kémä", -- Glottolog's name
"Wára", "Wara", -- Wikipedia
},
}
m["paa-wlp"] = {
"West Lakes Plain", -- [[w:Tariku languages]] redirects to [[w:Lakes Plain languages]]
47007503, -- actually for "Tariku languages", which per Wikipedia covers Fayu, Kirikiri, Iau and Tause
"paa-lpl",
aliases = {"West Tariku", -- Glottolog
"West Lakes Plains"}, -- Usher, with Edopi/Iau
}
m["paa-wpa"] = {
"Wapei-Palei",
65043156,
"paa-trr",
}
m["paa-wpw"] = { -- paa-wpa already used by Wapei-Palei
"Western Pauwasi", -- 2 langs per Glottolog and Pawley-Hammarström; Usher also includes Namla-Tofanma and Usku
85815062,
aliases = {"West Pauwasi", -- Wikipedia, Usher
"Tebi-Towe", "Dubu-Towei"},
}
m["paa-yam"] = {
"Yam",
15062272,
aliases = {"Morehead and Upper Maro River",
"Morehead River", -- Usher
},
}
m["paa-yaq"] = {
"Yaqayic", -- [[w:Yaqai languages]] redirects to [[w:Marind–Yaqai languages]]
nil,
"paa-mby",
aliases = {"Yakhai-Warkay"}, -- Usher
}
m["paa-ysa"] = {
"Yawa-Saweru",
3217545,
aliases = {"Yawa", "Yawan", "Yapen"},
}
m["paa-yua"] = {
"Yuat",
8060096,
}
m["phi"] = {
"Philippine",
947858,
"poz",
}
m["phi-kal"] = {
"Kalamian",
3217466,
"phi",
aliases = {"Calamian"},
}
m["poz"] = {
"Malayo-Polynesian",
143158,
"map",
}
m["poz-aay"] = {
"Admiralty Islands",
2701306,
"poz-oce",
}
m["poz-bnn"] = {
"North Bornean",
1427907,
"poz",
}
m["poz-bre"] = {
"East Barito",
2701314,
"poz",
}
m["poz-brw"] = {
"West Barito",
2761679,
"poz",
}
m["poz-bss"] = {
"Bali-Sasak-Sumbawa",
3396043,
"poz-msa",
}
m["poz-btk"] = {
"Bungku-Tolaki",
3217381,
"poz-clb",
}
m["poz-cet"] = {
"Central-Eastern Malayo-Polynesian",
2269883,
"poz",
}
m["poz-clb"] = {
"Celebic",
1078041,
"poz",
}
m["poz-cln"] = {
"New Caledonian",
3091221,
"poz-ocs",
}
m["poz-cma"] = {
"Central Maluku",
3217479,
"poz-cet",
}
m["poz-hce"] = {
"Halmahera-Cenderawasih",
2526616,
"pqe",
}
m["poz-kal"] = {
"Kaili-Pamona",
3217465,
"poz-clb",
}
m["poz-lgx"] = {
"Lampungic",
49215,
"poz",
}
m["poz-mcm"] = {
"Malayo-Chamic",
nil,
"poz-msa",
}
m["poz-mic"] = {
"Micronesian",
420591,
"poz-occ",
}
m["poz-mly"] = {
"Malayic",
662628,
"poz-mcm",
}
m["poz-msa"] = {
"Malayo-Sumbawan",
1363818,
"poz",
}
m["poz-mun"] = {
"Muna-Buton",
3037924,
"poz-clb",
}
m["poz-nws"] = {
"Northwest Sumatran",
2071308,
"poz",
}
m["poz-occ"] = {
"Central-Eastern Oceanic",
2068435,
"poz-oce",
}
m["poz-oce"] = {
"Oceanic",
324457,
"pqe",
}
m["poz-ocs"] = {
"Southern Oceanic",
3039118,
"poz-occ",
}
m["poz-ocw"] = {
"Western Oceanic",
2701282,
"poz-oce",
}
m["poz-pcc"] = {
"Central Pacific",
3130237,
"poz-occ",
}
m["poz-pep"] = {
"Eastern Polynesian",
390979,
"poz-pnp",
}
m["poz-pnp"] = {
"Nuclear Polynesian",
743851,
"poz-pol",
}
m["poz-pol"] = {
"Polynesian",
390979,
"poz-pcc",
}
m["poz-san"] = {
"Sabahan",
3217517,
"poz-bnn",
}
m["poz-sbj"] = {
"Sama-Bajaw",
2160409,
"poz",
}
m["poz-slb"] = {
"Saluan-Banggai",
3217519,
"poz-clb",
}
m["poz-sls"] = {
"Southeast Solomonic",
3119671,
"poz-occ",
}
m["poz-ssw"] = {
"South Sulawesi",
2778190,
"poz",
}
m["poz-stm"] = {
"St. Matthias",
6484143,
"poz-oce",
aliases = {"St Matthias"},
}
m["poz-swa"] = {
"North Sarawak",
538569,
"poz-bnn",
aliases = {"North Sarawakan"},
}
m["poz-tem"] = {
"Temotu",
3075769,
"poz-oce",
}
m["poz-tim"] = {
"Timoric",
7806987,
"poz-cet",
}
m["poz-ton"] = {
"Tongic",
3397263,
"poz-pol",
}
m["poz-tot"] = {
"Tomini-Tolitoli",
3217541,
"poz-clb",
}
m["poz-vnc"] = {
"Central Vanuatu",
5061988,
"poz-ocs",
}
m["poz-vnn"] = {
"North Vanuatu",
85789650,
"poz-ocs",
}
m["poz-vns"] = {
"South Vanuatu",
3070173,
"poz-ocs",
}
m["poz-wot"] = {
"Wotu-Wolio",
1041317,
"poz-clb",
aliases = {"Island Kaili-Wolio"}, -- Glottolog
}
m["pqe"] = {
"Eastern Malayo-Polynesian",
2269883,
"poz-cet",
}
m["qfa-adc"] = {
"Central Great Andamanese",
nil,
"qfa-adm",
}
m["qfa-adm"] = {
"Great Andamanese",
3515103,
}
m["qfa-adn"] = {
"Northern Great Andamanese",
nil,
"qfa-adm",
}
m["qfa-ads"] = {
"Southern Great Andamanese",
nil,
"qfa-adm",
}
m["qfa-ain"] = {
"Ainuic",
50111972,
aliases = {"Ainu"},
}
m["qfa-bej"] = {
"Be-Jizhao",
nil,
"qfa-bet",
}
m["qfa-bet"] = {
"Be-Tai",
12627719,
"qfa-tak",
aliases = {"Tai-Be", "Daic-Beic", "Beic-Daic"},
}
m["qfa-buy"] = {
"Buyang",
1109927,
"qfa-kra",
}
m["qfa-cka"] = {
"Chukotko-Kamchatkan",
33255,
}
m["qfa-cre"] = {
"creole",
33289,
"crp",
}
m["qfa-ckn"] = {
"Chukotkan",
2606732,
"qfa-cka",
}
m["qfa-cnt"] = {
"contact",
133253514,
"qfa-not",
}
m["qfa-dis"] = {
-- Languages that are not unclassifiable (qfa-unc) but where there is no consensus on classification. Usually
-- this is because the languages are divergent and it's disputed whether they are isolates or distantly related
-- to other languages.
"disputed affiliation",
nil,
"qfa-not",
categoryName = "Languages of disputed affiliation",
}
m["qfa-dgn"] = {
"Dogon",
1234776,
"nic",
}
m["qfa-dny"] = {
"Dene-Yeniseian",
21103,
aliases = {"Dené-Yeniseian"},
}
m["qfa-hur"] = {
"Hurro-Urartian",
1144159,
}
m["qfa-iso"] = {
"isolate",
33648,
"qfa-not",
categoryName = "Language isolates",
}
m["qfa-jew"] = {
"Jewish",
615948,
"qfa-not",
}
m["qfa-kad"] = {
"Kadu", -- considered either Nilo-Saharan or independent/none
1720989,
}
m["qfa-kms"] = {
"Kam-Sui",
1023641,
"qfa-tak",
}
m["qfa-kor"] = {
"Koreanic",
11263525,
}
m["qfa-kra"] = {
"Kra",
1022087,
"qfa-tak",
}
m["qfa-lic"] = {
"Hlai",
1023648,
"qfa-tak",
aliases = {"Hlaic"},
}
m["qfa-mch"] = { -- used in both N and S America
"Macro-Chibchan",
3438062,
}
m["qfa-mix"] = {
"mixed",
33694,
"qfa-cnt",
}
m["qfa-not"] = {
"not a family",
nil,
"qfa-not",
}
m["qfa-onb"] = {
"Be",
nil,
"qfa-bej",
aliases = {"Ong-Be", "Beic"},
}
m["qfa-ong"] = {
"Ongan",
2090575,
aliases = {"Angan", "South Andamanese", "Jarawa-Onge"},
}
m["qfa-pid"] = {
"pidgin",
33831,
"crp",
}
m["qfa-sub"] = {
"substrate",
20730913,
"qfa-not",
}
m["qfa-tak"] = {
"Kra-Dai",
34171,
aliases = {"Tai-Kadai", "Kadai"},
}
m["qfa-tyn"] = {
"Tyrsenian",
1344038,
}
m["qfa-unc"] = {
-- This corresponds to languages normally called "unclassified", i.e. there is insufficient data or research to
-- classify them, whereas our [[:Category:Unclassified languages]] is just languages that no Wiktionary editor
-- has classified yet (the family code in the language data is missing).
"unclassifiable",
33956,
"qfa-not",
}
m["qfa-xgs"] = {
"Serbi-Mongolic",
108887939,
}
m["qfa-xgx"] = {
"Para-Mongolic",
107619002,
"qfa-xgs",
}
m["qfa-yen"] = {
"Yeniseian",
27639,
"qfa-dny",
aliases = {"Yeniseic", "Yenisei-Ostyak"},
}
m["qfa-yke"] = {
"Ketic",
nil,
"qfa-yen",
}
m["qfa-yko"] = {
"Kottic",
nil,
"qfa-yen",
}
m["qfa-yrn"] = {
"Arinic",
nil,
"qfa-yen",
}
m["qfa-ypm"] = {
"Pumpokolic",
nil,
"qfa-yen",
}
m["qfa-yuk"] = {
"Yukaghir",
34164,
aliases = {"Yukagir", "Jukagir"},
}
m["qwe"] = {
"Quechuan",
5218,
pseudo_families = "sai",
}
m["raj"] = {
"Rajasthani",
13196,
"inc-wes",
protoLanguage = "inc-ogu",
}
m["roa"] = {
"Romance",
19814,
"itc",
aliases = {"Romanic", "Latin", "Neolatin", "Neo-Latin"},
protoLanguage = "la",
}
m["roa-asl"] = {
"Asturleonese",
35390,
"roa-ibe",
protoLanguage = "roa-ole",
}
m["roa-cas"] = {
"Castilian",
71924,
"roa-ibe",
aliases = {"Castillian", "Castilic", "Castillic"},
protoLanguage = "osp",
}
m["roa-dal"] = {
"Dalmatian Romance",
97646077,
"roa-itd",
}
m["roa-eas"] = {
"Eastern Romance",
147576,
"roa",
}
m["roa-emr"] = {
"Emilian-Romagnol",
242648,
"roa-git",
}
m["roa-gap"] = {
"Galician-Portuguese",
9080204,
"roa-ibe",
aliases = {"Galician Romance", "Galaic-Portuguese"},
protoLanguage = "roa-opt",
}
m["roa-gar"] = {
"Gallo-Romance",
500394,
"roa-wes",
}
m["roa-itd"] = {
"Italo-Dalmatian",
3313381,
"roa-iwr",
aliases = {"Central Romance"}
}
m["roa-itr"] = {
"Italo-Romance",
3356483,
"roa-itd",
}
m["roa-iwr"] = {
"Italo-Western Romance",
112608,
"roa",
aliases = {"Italo-Western"},
}
m["roa-git"] = {
"Gallo-Italic",
516074,
"roa-gar",
aliases = {"Gallo-Italian", "Gallo-Cisalpine", "Cisalpine"},
}
m["roa-grh"] = {
"Gallo-Rhaetian",
97646466,
"roa-gar",
}
m["roa-ibe"] = {
"Ibero-Romance",
749533,
"roa-wes",
aliases = {"Iberian Romance", "West Ibero-Romance", "Western Ibero-Romance", "West Iberian Romance", "Western Iberian Romance"}
}
m["roa-nar"] = {
"Navarro-Aragonese",
133252927,
"roa-ibe",
protoLanguage = "roa-ona",
}
m["roa-oil"] = {
"Oïl",
37351,
"roa-grh",
aliases = {"langues d'oïl", "langue d'oïl", "Cisalpine"},
protoLanguage = "fro",
}
m["roa-ocr"] = {
"Occitano-Romance",
599958,
"roa-gar",
aliases = {"Gallo-Narbonnese", "East Iberian", "Eastern Iberian"},
}
m["roa-rhe"] = {
"Rhaeto-Romance",
515593,
"roa-grh",
aliases = {"langues d'oïl", "langue d'oïl", "Cisalpine"},
}
m["roa-sou"] = {
"Southern Romance",
145345,
"roa",
}
m["roa-wes"] = {
"Western Romance",
2714388,
"roa-iwr",
}
m["sai"] = {
"South American Indigenous",
54801970,
"qfa-not",
}
--[=[
Exceptional language and family codes for South American Indigenous/Indian languages
can use the prefix "sai-", though "sai" is not a proper family (only a pseudo-family).
]=]--
m["sai-ara"] = {
"Araucanian",
626630,
}
m["sai-aym"] = {
"Aymaran",
33010,
}
m["sai-bar"] = {
"Barbacoan",
807304,
aliases = {"Barbakoan"},
}
m["sai-bor"] = {
"Boran",
5371776,
}
m["sai-cah"] = {
"Cahuapanan",
1025793,
}
m["sai-car"] = {
"Cariban",
33090,
aliases = {"Carib"},
}
m["sai-cer"] = {
"Cerrado",
98078151,
"sai-jee",
aliases = {"Amazonian Jê"},
}
m["sai-chc"] = {
"Chocoan",
1075616,
aliases = {"Choco", "Chocó"},
}
m["sai-cho"] = {
"Chonan",
33019,
aliases = {"Chon"},
}
m["sai-cje"] = {
"Central Jê",
18010843,
"sai-cer",
aliases = {"Akuwẽ"},
}
m["sai-cpc"] = {
"Chapacuran",
1062626,
}
m["sai-crn"] = {
"Charruan",
3112423,
aliases = {"Charrúan"},
}
m["sai-ctc"] = {
"Catacaoan",
5051139,
}
m["sai-guc"] = {
"Guaicuruan",
1974973,
"sai-mgc",
aliases = {"Guaicurú", "Guaycuruana", "Guaikurú", "Guaycuruano", "Guaykuruan", "Waikurúan"},
}
m["sai-guh"] = {
"Guahiban",
944056,
aliases = {"Guahiboan", "Guajiboan", "Wahivoan"},
}
m["sai-gui"] = {
"Guianan",
nil,
"sai-car",
aliases = {"Guianan Carib", "Guiana Carib"},
}
m["sai-har"] = {
"Harákmbut",
1584402,
"sai-hkt",
aliases = {"Harákmbet"},
}
m["sai-hkt"] = {
"Harákmbut-Katukinan",
17107635,
}
m["sai-hrp"] = {
"Huarpean",
1578336,
aliases = {"Warpean", "Huarpe", "Warpe"},
}
m["sai-jee"] = {
"Jê",
1483594,
"sai-mje",
aliases = {"Gê", "Jean", "Gean", "Jê-Kaingang", "Ye"},
}
m["sai-jir"] = {
"Jirajaran",
3028651,
aliases = {"Hiraháran"},
}
m["sai-jiv"] = {
"Jivaroan",
1393074,
aliases = {"Hívaro", "Jibaro", "Jibaroan", "Jibaroana", "Jívaro"},
}
m["sai-ktk"] = {
"Katukinan",
2636000,
"sai-hkt",
aliases = {"Catuquinan"},
}
m["sai-kui"] = {
"Kuikuroan",
nil,
"sai-car",
aliases = {"Kuikuro", "Nahukwa"},
}
m["sai-map"] = {
"Mapoyan",
61096301,
"sai-ven",
aliases = {"Mapoyo", "Mapoyo-Yabarana", "Mapoyo-Yavarana", "Mapoyo-Yawarana"},
}
m["sai-mas"] = {
"Mascoian",
1906952,
aliases = {"Mascoyan", "Maskoian", "Enlhet-Enenlhet"},
}
m["sai-mgc"] = {
"Mataco-Guaicuru",
255512,
}
m["sai-mje"] = {
"Macro-Jê",
887133,
aliases = {"Macro-Gê"},
}
m["sai-mtc"] = {
"Matacoan",
2447424,
"sai-mgc",
}
m["sai-mur"] = {
"Muran",
33826,
aliases = {"Mura"},
}
m["sai-nad"] = {
"Nadahup",
1856439,
aliases = {"Makú", "Macú", "Vaupés-Japurá"},
}
m["sai-nje"] = {
"Northern Jê",
98078225,
"sai-cer",
aliases = {"Core Jê"},
}
m["sai-nmk"] = {
"Nambikwaran",
15548027,
aliases = {"Nambicuaran", "Nambiquaran", "Nambikuaran"},
}
m["sai-otm"] = {
"Otomacoan",
3217503,
aliases = {"Otomákoan", "Otomakoan"},
}
m["sai-pan"] = {
"Panoan",
1544537,
"sai-pat",
aliases = {"Pano"},
}
m["sai-pat"] = {
"Pano-Tacanan",
2475746,
aliases = {"Pano-Tacana", "Pano-Takana", "Páno-Takána", "Pano-Takánan"},
}
m["sai-pek"] = {
"Pekodian",
107451736,
"sai-car",
aliases = {"South Amazonian Carib", "Southern Cariban", "Pekodi"},
}
m["sai-pem"] = {
"Pemongan",
nil,
"sai-ven",
aliases = {"Pemong", "Pemóng", "Purukoto"},
}
m["sai-pey"] = {
"Peba-Yaguan",
174015,
aliases = {"Peba-Yagua", "Yaguan", "Peban", "Yáwan"},
}
m["sai-prk"] = {
"Parukotoan",
107451482,
"sai-car",
aliases = {"Parukoto"},
}
m["sai-sje"] = {
"Southern Jê",
98078245,
"sai-jee",
}
m["sai-tac"] = {
"Tacanan",
3113762,
"sai-pat",
}
m["sai-tar"] = {
"Taranoan",
105097814,
"sai-gui",
aliases = {"Trio", "Tarano"},
}
m["sai-tin"] = {
"Tiniguan",
2892258,
aliases = {"Tinigua"},
}
m["sai-tuc"] = {
"Tucanoan",
788144,
}
m["sai-tyu"] = {
"Ticuna-Yuri",
4467010,
}
m["sai-ucp"] = {
"Uru-Chipaya",
2475488,
aliases = {"Uru-Chipayan"},
}
m["sai-ven"] = {
"Venezuelan Cariban",
nil,
"sai-car",
aliases = {"Venezuelan Carib", "Venezuelan", "Venezuelano"},
}
m["sai-wic"] = {
"Wichí",
3027047,
}
m["sai-wit"] = {
"Witotoan",
43079317,
aliases = {"Huitotoan", "Uitotoan"},
}
m["sai-ynm"] = {
"Yanomami",
nil,
aliases = {"Yanomam", "Shamatari", "Yamomami", "Yanomaman"},
}
m["sai-yuk"] = {
"Yukpan",
nil,
"sai-car",
aliases = {"Yukpa", "Yukpano", "Yukpa-Japreria"},
}
m["sai-zam"] = {
"Zamucoan",
3048461,
aliases = {"Samúkoan"},
}
m["sai-zap"] = {
"Zaparoan",
33911,
aliases = {"Záparoan", "Saparoan", "Sáparoan", "Záparo", "Zaparoano", "Zaparoana"},
}
m["sal"] = {
"Salish",
33985,
pseudo_families = "nai",
}
m["sdv"] = {
"Eastern Sudanic",
2036148,
"ssa",
}
m["sdv-bri"] = {
"Bari",
nil,
"sdv-nie",
}
m["sdv-daj"] = {
"Daju",
956724,
"sdv",
}
m["sdv-dnu"] = {
"Dinka-Nuer",
nil,
"sdv-niw",
}
m["sdv-eje"] = {
"Eastern Jebel",
3408878,
"sdv",
}
m["sdv-kln"] = {
"Kalenjin",
637228,
"sdv-nis",
}
m["sdv-lma"] = {
"Lotuko-Maa",
nil,
"sdv-nie",
}
m["sdv-lon"] = {
"Northern Luo",
nil,
"sdv-luo",
}
m["sdv-los"] = {
"Southern Luo",
7570103,
"sdv-luo",
}
m["sdv-luo"] = {
"Luo",
nil,
"sdv-niw",
}
m["sdv-nes"] = {
"Northern Eastern Sudanic",
4810496,
"sdv",
aliases = {"Astaboran", "Ek Sudanic"},
}
m["sdv-nie"] = {
"Eastern Nilotic",
153795,
"sdv-nil",
}
m["sdv-nil"] = {
"Nilotic",
513408,
"sdv",
}
m["sdv-nis"] = {
"Southern Nilotic",
1552410,
"sdv-nil",
}
m["sdv-niw"] = {
"Western Nilotic",
3114989,
"sdv-nil",
}
m["sdv-nma"] = {
"Nandi-Markweta",
nil,
"sdv-kln",
}
m["sdv-nyi"] = {
"Nyima",
11688746,
"sdv-nes",
aliases = {"Nyimang"},
}
m["sdv-tmn"] = {
"Taman",
3408873,
"sdv-nes",
aliases = {"Tamaic"},
}
m["sdv-ttu"] = {
"Teso-Turkana",
7705551,
"sdv-nie",
aliases = {"Ateker"},
}
m["sel"] = {
"Selkup",
34008,
"syd",
}
m["sem"] = {
"Semitic",
34049,
"afa",
}
m["sem-ara"] = {
"Aramaic",
28602,
"sem-nwe",
protoLanguage = "arc",
}
m["sem-arb"] = {
"Arabic",
164667,
"sem-cen",
protoLanguage = "ar",
}
m["sem-are"] = {
"Eastern Aramaic",
3410322,
"sem-ara",
}
m["sem-arw"] = {
"Western Aramaic",
3394214,
"sem-ara",
}
m["sem-ase"] = {
"Southeastern Aramaic",
3410322,
"sem-are",
}
m["sem-can"] = {
"Canaanite",
747547,
"sem-nwe",
}
m["sem-cen"] = {
"Central Semitic",
3433228,
"sem-wes",
}
m["sem-cna"] = {
"Central Neo-Aramaic",
3410322,
"sem-are",
}
m["sem-eas"] = {
"East Semitic",
164273,
"sem",
}
m["sem-eth"] = {
"Ethiopian Semitic",
163629,
"sem-wes",
aliases = {"Afro-Semitic", "Ethiopian", "Ethiopic", "Ethiosemitic"},
}
m["sem-nna"] = {
"Northeastern Neo-Aramaic",
2560578,
"sem-are",
}
m["sem-nwe"] = {
"Northwest Semitic",
162996,
"sem-cen",
}
m["sem-osa"] = {
"Old South Arabian",
35025,
"sem-cen",
aliases = {"Epigraphic South Arabian", "Sayhadic"},
}
m["sem-sar"] = {
"Modern South Arabian",
1981908,
"sem-wes",
}
m["sem-wes"] = {
"West Semitic",
124901,
"sem",
}
m["sgn"] = {
"sign",
34228,
"qfa-not",
}
m["sgn-asl"] = {
"American Sign Languages",
nil,
"sgn-fsl",
}
m["sgn-fsl"] = {
"French Sign Languages",
5501921,
"sgn",
}
m["sgn-gsl"] = {
"German Sign Languages",
5551235,
"sgn",
}
m["sgn-jsl"] = {
"Japanese Sign Languages",
11722508,
"sgn",
}
m["sio"] = {
"Siouan",
34181,
"nai-sca",
}
m["sio-dhe"] = {
"Dhegihan",
3217420,
"sio-msv",
}
m["sio-dkt"] = {
"Dakotan",
4154122,
"sio-msv",
}
m["sio-mor"] = {
"Missouri River Siouan",
26807266,
"sio",
}
m["sio-msv"] = {
"Mississippi Valley Siouan",
12637104,
"sio",
}
m["sio-ohv"] = {
"Ohio Valley Siouan",
21070931,
"sio",
}
m["sit"] = {
"Sino-Tibetan",
45961,
aliases = {"Trans-Himalayan"},
}
m["sit-aao"] = {
"Central Naga",
615474,
"sit",
}
m["sit-alm"] = {
"Almora",
nil,
"sit-whm",
}
m["sit-bai"] = {
"Bai",
35103,
"sit-mba",
}
m["sit-bdi"] = {
"Bodish",
1814078,
"sit",
}
m["sit-cln"] = {
"Cai-Long",
107182612,
"sit-mba",
aliases = {"Ta-Li"},
}
m["sit-dhi"] = {
"Dhimalish",
1207648,
"sit",
}
m["sit-ebo"] = {
"East Bodish",
56402,
"sit-bdi",
}
m["sit-egy"] = {
"East rGyalrongic",
832026,
"sit-rgy",
}
m["sit-ers"] = {
"Ersuic",
56335,
"sit",
}
m["sit-gma"] = {
"Greater Magaric",
55612963,
"sit",
}
m["sit-gsi"] = {
"Greater Siangic",
52698851,
"sit",
}
m["sit-hrs"] = {
"Hrusish",
1632501,
"sit",
aliases = {"Southeast Kamengic"},
}
m["sit-jnp"] = {
"Jingphoic",
nil,
"sit-jpl",
aliases = {"Jingpho"},
}
m["sit-jpl"] = {
"Kachin-Luic",
1515454,
"tbq-bkj",
aliases = {"Jingpho-Luish", "Jingpho-Asakian", "Kachinic"},
}
m["sit-kch"] = {
"Konyak-Chang",
nil,
"sit-kon",
}
m["sit-kha"] = {
"Kham",
33305,
"sit-gma",
}
m["sit-khb"] = {
"Kho-Bwa",
6401917,
"sit",
aliases = {"Bugunish", "Kamengic"},
}
m["sit-khw"] = {
"Western Kho-Bwa",
nil,
"sit-khb",
}
m["sit-khc"] = {
"Chug-Lish",
nil,
"sit-khw",
aliases = {"Duhumbi-Khispi"},
}
m["sit-khm"] = {
"Mey-Sartang",
nil,
"sit-khw",
aliases = {"Sartang-Sherdukpen"},
}
m["sit-kic"] = {
"Central Kiranti",
nil,
"sit-kir",
}
m["sit-kie"] = {
"Eastern Kiranti",
nil,
"sit-kir",
}
m["sit-kin"] = {
"Kinnauric",
nil,
"sit-whm",
aliases = {"Kinnauri"},
}
m["sit-kir"] = {
"Kiranti",
922148,
"sit",
}
m["sit-kiw"] = {
"Western Kiranti",
922148,
"sit-kir",
}
m["sit-kon"] = {
"Northern Naga",
774590,
"tbq-bkj",
aliases = {"Konyakian", "Konyak"},
}
m["sit-kyk"] = {
"Kyirong-Kagate",
6450957,
"sit-tib",
}
m["sit-lab"] = {
"Ladakhi-Balti",
6450957,
"sit-tib",
}
m["sit-las"] = {
"Lahuli-Spiti",
6473510,
"sit-tib",
}
m["sit-luu"] = {
"Luish",
55621439,
"sit-jpl",
aliases = {"Asakian", "Sak"},
}
m["sit-mar"] = {
"Maringic",
nil,
"sit-tma",
}
m["sit-mba"] = {
"Macro-Bai",
16963847,
"sit-sba",
aliases = {"Greater Bai"},
}
m["sit-mdz"] = {
"Midzu",
6843504,
"sit",
aliases = {"Geman", "Midzuish", "Miju-Meyor", "Southern Mishmi"},
}
m["sit-mnz"] = {
"Mondzish",
6898839,
"tbq-lob",
aliases = {"Mangish"},
}
m["sit-mru"] = {
"Mruic",
16908870,
"sit",
aliases = {"Mru-Hkongso"},
}
m["sit-nas"] = {
"Naish",
25047956,
"sit-nax",
}
m["sit-nax"] = {
"Naic",
6982999,
"tbq-buq",
aliases = {"Naxish"},
}
m["sit-nba"] = {
"Northern Bai",
122463830,
"sit-bai",
}
m["sit-new"] = {
"Newaric",
55625069,
"sit",
}
m["sit-nng"] = {
"Nungish",
1515482,
"sit",
aliases = {"Nung"},
}
m["sit-qia"] = {
"Qiangic",
1636765,
"tbq-buq",
}
m["sit-rgy"] = {
"Rgyalrongic",
56936,
"sit-qia",
aliases = {"Jiarongic"},
}
m["sit-sba"] = {
"Sino-Bai",
nil,
"sit",
aliases = {"Greater Bai"},
}
m["sit-tam"] = {
"Tamangic",
3309439,
"sit",
aliases = {"West Bodish"},
}
m["sit-tan"] = {
"Tani",
3217538,
"sit",
}
m["sit-tib"] = {
"Tibetic",
1641150,
"sit-bdi",
protoLanguage = "otb",
}
m["sit-tja"] = {
"Tujia",
nil,
"sit",
}
m["sit-tma"] = {
"Tangkhul-Maring",
nil,
"sit",
}
m["sit-tng"] = {
"Tangkhulic",
1516657,
"sit-tma",
aliases = {"Tangkhul"},
}
m["sit-tno"] = {
"Tangsa-Nocte",
nil,
"sit-kon",
}
m["sit-tsk"] = {
"Tshangla",
nil,
"sit",
}
m["sit-wgy"] = {
"West rGyalrongic",
nil,
"sit-rgy"
}
m["sit-whm"] = {
"West Himalayish",
2301695,
"sit",
}
m["sit-zem"] = {
"Zeme",
189291,
"sit",
aliases = {"Zeliangrong", "Zemeic"},
}
m["sla"] = {
"Slavic",
23526,
"ine-bsl",
aliases = {"Slavonic"},
}
m["smi"] = {
"Sami",
56463,
"urj",
aliases = {"Saami", "Samic", "Saamic"},
}
m["son"] = {
"Songhay",
505198,
"ssa",
aliases = {"Songhai"},
}
m["sqj"] = {
"Albanian",
8748,
"ine",
}
m["ssa"] = {
"Nilo-Saharan", -- possibly not a genetic grouping
33705,
}
m["ssa-fur"] = {
"Fur",
2989512,
"ssa",
}
m["ssa-klk"] = {
"Kuliak",
1791476,
"ssa",
aliases = {"Rub"},
}
m["ssa-kom"] = {
"Koman",
1781084,
"ssa",
}
m["ssa-sah"] = {
"Saharan",
1757661,
"ssa",
}
m["syd"] = {
"Samoyedic",
34005,
"urj",
aliases = {"Samoyed", "Samodeic"},
}
m["syd-ene"] = {
"Enets",
29942,
"syd",
}
m["tai"] = {
"Tai",
749720,
"qfa-bet",
aliases = {"Daic"},
}
m["tai-wen"] = {
"Wenma-Southwestern Tai",
nil,
"tai",
}
m["tai-tay"] = {
"Tày",
nil,
"tai-wen",
}
m["tai-sap"] = {
"Sapa-Southwestern Tai",
nil,
"tai-wen",
aliases = {"Sapa-Thai"},
}
m["tai-swe"] = {
"Southwestern Tai",
10889250,
"tai-sap",
}
m["tai-cho"] = {
"Chongzuo Tai",
13216,
"tai",
}
m["tai-cen"] = {
"Central Tai",
5061891,
"tai",
}
m["tai-nor"] = {
"Northern Tai",
7059014,
"tai",
}
m["tbq"] = {
"Tibeto-Burman",
34064,
"sit",
}
m["tbq-anp"] = {
"Angami-Pochuri",
530460,
"sit",
}
m["tbq-axi"] = {
"Axioid",
nil,
"tbq-sel",
}
m["tbq-bdg"] = {
"Bodo-Garo",
4090000,
"tbq-bkj",
}
m["tbq-bis"] = {
"Bisoid",
48844742,
"tbq-slo",
}
m["tbq-bka"] = {
"Bi-Ka",
12627890,
"tbq-slo",
}
m["tbq-bkj"] = {
"Sal",
889900,
"sit",
-- Brahmaputran appears to be Glottolog's term
aliases = {"Bodo-Konyak-Jinghpaw", "Brahmaputran", "Jingpho-Konyak-Bodo"},
}
m["tbq-brm"] = {
"Burmish",
865713,
"tbq-lob",
}
m["tbq-buq"] = {
"Burmo-Qiangic",
16056278,
"sit",
aliases = {"Eastern Tibeto-Burman"},
}
m["tbq-drp"] = {
"Downriver Phula",
7188378,
"tbq-rph",
}
m["tbq-han"] = {
"Hanoid",
17004185,
"tbq-slo",
}
m["tbq-hph"] = {
"Highland Phula",
nil,
"tbq-sel",
}
m["tbq-jin"] = {
"Jino",
6202716,
"tbq-slo",
}
m["tbq-kzh"] = {
"Kazhuoish",
48834669,
"tbq-lol",
}
m["tbq-kuk"] = {
"Kuki-Chin",
832413,
"sit",
aliases = {"Kukish", "South-Central Tibeto-Burman"},
}
m["tbq-lal"] = {
"Lalo",
56548,
"tbq-lso",
}
m["tbq-lho"] = {
"Lahoish",
nil,
"tbq-lol",
}
m["tbq-llo"] = {
"Lipo-Lolopo",
nil,
"tbq-lso",
}
m["tbq-lob"] = {
"Lolo-Burmese",
1635712,
"tbq-buq",
}
m["tbq-lol"] = {
"Loloish",
37035,
"tbq-lob",
aliases = {"Yi", "Ngwi", "Nisoic"},
}
m["tbq-lso"] = {
"Lisoish",
6559055,
"tbq-lol",
}
m["tbq-lwo"] = {
"Lawoish",
48847673,
"tbq-lol",
}
m["tbq-muj"] = {
"Muji",
11221327,
"tbq-hph",
}
m["tbq-nas"] = {
"Nasoid",
nil,
"tbq-nlo",
}
m["tbq-nis"] = {
"Nisu",
56404,
"tbq-nlo",
}
m["tbq-nlo"] = {
"Northern Loloish",
7058676,
"tbq-nso",
}
m["tbq-nso"] = {
"Nisoish",
56990,
"tbq-lol",
}
m["tbq-nus"] = {
"Nusoish",
114245231,
"tbq-lol",
}
m["tbq-phw"] = {
"Phowa",
7187959,
"tbq-hph",
}
m["tbq-rph"] = {
"Riverine Phula",
nil,
"tbq-sel",
}
m["tbq-sel"] = {
"Southeastern Loloish",
16111894,
"tbq-nso",
}
m["tbq-sil"] = {
"Siloid",
60787071,
"tbq-slo",
}
m["tbq-slo"] = {
"Southern Loloish",
5649340,
"tbq-lol",
}
m["tbq-tal"] = {
"Taloid",
48804018,
"tbq-lso",
}
m["tbq-urp"] = {
"Upriver Phula",
7187058,
"tbq-rph",
}
m["trk"] = {
"Turkic",
34090,
}
m["trk-cmn"] = {
"Common Turkic",
1126028,
"trk",
aliases = {"Shaz Turkic", "Shaz-Turkic"},
}
m["trk-kar"] = {
"Karluk",
703173,
"trk-cmn",
aliases = {"Qarluq", "Uyghur-Uzbek", "Southeastern Turkic"},
}
m["trk-kbu"] = {
"Kipchak-Bulgar",
3512539,
"trk-kip",
aliases = {"Uralian", "Uralo-Caspian"},
}
m["trk-kcu"] = {
"Kipchak-Cuman",
4370412,
"trk-kip",
aliases = {"Ponto-Caspian"},
}
m["trk-kip"] = {
"Kipchak",
1339898,
"trk-cmn",
-- Russian Wikipedia article [[w:ru:Западнотюркские_языки]] says "Western Turkic" is used by N.A. Baskakov and includes Oghuz, Kipchak and Karluk.
-- Azerbaijani Wikipedia article [[w:az:Qərbi_türk_dilləri]] clarifies that "Western Turkic" is not a clade.
other_names = {"Western Turkic"},
aliases = {"Kypchak", "Qypchaq", "Northwestern Turkic"},
protoLanguage = "qwm",
}
m["trk-kkp"] = {
"Kyrgyz-Kipchak",
4221189,
"trk-kip",
}
m["trk-kno"] = {
"Kipchak-Nogai",
4326954,
"trk-kip",
aliases = {"Aralo-Caspian"},
}
m["trk-nsb"] = {
"North Siberian Turkic",
4537269,
"trk-sib",
aliases = {"Northern Siberian Turkic"},
}
m["trk-ogr"] = {
"Oghur",
1422731,
"trk",
aliases = {"Lir-Turkic", "r-Turkic"},
}
m["trk-ogz"] = {
"Oghuz",
494600,
"trk-cmn",
aliases = {"Southwestern Turkic"},
}
m["trk-sib"] = {
"Siberian Turkic",
354353,
"trk-cmn",
other_names = {"Northern Turkic"},
-- per [[w:ru:Восточнотюркские_языки]], "Eastern Turkic" is an alias for Siberian Turkic in the work of O.A. Mudrak,
-- but has a different non-clade meaning in the older work of N.A. Baskakov.
aliases = {"Eastern Turkic", "Northeastern Turkic"},
}
m["trk-ssb"] = {
"South Siberian Turkic",
nil,
"trk-sib",
aliases = {"Southern Siberian Turkic"},
}
m["tup"] = {
"Tupian",
34070,
aliases = {"Tupi"},
pseudo_families = "sai",
}
m["tup-gua"] = {
"Tupi-Guarani",
148610,
"tup",
aliases = {"Tupí-Guaraní"},
}
m["tuw"] = {
"Tungusic",
34230,
aliases = {"Manchu-Tungus", "Tungus"},
}
m["tuw-ewe"] = {
"Ewenic",
105889448,
"tuw",
aliases = {"Northern Tungusic"},
}
m["tuw-jrc"] = {
"Jurchenic",
105889432,
"tuw",
aliases = {"Manchuric"},
}
m["tuw-nan"] = {
"Nanaic",
105889264,
"tuw",
}
m["tuw-udg"] = {
"Udegheic",
105889266,
"tuw",
}
m["urj"] = {
"Uralic",
34113,
varieties = {"Finno-Ugric"},
}
m["urj-fin"] = {
"Finnic",
33328,
"urj",
aliases = {"Baltic-Finnic", "Balto-Finnic", "Fennic"},
}
m["urj-mdv"] = {
"Mordvinic",
627313,
"urj",
}
m["urj-prm"] = {
"Permic",
161493,
"urj",
}
m["urj-ugr"] = {
"Ugric",
156631,
"urj",
}
m["wak"] = {
"Wakashan",
60069,
pseudo_families = "nai",
}
m["wen"] = {
"Sorbian",
25442,
"zlw",
aliases = {"Lusatian", "Wendish"},
}
m["xgn"] = {
"Mongolic",
33750,
"qfa-xgs",
aliases = {"Mongolian"},
}
m["xgn-cen"] = {
"Central Mongolic",
28719447,
"xgn",
protoLanguage = "xng-lat",
}
m["xgn-sou"] = {
"Southern Mongolic",
nil,
"xgn",
protoLanguage = "xng-ear",
}
m["xgn-shr"] = {
"Shirongolic",
107539435,
"xgn-sou",
}
m["xme"] = {
"Median",
nil,
"ira-mpr",
protoLanguage = "xme-old",
}
m["xme-ttc"] = {
"Tatic",
nil,
"xme",
}
m["xnd"] = {
"Na-Dene",
26986,
"qfa-dny",
aliases = {"Na-Dené"},
pseudo_families = "nai",
}
m["xsc"] = {
"Scythian",
nil,
"ira-nei",
}
m["xsc-sak"] = {
"Saka",
nil,
"xsc-skw",
aliases = {"Sakan"},
}
m["xsc-sar"] = {
"Sarmatian",
nil,
"xsc",
}
m["xsc-skw"] = {
"Saka-Wakhi",
nil,
"xsc",
}
m["yok"] = {
"Yokuts",
34249,
"nai-you",
aliases = {"Yokutsan", "Mariposan", "Mariposa"},
}
m["ypk"] = {
"Yupik",
27970,
"esx-esk",
aliases = {"Yup'ik", "Yuit"},
}
m["yrk"] = {
"Nenets",
36452,
"syd",
}
m["zhx"] = {
"Sinitic",
33857,
"sit-sba",
aliases = {"Chinese"},
protoLanguage = "och",
}
m["zhx-com"] = {
"Coastal Min",
20667215,
"zhx-min",
}
m["zhx-inm"] = {
"Inland Min",
20667237,
"zhx-min",
}
m["zhx-man"] = {
"Mandarinic",
nil,
"zhx",
protoLanguage = "cmn-ear",
}
m["zhx-min"] = {
"Min",
56504,
"zhx",
}
m["zhx-nan"] = {
"Southern Min",
36495,
"zhx-com",
}
m["zhx-pin"] = {
"Pinghua",
2735715,
"zhx",
protoLanguage = "ltc",
}
m["zhx-yue"] = {
"Yue",
7033959,
"zhx",
protoLanguage = "ltc",
}
m["zle"] = {
"East Slavic",
144713,
"sla",
}
m["zls"] = {
"South Slavic",
146665,
"sla",
}
m["zlw"] = {
"West Slavic",
145852,
"sla",
}
m["zlw-lch"] = {
"Lechitic",
742782,
"zlw",
aliases = {"Lekhitic"},
}
m["zlw-pom"] = {
"Pomeranian",
nil,
"zlw-lch",
}
m["znd"] = {
"Zande",
8066072,
"nic-ubg",
}
return require("Module:languages").finalizeData(m, "family")
44lasaxndbabzsihcvtdja7fje1xoe3
Module:data/interwikis
828
8081
54912
2026-09-28T23:25:41Z
Deadend0914
7211
Gesceop tramet þe hafaþ 'local data = {} local gsub = string.gsub local next = next local ulower = require("Module:string utilities").lower for _, interwiki in next, mw.site.interwikiMap() do data[ulower((gsub(interwiki.prefix, "_", " ")))] = interwiki.isCurrentWiki and "current" or interwiki.isLocal and "local" or "external" end return data'
54912
Scribunto
text/plain
local data = {}
local gsub = string.gsub
local next = next
local ulower = require("Module:string utilities").lower
for _, interwiki in next, mw.site.interwikiMap() do
data[ulower((gsub(interwiki.prefix, "_", " ")))] =
interwiki.isCurrentWiki and "current" or
interwiki.isLocal and "local" or
"external"
end
return data
sj16ikp1xmfv7lsala0b7bnu9dlinm5
Module:floccnaman
828
8082
54916
2026-09-28T23:57:16Z
Deadend0914
7211
Gesceop tramet þe hafaþ '--[=[ Floccnaman (category names) for the Old English Wiktionary. Every category that a reader sees on an entry page is built as "<sprǣc> <word>" or "<sprǣc> <word> <word>", exactly like the categories that already exist by hand on this wiki ("Englisc nama", "Nīwenglisc fégung", "Eald Noren werlic nama"), so only the words need translating, never the word order. The modules that build such categories ([[Module:headword]], [[Module:headword utilities]]...'
54916
Scribunto
text/plain
--[=[
Floccnaman (category names) for the Old English Wiktionary.
Every category that a reader sees on an entry page is built as "<sprǣc> <word>" or
"<sprǣc> <word> <word>", exactly like the categories that already exist by hand on this wiki
("Englisc nama", "Nīwenglisc fégung", "Eald Noren werlic nama"), so only the words need
translating, never the word order.
The modules that build such categories ([[Module:headword]], [[Module:headword utilities]],
[[Module:form of]], [[Module:gender and number]], [[Module:affix]], [[Module:etymology]],
[[Module:etymology/specialized]], [[Module:ang-headword]]) ask this module for the Old English
wording first and keep the English wording if it is not here yet. Every missing wording is
tracked in [[Wiktionary:Tracking/flocc/untranslated/<wording>]], so the list of what still needs
to be added is always up to date:
[[Special:WhatLinksHere/Wiktionary:Tracking/flocc/untranslated]]
Words are entered without leading or trailing spaces, in the singular for parts of speech
("nama", not "naman"), because that is what the pre-existing categories use. The plural forms
used for the lemma categories are entered separately ("lemmas", "non-lemma forms", ...).
Only categories a reader sees on an entry page are translated here. Maintenance and tracking
categories (sortkeys, script codes, requests, pages with ...), the categories of the template
namespace and the ones produced by MediaWiki itself stay English on purpose.
]=]
local export = {}
--[=[
English wording -> Old English wording.
The words in this first group are already used by categories and template names that exist on
this wiki, so their spelling is established ("Flocc:Nama", "Flocc:Bīnaman", "Flocc:Nīwenglisc
fégung", "Bysen:Tōgeīecendlic-Tabule", "Cynn 1 strang forþgewiten dǣlnimend"), and the gender
words match the existing "Eald Noren werlic nama" style.
]=]
local words = {
-- Parts of speech.
["nouns"] = "nama",
["verbs"] = "word",
["adjectives"] = "tōgeīecendlic",
["adverbs"] = "bīword",
["conjunctions"] = "fégung",
["pronouns"] = "bīnaman",
["prepositions"] = "ēowigendlic",
["participles"] = "dǣlnimend",
["past participles"] = "forþgewiten dǣlnimend",
["present participles"] = "andweard dǣlnimend",
["masculine"] = "werlic",
["feminine"] = "wīflic",
["neuter"] = "nāhwæðer",
}
--[=[
Wording still to be translated. Anything listed here (or used in a module but not listed at
all) falls back to its English form and shows up in
[[Wiktionary:Tracking/flocc/untranslated]], so nothing breaks while the table is filled in.
Suggestions, commented out until checked against a source:
-- ["lemmas"] = "?", -- the lemma category, e.g. "Englisc ?"
-- ["non-lemma forms"] = "?", -- e.g. "Englisc ?"
-- ["variant lemmas"] = "?", -- alternative forms
-- ["variant non-lemma forms"] = "?",
-- ["proper nouns"] = "?", -- e.g. "syndrig nama"?
-- ["suffixes"] = "?", -- "Englisc ?"
-- ["prefixes"] = "?",
-- ["numerals"] = "?", -- cf. "Bysen:Getæl-Naman-Tabule"
-- ["interjections"] = "?",
-- ["particles"] = "?",
-- ["determiners"] = "?",
-- ["phrases"] = "?",
-- ["proverbs"] = "?",
-- ["abbreviations"] = "?",
-- ["initialisms"] = "?",
-- ["symbols"] = "?",
-- ["letters"] = "?",
-- ["countable nouns"] = "?",
-- ["uncountable nouns"] = "?",
-- ["compound words"] = "?",
-- ["terms inherited from "] = "?", -- etymology, e.g. "Nīwenglisc ? Englisce"
-- ["terms derived from "] = "?",
-- ["terms borrowed from "] = "?",
-- ["terms borrowed back into "] = "?",
-- ["learned borrowings"] = "?",
-- ["other languages"] = "?",
-- ["Translingual"] = "?",
-- ["taxonomic names"] = "?",
]=]
--[=[
Wording that carries a variable part, as a leading phrase. For example the affix templates
build categories such as "terms suffixed with -kas", where only the beginning is fixed; the
language name is prepended by the caller. Longest phrase first, so the most specific rule wins.
]=]
local prefixes = {
-- {"terms suffixed with ", "?"},
-- {"terms prefixed with ", "?"},
-- {"terms circumfixed with ", "?"},
-- {"terms infixed with ", "?"},
-- {"terms interfixed with ", "?"},
}
local function track(text)
local ok, track_module = pcall(require, "Module:debug/track")
if ok then
track_module("flocc/untranslated/" .. tostring(text))
end
end
--[==[
Return the Old English wording for one category name, or nil if it is not known yet. `lang` is
accepted so that a wording can later be made language-specific if that turns out to be needed.
]==]
function export.translate(lang, text)
if type(text) ~= "string" or text == "" then
return nil
end
if words[text] then
return words[text]
end
for _, rule in ipairs(prefixes) do
if text:sub(1, #rule[1]) == rule[1] then
return rule[2] .. text:sub(#rule[1] + 1)
end
end
track(text)
return nil
end
--[==[
Return the Old English wording for one category name, or the English wording unchanged if it is
not known yet. Use this in the modules that build categories: the language name is prepended by
the caller, so only the wording itself is passed in.
]==]
function export.get(lang, text)
return export.translate(lang, text) or text
end
-- The table is exposed for tests and maintenance scripts; use get() elsewhere.
export.words = words
return export
1n9fpnl2w348v8tuhblbul3ngapg3gy