Jump to content

Module:Languages: Difference between revisions

From Yezur Wiki
Khurouan (talk | contribs)
Register YAP-XX (Proto-Herta-Olaic, reconstructed)
Thiorosan (talk | contribs)
Register YCQ-BE Besoh — the first attested Andusian language
 
(7 intermediate revisions by 3 users not shown)
Line 7: Line 7:
-- not separate languages). `recon = true` marks a reconstructed (proto)
-- not separate languages). `recon = true` marks a reconstructed (proto)
-- language: its forms are mentioned with a leading * (the page title omits it).
-- language: its forms are mentioned with a leading * (the page title omits it).
-- Keep this table in step with the Languages Cargo table.
-- `family` = the macro-family the language belongs to (used by
-- Template:Translations for grouping); isolates carry no family.
-- Keep this table in step with the `code` fields of {{Infobox language}}
-- and the [[List of languages]] tables.


local languages = {
local languages = {
["YAQ-GA"] = { name = "Gaillean",    section = "Gaillean" },
-- Herta-Olaic
["YAQ-HE"] = { name = "Hertic",     section = "Hertic" },
["YAQ-GA"] = { name = "Gaillean",    section = "Gaillean", family = "Herta-Olaic" },
["YAP-XX"] = { name = "Proto-Herta-Olaic", section = "Proto-Herta-Olaic", recon = true },
["YAQ-HE"] = { name = "Ancient Hertic", section = "Ancient Hertic", family = "Herta-Olaic" },
["YBS-LO"] = { name = "Lonish",      section = "Lonish" },
["YAQ-SK"] = { name = "Skennic",    section = "Skennic", family = "Herta-Olaic" },
["YBS-NI"] = { name = "Nichana",    section = "Nichana" },
["YAR-AI"] = { name = "Middle Airananwe", section = "Middle Airananwe", family = "Herta-Olaic" },
["YBS-PJ"] = { name = "Pjany",      section = "Pjany" },
["YAR-GW"] = { name = "High Gaillean", section = "High Gaillean", family = "Herta-Olaic" },
["YBS-UU"] = { name = "Uu",          section = "Uu" },
["YAS-AI"] = { name = "Airananwe",  section = "Airananwe", family = "Herta-Olaic" },
["YBP-XX"] = { name = "Proto-Njeshan", section = "Proto-Njeshan", recon = true },
["YAP-XX"] = { name = "Proto-Herta-Olaic", section = "Proto-Herta-Olaic", recon = true, family = "Herta-Olaic" },
-- Njeshan
["YBR-HN"] = { name = "High Nichana", section = "High Nichana", family = "Njeshan" },
["YBR-OT"] = { name = "Otjesi",      section = "Otjesi", family = "Njeshan" },
["YBR-PI"] = { name = "Pises",      section = "Pises", family = "Njeshan" },
["YBS-AL"] = { name = "Anilonic",    section = "Anilonic", family = "Njeshan" },
["YBS-LO"] = { name = "Lonish",      section = "Lonish", family = "Njeshan" },
["YBS-NI"] = { name = "Nichana",    section = "Nichana", family = "Njeshan" },
["YBS-PJ"] = { name = "Pjany",      section = "Pjany", family = "Njeshan" },
["YBS-UU"] = { name = "Uu",          section = "Uu", family = "Njeshan" },
["YBP-XX"] = { name = "Proto-Njeshan", section = "Proto-Njeshan", recon = true, family = "Njeshan" },
-- Andusian
["YCP-XX"] = { name = "Proto-Andusian", section = "Proto-Andusian", recon = true, family = "Andusian" },
["YCP-XA"] = { name = "Proto-North-Andusian", section = "Proto-North-Andusian", recon = true, family = "Andusian" },
["YCP-XB"] = { name = "Proto-South-Andusian", section = "Proto-South-Andusian", recon = true, family = "Andusian" },
["YCP-XC"] = { name = "Proto-Unterian", section = "Proto-Unterian", recon = true, family = "Andusian" },
["YCQ-BE"] = { name = "Besoh", section = "Besoh", family = "Andusian" },
-- Tacchoan
["YDQ-ES"] = { name = "Esselitian",  section = "Esselitian", family = "Tacchoan" },
["YDQ-PY"] = { name = "Old Ousperian", section = "Old Ousperian", family = "Tacchoan" },
["YDR-KK"] = { name = "Kankai",      section = "Kankai", family = "Tacchoan" },
["YDR-TZ"] = { name = "Terjiquan",  section = "Terjiquan", family = "Tacchoan" },
["YDR-YS"] = { name = "Old Usinger", section = "Old Usinger", family = "Tacchoan" },
["YDS-SE"] = { name = "Senitian",    section = "Senitian", family = "Tacchoan" },
["YDS-YS"] = { name = "Usinger",    section = "Usinger", family = "Tacchoan" },
-- Isolates
["YXS-EN"] = { name = "English",    section = "English" },
["YXS-EN"] = { name = "English",    section = "English" },
["YXS-NE"] = { name = "New English", section = "English" },
["YXS-NE"] = { name = "New English", section = "English" },
Line 31: Line 59:
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])
Line 44: Line 72:


