Module:etymology: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 5: Line 5:
local m_links = require("Module:links")
local m_links = require("Module:links")
local m_parameters = require("Module:parameters")
local m_parameters = require("Module:parameters")
local new_pos_data = {
["adjective"] = {
categories = {"adjectivisations"},
},
["noun"] = {
categories = {"nominalisations"},
},
["verb"] = {
categories = {"verbalisations"},
},
}
local new_pos_aliases = {
["adj"] = "adjective",
["n"] = "noun",
["v"] = "verb",
}


local no_term_params = {
local no_term_params = {
Line 188: Line 205:
end
end


local function hydrate_category(category, language_to, language_from)
local function hydrate_category(category, language_to, language_from, newpos)
     local new_category = language_to.name .. " " .. category
     local new_category = language_to.name .. " " .. category
     if language_from then new_category = new_category .. " " .. language_from.name end
     if language_from then new_category = new_category .. " " .. language_from.name end
Line 194: Line 211:
end
end


local function hydrate_categories(categories, language_to, language_from)
local function hydrate_categories(categories, language_to, language_from, newpos)
     local new_categories = {}
     local new_categories = {}
     for i, category in ipairs(categories) do
     for i, category in ipairs(categories) do
         new_categories[i] = hydrate_category(category, language_to, language_from)
         new_categories[i] = language_to.name .. " " .. category .. (language_from and (" " .. language_from.name) or "")
    end
    if newpos then
    newpos = new_pos_aliases[newpos] or newpos
    local newpos_data = new_pos_data[newpos]
    for _, category in ipairs(newpos_data["categories"]) do table.insert(new_categories, language_from .. " " .. category) end
     end
     end
     return new_categories
     return new_categories
Line 224: Line 246:
         nobold = true,
         nobold = true,
     }, "term")
     }, "term")
     if not args["nocat"] then categories = hydrate_categories(data["categories"], language) end
     if not args["nocat"] then categories = hydrate_categories(data["categories"], language, nil, args["newpos"]) end
     return format_etymology(out, categories)
     return format_etymology(out, categories)
end
end

Navigation menu