Module:etymology: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 60: Line 60:
     ["back-formation"] = {
     ["back-formation"] = {
         text = true,
         text = true,
        preposition = "from",
         categories = {"back-formations"}
         categories = {"back-formations"}
     },
     },
Line 68: Line 69:
     ["deadjectival"] = {
     ["deadjectival"] = {
     text = true,
     text = true,
    preposition = "from",
     categories = {"deadjectivals"},
     categories = {"deadjectivals"},
     },
     },
     ["denominal"] = {
     ["denominal"] = {
text = true,
text = true,
preposition = "from",
categories = {"denominals"},
categories = {"denominals"},
     },
     },
     ["deverbal"] = {
     ["deverbal"] = {
     text = true,
     text = true,
    preposition = "from",
     categories = {"deverbals"},
     categories = {"deverbals"},
     },
     },
Line 197: Line 201:
end
end


local function format_prefixed_text(label, text_data, nocap_arg)
local function format_prefixed_text(label, text_data, nocap_arg, preposition)
     if not text_data then return "" end
     if not text_data then return "" end
     if type(text_data) == "function" then return text_data(nocap_arg) end
     if type(text_data) == "function" then return text_data(nocap_arg) end
    local prep = "of"
     return "[[Appendix:Glossary#" .. label .. "|" .. (nocap_arg and label or mw.ustring.gsub(label, "^%l", string.upper)) .. "]] " .. (preposition or "of") .. " "
    if label == "back-formation" then prep = "from" end
     return "[[Appendix:Glossary#" .. label .. "|" .. (nocap_arg and label or mw.ustring.gsub(label, "^%l", string.upper)) .. "]] " .. prep .. " "
end
end


Line 237: Line 239:
     local out, categories = "", {}
     local out, categories = "", {}
     local language = m_languages.get_by_code(args[1])
     local language = m_languages.get_by_code(args[1])
     if not args["notext"] then out = out .. format_prefixed_text(template, data["text"], args["nocap"]) end
     if not args["notext"] then out = out .. format_prefixed_text(template, data["text"], args["nocap"], data["preposition"]) end
     out = out .. m_links.full_link({
     out = out .. m_links.full_link({
         term = args[2],
         term = args[2],
Line 255: Line 257:
     local language_to = m_languages.get_by_code(args[1])
     local language_to = m_languages.get_by_code(args[1])
     local language_from = m_languages.get_by_code(args[2])
     local language_from = m_languages.get_by_code(args[2])
     if (not args["notext"]) and (not data["silent"]) then out = out .. format_prefixed_text(template, data["text"], args["nocap"]) end
     if (not args["notext"]) and (not data["silent"]) then out = out .. format_prefixed_text(template, data["text"], args["nocap"], data["preposition"]) end
     out = out .. m_links.full_link({
     out = out .. m_links.full_link({
         term = args[3],
         term = args[3],
Line 313: Line 315:
     local out = table.concat(pre_out, " + ")
     local out = table.concat(pre_out, " + ")
     if not args["notext"] then
     if not args["notext"] then
         out = format_prefixed_text(template, data["text"], args["nocap"]) .. out
         out = format_prefixed_text(template, data["text"], args["nocap"], data["preposition"]) .. out
     end
     end
     return format_etymology(out, categories)
     return format_etymology(out, categories)

Navigation menu