-- Link to a word's Dictionary section; prefixes * for reconstructed languages.
-- Link to a word's Dictionary section; prefixes * for reconstructed languages.
local function build_link(word, l, disp)
-- Exported for other modules (e.g. Module:Translations).
function p._build_link(word, l, disp)
local target = "Dictionary:" .. word
local target = "Dictionary:" .. word
if l then target = target .. "#" .. l.section end
if l then target = target .. "#" .. l.section end
Line 59: Line 88:
local label = frame.args[3]
local label = frame.args[3]
if label ~= nil and mw.text.trim(label) == "" then label = nil end
if label ~= nil and mw.text.trim(label) == "" then label = nil end
return build_link(word, p._get(frame.args[2]), label)
return p._build_link(word, p._get(frame.args[2]), label)
end
end


Line 69: Line 98:
local disp = frame.args[3]
local disp = frame.args[3]
if disp ~= nil and mw.text.trim(disp) == "" then disp = nil end
if disp ~= nil and mw.text.trim(disp) == "" then disp = nil end
return build_link(word, p._get(frame.args[1]), disp)
return p._build_link(word, p._get(frame.args[1]), disp)
end
end


Line 79: Line 108:
local disp = frame.args[3]
local disp = frame.args[3]
if disp ~= nil and mw.text.trim(disp) == "" then disp = nil end
if disp ~= nil and mw.text.trim(disp) == "" then disp = nil end
return "''" .. build_link(word, p._get(frame.args[1]), disp) .. "''"
return "''" .. p._build_link(word, p._get(frame.args[1]), disp) .. "''"
end
 
-- {{#invoke:Languages|desc|code|word|label}} — a Descendants line: the
-- language's display name (resolved here, so renaming a language is a
-- one-line edit to this registry) followed by a link to the word. Backs
-- Template:Desc.
function p.desc(frame)
local l = p._get(frame.args[1])
local name = l and l.name or (frame.args[1] or "")
local word = mw.text.trim(frame.args[2] or "")
if word == "" then return name end
local label = frame.args[3]
if label ~= nil and mw.text.trim(label) == "" then label = nil end
return name .. ": " .. p._build_link(word, l, label)
end
end


return p
return p

Latest revision as of 08:17, 6 August 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).
-- `family` = the macro-family the language belongs to (used by
-- Template:Translations for grouping); isolates carry no family.
-- Keep this table in step with the `code` fields of {{Infobox language}}
-- and the [[List of languages]] tables.

