Module:qhv-noun: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 8: Line 8:
local syllables = require("Module:qhv-pron").write_stress
local syllables = require("Module:qhv-pron").write_stress
local alldata = require('Module:qhv-noun/data')
local alldata = require('Module:qhv-noun/data')
local PAGENAME = mw.title.getCurrentTitle().text
local PAGENAME = gsub(mw.title.getCurrentTitle().text, "%s", " ")
local NAMESPACE = mw.title.getCurrentTitle().nsText
local NAMESPACE = mw.title.getCurrentTitle().nsText


Line 15: Line 15:


local lang = require("Module:languages").getByCode("qhv")
local lang = require("Module:languages").getByCode("qhv")
local sorted = lang:makeSortKey(PAGENAME)


local export = {}
local export = {}
Line 34: Line 33:
["ir"] = "c-5", ["rjin"] = "p-5",
["ir"] = "c-5", ["rjin"] = "p-5",
}
}
local function ncategories(categories)
local out_categories = {}
for key, cat in ipairs(categories) do
out_categories[key] = "[[Category:" .. cat .. "|" .. sorted .. "]]"
end
return table.concat(out_categories, "")
end


function export.detect_decl(word, number, class, reanalyzed)
function export.detect_decl(word, number, class, reanalyzed)
Line 51: Line 41:
local decl = number .. "-" .. class
local decl = number .. "-" .. class
return decl, {sub(word, 1, -(#endings_reverse[decl] + 1))}
return decl, {sub(word, 1, -(#endings_reverse[decl] + 1))}
elseif word:find("illa$") then
return "-illa", {sub(word, 1, -2)}
elseif word == "skorlūs" then
return "3-s-h", {sub(word, 1, -2)}
elseif reanalyzed then
elseif reanalyzed then
for ending, decl in pairs(reanalyzed_endings) do
for ending, decl in pairs(reanalyzed_endings) do
Line 76: Line 70:
local decl = {}
local decl = {}
local word = NAMESPACE == "Template" and "vala" or parent_args.word or PAGENAME
local word = NAMESPACE == "Template" and "vala" or parent_args.word or PAGENAME
local reanalyzed = parent_args["r"]
local args = {}
local args = {}


Line 86: Line 81:
numbers = {parent_args[1]}
numbers = {parent_args[1]}
else
else
decl_type, numbers = export.detect_decl(word, parent_args.n, parent_args.c)
decl_type, numbers = export.detect_decl(word, parent_args.n, parent_args.c, reanalyzed)
end
end
end
end
Line 107: Line 102:
pass.head = parent_args["head"] or nil
pass.head = parent_args["head"] or nil
pass.proper = parent_args["proper"] and true or false
pass.proper = parent_args["proper"] and true or false
pass.nocat = parent_args["nocat"] and true or false
-- Generate the forms
-- Generate the forms
Line 192: Line 188:
|}]=]
|}]=]


return (gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. ncategories(pass.categories)
 
return gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl) .. (not pass.nocat and require("Module:utilities").format_categories(pass.categories, lang) or "")
end
end




return export
return export