12,303
edits
TheNightAvl (talk | contribs) m (Added slash split functionality) |
TheNightAvl (talk | contribs) No edit summary |
||
(14 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
local export = {} | local export = {} | ||
local m_labels = require("Module:labels") | |||
local m_links = require("Module:links") | local m_links = require("Module:links") | ||
local m_data = mw.loadData("Module:form of/data") | local m_data = mw.loadData("Module:form of/data") | ||
local function make_labels(inflections) | local function pluralize(word) | ||
local ending = mw.ustring.sub(word, -1) | |||
if ending == "h" and mw.ustring.sub(word, -2, -1) == "s" then ending = "sh" end | |||
if ending == "s" or ending == "z" or ending == "x" or ending == "sh" then | |||
return word .. "es" | |||
end | |||
return word .. "s" | |||
end | |||
local function make_labels(inflections, language) | |||
local out = {} | local out = {} | ||
if inflections[1] == nil then return "inflection" end | |||
-- split parameters at / and , | -- split parameters at / and , | ||
local it = 1 | |||
while inflections[it] do | while inflections[it] do | ||
if mw.ustring.find(inflections[it], "^[^,]+,%s.+") then | if mw.ustring.find(inflections[it], "^[^,]+,%s.+") then | ||
Line 31: | Line 44: | ||
local text = l.label or inflection | local text = l.label or inflection | ||
if l.glossary then | if l.glossary then | ||
glosslink = "[[Appendix:Glossary#" .. (type(l.glossary) == "string" and l.glossary or text) .. "|" .. text .. "]]" | |||
if text == "verbal noun" then | |||
glosslink = glosslink .. "[[Category:" .. language.name .. " verbal nouns|" .. mw.title.getCurrentTitle().subpageText .. "]]" | |||
end | |||
table.insert(out, glosslink) | |||
else | else | ||
table.insert(out, text) | table.insert(out, text) | ||
Line 48: | Line 65: | ||
local label | local label | ||
local link = m_links.full_link(data, "term") | local link = m_links.full_link(data, "term") | ||
local note = data.note | |||
if note then | |||
if mw.ustring.find(note, "^%P") then | |||
note = " " .. note | |||
end | |||
else | |||
note = "" | |||
end | |||
if data.inflection then | if data.inflection then | ||
label = make_labels(data.inflection) | label = make_labels(data.inflection, data.language) | ||
else | else | ||
label = data.form or "alternative form" | label = m_labels.make_labels(data.language, {[1] = data.form or "alternative form"}, data.nocat, true) | ||
end | end | ||
return '<span class="form-of">' .. label .. ' of ' .. link .. '</span>' | return '<span class="form-of">' .. label .. ((data.post and (" ".. data.post)) or "") .. ' of ' .. link .. note .. '</span>' | ||
end | end | ||
Line 59: | Line 84: | ||
local label | local label | ||
if data.inflection then | if data.inflection then | ||
label = make_labels(data.inflection) | label = make_labels(data.inflection, data.language) | ||
else | else | ||
label = data.form or "alternative form" | label = data.form or "alternative form" |