Module:Ikiusu
Documentation for this module may be created at Module:Ikiusu/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local word = args[1]
local options = {}
for i = 2, #args do
options[args[i]] = true
end
options.image = args.image
local langs = {}
local lang_list = {}
for k, v in pairs(args) do
if type(k) == "string" then
local lang, param = k:match "([^-]*)-(.*)"
if lang then
if not langs[lang] then
table.insert(lang_list, lang)
langs[lang] = {}
end
if tonumber(param) then
langs[lang][tonumber(param)] = v
else
langs[lang][param] = v
end
end
end
end
local result = {}
table.insert(result, "{{langs|")
for _, lang in ipairs(lang_list) do
table.insert(result, "{{langs/in|"..lang.."|")
if options.image then
local caption = langs[lang].caption or ""
table.insert(result,
"[["..options.image.."|200px|thumb|"..caption.."]]"
)
end
table.insert(result, "'''"..word.."'''")
for _, defn in ipairs(langs[lang]) do
table.insert(result, "#"..defn)
end
if options.inflect then
table.insert(result, "{{inflect senra|"..lang.."|"..word.."}}")
end
table.insert(result, langs[lang].extra or "")
table.insert(result, "}}")
end
table.insert(result, "}}")
return frame:preprocess(table.concat(result, "\n"))
end
return p