This module deploys the Indonesian headword templates and all associated templates.
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("id")
local script = require('Module:scripts').getByCode("Latn")
local PAGENAME = mw.title.getCurrentTitle().text
function export.show(frame)
-- FIXME: Use ].
local args = frame:getParent().args
local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local head = args; if head == "" then head = nil end
local data = {
lang = lang,
sc = script,
pos_category = poscat,
categories = {}, -- Ensure initialized as an empty table
heads = {head},
translits = {"-"},
inflections = {}
}
if pos_functions then
pos_functions(args, data)
end
return require("Module:headword").full_headword(data)
end
-- Function for nouns (common and proper)
-- Shortcuts for the plural markings
pos_functions = function(args, data)
-- For nouns with unknown or uncertain plural forms or requests for nouns plural forms
if args == "req" then -- Adding ]
args = "req"
elseif args == "?" then -- Adding ]
args = "?"
-- For uncountable and semi-countable nouns
elseif args == "-" then -- Marking uncountable nouns
args = "-"
elseif args == "0" then -- Marking uncountable nouns without the (uncountable) label, if very unnecessary
args = "0"
elseif args == "u" then -- Marking usually uncountable nouns
args = "u"
elseif args == "~" then -- Marking countable and uncountable nouns both in quality
args = "~"
elseif args == "pt" or args == "p" then -- Marking pluralia tantum
args = "p"
elseif args == "st" or args == "s" then -- Marking singularia tantum
args = "s"
elseif args == "*" then -- Creating unchanged plural forms
args = "*"
-- For countable nouns
elseif args == "+" then -- Creating common plural forms (reduplication)
args = "+"
elseif args == "a" then -- Creating both common (reduplication) and "para" plural forms for some human nouns
args = "a"
end
-- Auto-detect full reduplication
local pagename = mw.title.getCurrentTitle().text -- Get the current page name
if pagename:match("^(+)%-%1$") then
local pl = {label = "plural"}
table.insert(pl, mw.ustring.format("]", PAGENAME))
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
table.insert(data.inflections, pl)
return -- Stop further processing
end
-- Initialize categories and inflections if nil (not specified)
data.categories = data.categories or {}
data.inflections = data.inflections or {}
-- Main code for noun plurality
-- Unknown or uncertain and requests
if args == "req" then
table.insert(data.categories, "Requests for plural forms in Indonesian entries")
elseif args == "?" then
table.insert(data.categories, "Indonesian nouns with unknown or uncertain plurals")
-- Uncountable and semi-countable
elseif args == "-" then
table.insert(data.categories, "Indonesian uncountable nouns")
table.insert(data.inflections, {label = "]"})
elseif args == "0" then
table.insert(data.categories, "Indonesian uncountable nouns")
elseif args == "u" then
local pl_countable = {label = "usually ]"}
local pl_plural = {label = "plural"}
table.insert(data.categories, "Indonesian countable nouns")
table.insert(data.categories, "Indonesian uncountable nouns")
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords
local plural_form = mw.ustring.gsub("]-]", "(+%-)%1%1", "banyak %1")
table.insert(pl_plural, plural_form)
table.insert(data.inflections, pl_countable)
table.insert(data.inflections, pl_plural)
elseif args == "~" then
local pl_countable = {label = "] and ]"}
local pl_plural = {label = "plural"}
table.insert(data.categories, "Indonesian countable nouns")
table.insert(data.categories, "Indonesian uncountable nouns")
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords
local plural_form = mw.ustring.gsub("]-]", "(+%-)%1%1", "banyak %1")
table.insert(pl_plural, plural_form)
table.insert(data.inflections, pl_countable)
table.insert(data.inflections, pl_plural)
elseif args == "pt" or args == "p" then
table.insert(data.categories, "Indonesian pluralia tantum")
table.insert(data.inflections, {label = "]"})
elseif args == "st" or args == "s" then
table.insert(data.categories, "Indonesian singularia tantum")
table.insert(data.inflections, {label = "]"})
-- Countable
else
local pl = {label = "plural"}
if not args or args == "duplication" or args == "+" then
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords
subwords = mw.ustring.gsub("]-]", "(+%-)%1%1", "banyak %1")
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
table.insert(pl, table.concat(subwords, " "))
elseif args == "a" then
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords
local plural_form = "]-]"
if #subwords > 1 then
for i = 2, #subwords do
plural_form = plural_form .. " " .. subwords
end
end
table.insert(pl, plural_form)
local para_form = "] " .. table.concat(subwords, " ")
table.insert(pl, para_form)
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
elseif args == "*" then
table.insert(pl, mw.ustring.format(PAGENAME))
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
table.insert(data.inflections, pl)
return -- Stop further processing
end
table.insert(data.inflections, pl)
end
end
return export