Module:Ikiusu: Difference between revisions
aaaaaaa |
using mediawiki is an exercise in spending hours debugging the most inane issues that could ever occur |
||
| Line 44: | Line 44: | ||
) | ) | ||
end | end | ||
local entry_start = "'''"..word.."'''" | local entry_start = " ''' "..word.." ''' " | ||
if langs[lang].pos then | if langs[lang].pos then | ||
entry_start = entry_start.." (''"..langs[lang].pos.."'')" | entry_start = entry_start.." (''"..langs[lang].pos.."'')" | ||
| Line 59: | Line 59: | ||
end | end | ||
table.insert(result, "}}") | table.insert(result, "}}") | ||
return | return frame:preprocess(table.concat(result, "\n")) | ||
end | end | ||
return p | return p | ||
Revision as of 08:02, 29 September 2025
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 = 1, math.huge do
if not args[i] then
break
end
options[mw.text.trim(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
table.sort(lang_list)
local result = {}
table.insert(result, "[[Ikiusu:lemma::"..word.."|]]")
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,
"[[File:"..options.image.."|200px|thumb|"..caption.."]]"
)
end
local entry_start = " ''' "..word.." ''' "
if langs[lang].pos then
entry_start = entry_start.." (''"..langs[lang].pos.."'')"
end
table.insert(result, entry_start)
for _, defn in ipairs(langs[lang]) do
table.insert(result, "# [[Ikiusu:definition::"..defn.."@"..lang.."|"..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