Module:Ikiusu: Difference between revisions
Created page with "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) end langs[lang] = langs[lang] if tonumber(..." |
No edit summary |
||
| Line 18: | Line 18: | ||
if not langs[lang] then | if not langs[lang] then | ||
table.insert(lang_list, lang) | table.insert(lang_list, lang) | ||
langs[lang] = {} | |||
end | end | ||
if tonumber(param) then | if tonumber(param) then | ||
langs[tonumber(param)] = v | langs[lang][tonumber(param)] = v | ||
else | else | ||
langs[param] = v | langs[lang][param] = v | ||
end | end | ||
end | end | ||
Revision as of 10:38, 26 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 = 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 = {}
for _, lang in ipairs(lang_list) do
table.concat(result, "{{langs/in|"..lang.."")
if options.image then
local caption = langs[lang].caption or ""
table.concat(result,
"[["..options.image.."|200px|thumb|"..caption.."]]"
)
end
table.concat(result, "'''"..word.."'''")
for _, defn in ipairs(langs[lang]) do
table.concat(result, defn)
end
if options.inflect then
table.concat(result, "{{inflect senra|"..lang.."|"..word.."}}")
end
table.concat(result, "}}")
end
return frame:preprocess(table.concat(result, "\n"))
end
return p