Module:Languages: Difference between revisions
Rename YAQ-HE -> Ancient Hertic (distinct from Modern Hertic) |
Worked example now matches the table it documents (flag 36) |
||
| Line 31: | Line 31: | ||
end | end | ||
-- {{#invoke:Languages|name|YAQ-HE}} → Hertic | -- {{#invoke:Languages|name|YAQ-HE}} → Ancient Hertic | ||
function p.name(frame) | function p.name(frame) | ||
local l = p._get(frame.args[1]) | local l = p._get(frame.args[1]) | ||
Revision as of 20:18, 28 July 2026
This is the documentation for Module:Languages, the language-code registry for the Yezur wiki. It maps a registry code — the code field of Template:Infobox language — onto a language's display name, its Dictionary section, its family and whether it is reconstructed, and it is the single place those are recorded. Wikitext reaches it through {{#invoke:Languages|…}}, in Template:D, Template:L, Template:M, Template:Desc, Template:Head and Template:Etym-missing; Module:Head, Module:Labels and Module:Translations require the module and reach entries through its exported _get, the registry table itself being local to the module.
Codes take the form Y, a family letter, an era letter, a hyphen and a two-letter tag for the language, as in YAQ-HE for Ancient Hertic. The second letter is the family — A Herta-Olaic, B Njeshan, C Andusian, D Tacchoan, E Shung-Worrehan (no code registered under it yet), X isolate — and the third the era, P proto, Q ancient, R medieval, S modern, so that alphabetical order of codes is chronological order of languages. Module:Translations reads those two letters off the code itself to order its rows: families fall in letter order, isolates last, and within a family the older stages first.
Registry fields
Each entry in the table is keyed by its code and carries:
| Field | Purpose |
|---|---|
name |
The display name. Shown by Template:Desc and as the row label of a translations box, stored in the langname field of the Lexemes row by Template:Head, and used by Module:Head, Module:Labels and Template:Etym-missing to build category names such as Category:Pjany lemmas and Category:Gaillean entries needing etymology.
|
section |
The level-2 heading the language's entries file under in the Dictionary, and so the anchor every generated link points at. It differs from name where two forms of one language share a section: YXS-NE New English files under English.
|
recon |
Set to true for a reconstructed language. Its forms are rendered with a leading * in headwords, links and mentions; the page title itself carries no asterisk.
|
family |
The macro-family, used by Module:Translations to group a translations box. Isolates carry no family and are gathered under Isolates at the end of the box.
|
Entry points
| Call | Backs | Result |
|---|---|---|
{{#invoke:Languages|name|CODE}} |
Template:Head, Template:Etym-missing | The display name. |
{{#invoke:Languages|section|CODE}} |
— | The Dictionary section heading. |
{{#invoke:Languages|dlink|word|code|label}} |
Template:D | A link to Dictionary:word anchored at the language's section. Word first.
|
{{#invoke:Languages|link|code|word|label}} |
Template:L | The same link, code first, for lists of synonyms and derived terms. |
{{#invoke:Languages|mention|code|word|label}} |
Template:M | The same link italicised, for mentions in running prose. |
{{#invoke:Languages|desc|code|word|label}} |
Template:Desc | The display name, a colon, then the link — a Descendants-section line. |
The last parameter of the four link-building calls is optional display text, defaulting to the word; a parameter left blank counts as absent. Codes and words are trimmed, and codes are matched without regard to case. Given no word, dlink, link and mention return an empty string and desc returns the display name alone.
An unrecognised or omitted code is not an error. name and section return an empty string, desc falls back to printing the code itself as the name, and the link calls still emit a link — to the top of the Dictionary page, with no section anchor and no reconstruction asterisk. Template:Translations is the exception: it renders unknown codes visibly as errors rather than passing them through.
Two functions are exported for other modules rather than for wikitext. _get(code) returns the registry entry for a code, or nil; _build_link(word, entry, display) builds the anchored, starred Dictionary link from an entry.
Because the display names live here, renaming a language is a one-line edit to the registry rather than a sweep of every page that mentions it. The table has to be kept in step with the code fields of Template:Infobox language and with the tables at List of languages, which catalogue the codes in use; a language absent from the registry is invisible to the dictionary templates, which fall back to unanchored links. See Yezur Wiki:Dictionary structure.
-- Module:Languages — the wiki's language-code registry.
-- Single source of truth mapping registry codes (the `code` field of
-- Template:Infobox language; the prefix encodes the family) to display data
-- for the dictionary templates ({{D}}, {{head}}, {{l}}, {{m}}).
-- `section` is the level-2 heading a Dictionary entry files under — New
-- English shares the English section (the two are forms of one language,
-- not separate languages). `recon = true` marks a reconstructed (proto)
-- language: its forms are mentioned with a leading * (the page title omits it).
-- Keep this table in step with the Languages Cargo table.
local languages = {
["YAQ-GA"] = { name = "Gaillean", section = "Gaillean" },
["YAQ-HE"] = { name = "Ancient Hertic", section = "Ancient Hertic" },
["YAP-XX"] = { name = "Proto-Herta-Olaic", section = "Proto-Herta-Olaic", recon = true },
["YBS-LO"] = { name = "Lonish", section = "Lonish" },
["YBS-NI"] = { name = "Nichana", section = "Nichana" },
["YBS-PJ"] = { name = "Pjany", section = "Pjany" },
["YBS-UU"] = { name = "Uu", section = "Uu" },
["YBP-XX"] = { name = "Proto-Njeshan", section = "Proto-Njeshan", recon = true },
["YXS-EN"] = { name = "English", section = "English" },
["YXS-NE"] = { name = "New English", section = "English" },
}
local p = {}
function p._get(code)
if not code then return nil end
code = mw.text.trim(code)
if code == "" then return nil end
return languages[code:upper()]
end
-- {{#invoke:Languages|name|YAQ-HE}} → Ancient Hertic
function p.name(frame)
local l = p._get(frame.args[1])
return l and l.name or ""
end
-- {{#invoke:Languages|section|YXS-NE}} → English
function p.section(frame)
local l = p._get(frame.args[1])
return l and l.section or ""
end
-- Link to a word's Dictionary section; prefixes * for reconstructed languages.
local function build_link(word, l, disp)
local target = "Dictionary:" .. word
if l then target = target .. "#" .. l.section end
local star = (l and l.recon) and "*" or ""
return "[[" .. target .. "|" .. star .. (disp or word) .. "]]"
end
-- {{#invoke:Languages|dlink|word|code|label}} — a link to a Dictionary
-- entry, anchored to the language's section when the code is known. Backs {{D}}.
-- (Note the word-first argument order, unlike {{l}}/{{m}}.)
function p.dlink(frame)
local word = mw.text.trim(frame.args[1] or "")
if word == "" then return "" end
local label = frame.args[3]
if label ~= nil and mw.text.trim(label) == "" then label = nil end
return build_link(word, p._get(frame.args[2]), label)
end
-- {{#invoke:Languages|link|code|word|label}} — a plain link, for lists
-- (synonyms, derived terms). Backs {{l}}. Code-first, Wiktionary-style.
function p.link(frame)
local word = mw.text.trim(frame.args[2] or "")
if word == "" then return "" end
local disp = frame.args[3]
if disp ~= nil and mw.text.trim(disp) == "" then disp = nil end
return build_link(word, p._get(frame.args[1]), disp)
end
-- {{#invoke:Languages|mention|code|word|label}} — an italic mention, for
-- running prose (etymologies). Backs {{m}}. Code-first.
function p.mention(frame)
local word = mw.text.trim(frame.args[2] or "")
if word == "" then return "" end
local disp = frame.args[3]
if disp ~= nil and mw.text.trim(disp) == "" then disp = nil end
return "''" .. build_link(word, p._get(frame.args[1]), disp) .. "''"
end
return p