Module:example: Difference between revisions

From Laenkea
Jump to navigation Jump to search
(Created page with "local export = {} local m_formatting = require("Module:formatting") local m_languages = require("Module:languages") function export.show(frame) local args = frame:getParent().args local language = m_languages.get_by_code(args[1]) if not args[2] then error("a sentence must be provided to {{example}}") end local translation = args[3] and ('<dl><dd>' .. args[3] .. '</dd></dl>') or "" return '<dl><dd>' .. m_formatting.wrap_face(args[2], language, "example") .. transla...")
 
No edit summary
Line 9: Line 9:
if not args[2] then error("a sentence must be provided to {{example}}") end
if not args[2] then error("a sentence must be provided to {{example}}") end
local translation = args[3] and ('<dl><dd>' .. args[3] .. '</dd></dl>') or ""
local translation = args[3] and ('<dl><dd>' .. args[3] .. '</dd></dl>') or ""
return '<dl><dd>' .. m_formatting.wrap_face(args[2], language, "example") .. translation .. '</dd></dl>'
local cats = (args["nocats"] and args["nocats"] ~= "") and ("[[Category:" .. language.name .. " terms with usage examples]]") or ""
return '<dl><dd>' .. m_formatting.wrap_face(args[2], language, "example") .. translation .. '</dd></dl>' .. cats
end
end

Revision as of 13:48, 7 August 2023

Implements {{example}}.


local export = {}

local m_formatting = require("Module:formatting")
local m_languages = require("Module:languages")

function export.show(frame)
	local args = frame:getParent().args
	local language = m_languages.get_by_code(args[1])
	if not args[2] then error("a sentence must be provided to {{example}}") end
	local translation = args[3] and ('<dl><dd>' .. args[3] .. '</dd></dl>') or ""
	local cats = (args["nocats"] and args["nocats"] ~= "") and ("[[Category:" .. language.name .. " terms with usage examples]]") or ""
	return '<dl><dd>' .. m_formatting.wrap_face(args[2], language, "example") .. translation .. '</dd></dl>' .. cats
end