Jump to content

Module:Labels

From Yezur Wiki
Revision as of 15:23, 18 July 2026 by Khurouan (talk | contribs) (Create: inline sense-label engine (backs {{lb}}))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation for Module:Labels, the sense-label renderer for the Yezur wiki's Dictionary. It is not called directly: Template:Lb invokes it as {{#invoke:Labels|lb|CODE|label1|label2|…}}, passing a language code and up to seven labels. The module returns those labels comma-joined, italicised and parenthesised, in the order given — {{lb|YAP-XX|by extension}} renders (by extension) at the head of a definition line — and appends a per-language category for each label it recognises. When no label survives trimming it returns nothing at all.

Parameters

Parameter Purpose
1 The language code, such as YBS-PJ. It is trimmed and matched without regard to case in Module:Languages, which supplies the display name used in the category titles; the code itself is never shown.
2, 3, … The labels, in display order. Each is trimmed, and empty values are skipped. Reading stops at the first argument that is absent altogether, which only affects direct invocation: Template:Lb always supplies slots 2 to 8, so unfilled slots between filled ones do no harm.

Categorising labels

A label in the table below files the page into a category named after the language, written Lang here: under YBS-PJ, transitive adds Category:Pjany transitive verbs. Recognition ignores case, but only a shorthand is rewritten — the shorthands in the second column are replaced by the canonical label before display, whereas a canonical label is shown exactly as typed, so Transitive renders (Transitive) and categorises all the same.

Label Shorthand Category
Verbs
transitive tr Lang transitive verbs
intransitive intr Lang intransitive verbs
ambitransitive Lang ambitransitive verbs
ditransitive ditr Lang ditransitive verbs
ergative Lang ergative verbs
reflexive Lang reflexive verbs
impersonal Lang impersonal verbs
copulative Lang copulative verbs
auxiliary Lang auxiliary verbs
modal Lang modal verbs
causative Lang causative verbs
deponent Lang deponent verbs
pronominal Lang pronominal verbs
reciprocal Lang reciprocal verbs
Nouns
countable count Lang countable nouns
uncountable uncount Lang uncountable nouns
collective Lang collective nouns
singular only Lang singular-only nouns
plural only Lang plural-only nouns
attributive Lang attributive terms
Adjectives
comparable Lang comparable adjectives
not comparable Lang uncomparable adjectives
predicative Lang predicative-only terms
Register and usage
slang Lang slang
colloquial colloq Lang colloquialisms
informal Lang informal terms
formal Lang formal terms
vulgar Lang vulgarities
derogatory derog Lang derogatory terms
offensive Lang offensive terms
slur Lang slurs
euphemistic euph Lang euphemisms
dysphemistic Lang dysphemisms
humorous hum Lang humorous terms
endearing Lang terms of endearment
familiar Lang familiar terms
childish Lang childish terms
honorific Lang honorifics
humble Lang humble terms
polite Lang polite terms
solemn Lang solemn terms
poetic Lang poetic terms
literary Lang literary terms
journalistic Lang journalistic terms
technical Lang technical terms
rustic Lang rustic terms
proscribed Lang proscribed terms
nonstandard Lang nonstandard terms
dialectal Lang dialectal terms
Temporal
archaic arch Lang archaic terms
dated Lang dated terms
obsolete obs Lang obsolete terms
historical Lang historical terms
rare Lang rare terms
uncommon Lang uncommon terms
neologism Lang neologisms
Word formation
abbreviation Lang abbreviations
acronym Lang acronyms
initialism Lang initialisms
contraction Lang contractions
onomatopoeia Lang onomatopoeias
misspelling Lang misspellings
eye dialect Lang eye dialect

One further shorthand, fig, expands to figurative, which is not a categorising label.

A label absent from the table is shown exactly as typed and adds no category, so domain tags such as nautical or botany and semantic qualifiers such as figurative or idiomatic work without any entry here. The categorising set is deliberately partial and is meant to grow as the category scheme is settled; it is curated from Wiktionary's label data, keeping the universal linguistic labels — valency, register, temporal, word formation — and leaving out the topical and regional domains.

Categories are added only when the code resolves in Module:Languages; an unknown or missing code still displays the labels, uncategorised. The module adds membership only — it does not create the category description pages, and most of the categories above are as yet empty.

For the division of labour between a per-sense label and the per-word register field of {{head}}, see Template:Lb.


-- Module:Labels — inline sense labels for Dictionary definitions, after the
-- fashion of Wiktionary's {{lb}}. Renders italic, parenthesised context /
-- register / domain labels immediately before a sense, and (for labels it
-- knows) files the page into a per-language maintenance category. Backs {{lb}}.
--
-- Any label not in the table below still displays, verbatim, with no category —
-- so figurative, by extension, and unlisted domains just work as plain text.
-- Keep the categorising set deliberately small; the category scheme is the
-- operator's to grow.

local Languages = require('Module:Languages')

local p = {}

-- label key (lower-cased) -> category suffix; {lang} is replaced by the
-- language's display name, e.g. "slang" -> "Pjany slang".
local CATS = {
	-- grammatical context
	["transitive"]   = "{lang} transitive verbs",
	["intransitive"] = "{lang} intransitive verbs",
	["ergative"]     = "{lang} ergative verbs",
	["reflexive"]    = "{lang} reflexive verbs",
	["impersonal"]   = "{lang} impersonal verbs",
	["ditransitive"] = "{lang} ditransitive verbs",
	["countable"]    = "{lang} countable nouns",
	["uncountable"]  = "{lang} uncountable nouns",
	-- register / usage
	["colloquial"]  = "{lang} colloquialisms",
	["informal"]    = "{lang} informal terms",
	["formal"]      = "{lang} formal terms",
	["slang"]       = "{lang} slang",
	["vulgar"]      = "{lang} vulgarities",
	["derogatory"]  = "{lang} derogatory terms",
	["offensive"]   = "{lang} offensive terms",
	["euphemistic"] = "{lang} euphemisms",
	["honorific"]   = "{lang} honorifics",
	["literary"]    = "{lang} literary terms",
	["poetic"]      = "{lang} poetic terms",
	["archaic"]     = "{lang} archaic terms",
	["obsolete"]    = "{lang} obsolete terms",
	["dated"]       = "{lang} dated terms",
	["historical"]  = "{lang} historical terms",
	["rare"]        = "{lang} rare terms",
	["nonstandard"] = "{lang} nonstandard terms",
	["dialectal"]   = "{lang} dialectal terms",
}

local function langname(code)
	local l = Languages._get(code)
	return (l and l.name) or ""
end

-- {{#invoke:Labels|lb|CODE|label1|label2|...}}
function p.lb(frame)
	local a = frame.args
	local lang = langname(a[1])
	local shown, cats = {}, {}
	local i = 2
	while a[i] ~= nil do
		local key = mw.text.trim(a[i])
		if key ~= "" then
			shown[#shown + 1] = key
			local suffix = CATS[key:lower()]
			if suffix and lang ~= "" then
				cats[#cats + 1] = "[[Category:" .. suffix:gsub("{lang}", lang) .. "]]"
			end
		end
		i = i + 1
	end
	if #shown == 0 then return "" end
	return "''(" .. table.concat(shown, ", ") .. ")''" .. table.concat(cats)
end

return p