Module:example: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
local m_formatting = require("Module:formatting") | local m_formatting = require("Module:formatting") | ||
local m_languages = require("Module:languages") | local m_languages = require("Module:languages") | ||
local params = { | |||
[1] = {required = true}, | |||
[2] = {required = true}, | |||
[3] = {}, | |||
["inline"] = {type = "boolean"}, | |||
["nocat"] = {type = "boolean"}, | |||
} | |||
function export.show(frame) | function export.show(frame) | ||
local args = frame:getParent().args | local args = require("Module:parameters").process(frame:getParent().args, params) | ||
local language = m_languages.get_by_code(args[1]) | local language = m_languages.get_by_code(args[1]) | ||
local translation = args[3] and (args["inline"] and (" — " .. args[3]) or ("<dl><dd>" .. args[3] .. "</dd></dl>")) or "" | |||
local cats = args["nocat"] and "" or ("[[Category:" .. language.name .. " terms with usage examples]]") | |||
local cats = | |||
return '<div class="h-example">' .. m_formatting.wrap_face(args[2], language, "example") .. translation .. '</div>' .. cats | return '<div class="h-example">' .. m_formatting.wrap_face(args[2], language, "example") .. translation .. '</div>' .. cats | ||
end | end | ||
return export | return export |
Revision as of 15:44, 22 February 2024
Implements {{example}}
.
local export = {}
local m_formatting = require("Module:formatting")
local m_languages = require("Module:languages")
local params = {
[1] = {required = true},
[2] = {required = true},
[3] = {},
["inline"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
}
function export.show(frame)
local args = require("Module:parameters").process(frame:getParent().args, params)
local language = m_languages.get_by_code(args[1])
local translation = args[3] and (args["inline"] and (" — " .. args[3]) or ("<dl><dd>" .. args[3] .. "</dd></dl>")) or ""
local cats = args["nocat"] and "" or ("[[Category:" .. language.name .. " terms with usage examples]]")
return '<div class="h-example">' .. m_formatting.wrap_face(args[2], language, "example") .. translation .. '</div>' .. cats
end
return export