Module:form of: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
local m_links = require("Module:links") | local m_links = require("Module:links") | ||
local m_data = mw.loadData("Module:form of/data") | |||
local | |||
local function make_labels(inflections) | local function make_labels(inflections) | ||
local out = {} | local out = {} | ||
for _, inflection in ipairs(inflections) do | for _, inflection in ipairs(inflections) do | ||
if aliases[inflection] then inflection = aliases[inflection] end | if m_data.aliases[inflection] then inflection = m_data.aliases[inflection] end | ||
local l = labels[inflection] | local l = m_data.labels[inflection] | ||
if l then | if l then | ||
local text = l.label or inflection | local text = l.label or inflection |
Revision as of 15:08, 9 August 2023
local export = {}
local m_links = require("Module:links")
local m_data = mw.loadData("Module:form of/data")
local function make_labels(inflections)
local out = {}
for _, inflection in ipairs(inflections) do
if m_data.aliases[inflection] then inflection = m_data.aliases[inflection] end
local l = m_data.labels[inflection]
if l then
local text = l.label or inflection
if l.glossary then
table.insert(out, "[[Appendix:Glossary#" .. (type(l.glossary) == "string" and l.glossary or text) .. "|" .. text .. "]]")
else
table.insert(out, text)
end
else
table.insert(out, inflection)
end
end
return table.concat(out, " ")
end
function export.make_form_of(data)
local label
local link = m_links.full_link(data, "term")
if data.inflection then
label = make_labels(data.inflection)
else
label = data.form or "alternative form"
end
return '<span class="form-of">' .. label .. ' of ' .. link .. '</span>'
end
return export