local languages = {
	-- Herta-Olaic
	["YAQ-GA"] = { name = "Gaillean",    section = "Gaillean", family = "Herta-Olaic" },
	["YAQ-HE"] = { name = "Ancient Hertic", section = "Ancient Hertic", family = "Herta-Olaic" },
	["YAQ-SK"] = { name = "Skennic",     section = "Skennic", family = "Herta-Olaic" },
	["YAR-AI"] = { name = "Middle Airananwe", section = "Middle Airananwe", family = "Herta-Olaic" },
	["YAR-GW"] = { name = "High Gaillean", section = "High Gaillean", family = "Herta-Olaic" },
	["YAS-AI"] = { name = "Airananwe",   section = "Airananwe", family = "Herta-Olaic" },
	["YAP-XX"] = { name = "Proto-Herta-Olaic", section = "Proto-Herta-Olaic", recon = true, family = "Herta-Olaic" },
	-- Njeshan
	["YBR-HN"] = { name = "High Nichana", section = "High Nichana", family = "Njeshan" },
	["YBR-OT"] = { name = "Otjesi",      section = "Otjesi", family = "Njeshan" },
	["YBR-PI"] = { name = "Pises",       section = "Pises", family = "Njeshan" },
	["YBS-AL"] = { name = "Anilonic",    section = "Anilonic", family = "Njeshan" },
	["YBS-LO"] = { name = "Lonish",      section = "Lonish", family = "Njeshan" },
	["YBS-NI"] = { name = "Nichana",     section = "Nichana", family = "Njeshan" },
	["YBS-PJ"] = { name = "Pjany",       section = "Pjany", family = "Njeshan" },
	["YBS-UU"] = { name = "Uu",          section = "Uu", family = "Njeshan" },
	["YBP-XX"] = { name = "Proto-Njeshan", section = "Proto-Njeshan", recon = true, family = "Njeshan" },
	-- Andusian
	["YCP-XX"] = { name = "Proto-Andusian", section = "Proto-Andusian", recon = true, family = "Andusian" },
	["YCP-XA"] = { name = "Proto-North-Andusian", section = "Proto-North-Andusian", recon = true, family = "Andusian" },
	["YCP-XB"] = { name = "Proto-South-Andusian", section = "Proto-South-Andusian", recon = true, family = "Andusian" },
	["YCP-XC"] = { name = "Proto-Unterian", section = "Proto-Unterian", recon = true, family = "Andusian" },
	["YCQ-BE"] = { name = "Besoh", section = "Besoh", family = "Andusian" },
	-- Tacchoan
	["YDQ-ES"] = { name = "Esselitian",  section = "Esselitian", family = "Tacchoan" },
	["YDQ-PY"] = { name = "Old Ousperian", section = "Old Ousperian", family = "Tacchoan" },
	["YDR-KK"] = { name = "Kankai",      section = "Kankai", family = "Tacchoan" },
	["YDR-TZ"] = { name = "Terjiquan",   section = "Terjiquan", family = "Tacchoan" },
	["YDR-YS"] = { name = "Old Usinger", section = "Old Usinger", family = "Tacchoan" },
	["YDS-SE"] = { name = "Senitian",    section = "Senitian", family = "Tacchoan" },
	["YDS-YS"] = { name = "Usinger",     section = "Usinger", family = "Tacchoan" },
	-- Isolates
	["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.
-- Exported for other modules (e.g. Module:Translations).
function p._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 p._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 p._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 "''" .. p._build_link(word, p._get(frame.args[1]), disp) .. "''"
end

-- {{#invoke:Languages|desc|code|word|label}} — a Descendants line: the
-- language's display name (resolved here, so renaming a language is a
-- one-line edit to this registry) followed by a link to the word. Backs
-- Template:Desc.
function p.desc(frame)
	local l = p._get(frame.args[1])
	local name = l and l.name or (frame.args[1] or "")
	local word = mw.text.trim(frame.args[2] or "")
	if word == "" then return name end
	local label = frame.args[3]
	if label ~= nil and mw.text.trim(label) == "" then label = nil end
	return name .. ": " .. p._build_link(word, l, label)
end

return p