Module:Connect Individuals
Usage
editEmbed everything (all individuals)
edit{{#invoke:Connect Individuals|individuals}}
This loops through all the individuals in the Lua table onto Connect/Individuals on Connect.
Translation
editThe strings for this module are contained in Template:I18n/Education Connect.
local p = {}
-- To edit the list of individuals in its raw form, go to the page named below.
content = require( 'Module:Education_Connect/Individuals' )
is_rtl = require( 'Module:Is rtl' )
lang = mw.getCurrentFrame():preprocess('{{int:lang}}')
ModuleMsg = require( 'Module:ModuleMsg' )
msg = ModuleMsg:get_msgs('Template:I18n/Education Connect', lang)
function get_translation(details)
-- Get translated version of a list entry
--
-- Usage:
-- details: table containing the entry to translate
--
-- Return table: translated entry (with English as fallback)
if details.name == nil or lang == 'en' then
-- This system assumes that a unique name is assigned.
return details
end
for k, v in pairs(details) do
if msg[k] ~= nil then
details[k] = msg[k]
end
end
return details
end
function get_directionality()
-- Should something be left-aligned or right-aligned?
if is_rtl[lang] == true then
return 'right'
end
return 'left'
end
function build_entry(frame, details)
-- Builds an individual entry on a Individuals page view
--
-- Usage:
-- frame: The frame object
-- details: a table with type, name, description, icon is required
--
-- Return string: wikitext
details = get_translation(details)
template_args = {
type = details.type,
}
if details.name ~= nil then
template_args.name = details.name:gsub("%_", " ")
end
if details.edit_id == nil then
template_args.edit_id = details.name
end
if details.description ~= nil then
template_args.description = string.sub(details.description, 0, 200) .. "..."
end
if details.icon ~= nil then
template_args.icon = details.icon
end
entrycontent = frame:expandTemplate{
title = 'Connect listing',
args = template_args
}
return entrycontent
end
function p.individuals(frame)
-- Function for building individual views
--
-- Usage:
-- frame: The frame object
--
-- Return string: wikitext
individualcontent = ''
for _, individual in ipairs(content) do
individualcontent = individualcontent .. build_entry(frame, individual)
end
return '<div dir="' .. frame:expandTemplate{ title = 'dir', args = { lang } } .. '">' .. individualcontent .. '</div>'
end
return p