Module:form of: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:
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 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 function make_labels(inflections, language)
Line 37: Line 46:
glosslink = "[[Appendix:Glossary#" .. (type(l.glossary) == "string" and l.glossary or text) .. "|" .. text .. "]]"
glosslink = "[[Appendix:Glossary#" .. (type(l.glossary) == "string" and l.glossary or text) .. "|" .. text .. "]]"
if text == "verbal noun" then
if text == "verbal noun" then
glosslink = glosslink .. "[[Category:" .. language.name .. " verbal nouns]]"
glosslink = glosslink .. "[[Category:" .. language.name .. " verbal nouns|" .. mw.title.getCurrentTitle().subpageText .. "]]"
end
end
table.insert(out, glosslink)
table.insert(out, glosslink)
Line 56: 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, data.language)
label = make_labels(data.inflection, data.language)
Line 61: Line 78:
label = m_labels.make_labels(data.language, {[1] = data.form or "alternative form"}, data.nocat, true)
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