Module:zh-Christian-syn
Appearance
- The following documentation is located at Module:zh-Christian-syn/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
Module for equivalent terms in different branches of Christianity. See {{zh-Christian-syn}}
.
-- adapted from [[MOD:zh-dial-syn]]
local export = {}
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local zh = m_languages.getByCode("zh")
local branch_list = {
"Protestant", "Roman Catholic", "Eastern Orthodox", "Church of the East"
}
local branch_colour = {
["Protestant"] = "FAF5F0",
["Roman Catholic"] = "F0F5FA",
["Eastern Orthodox"] = "F0FAF3",
["Church of the East"] = "F6F0FA",
}
function export.main(frame)
local args = frame:getParent().args
local pagename = mw.title.getCurrentTitle().text
local target_page = args[1] or pagename
local resource_page = "Module:zh/data/Christian-syn/" .. target_page
local m_syndata
if mw.title.new(resource_page).exists then
m_syndata = require(resource_page).list
else
return frame:expandTemplate{ title = "Template:zh-Christian-syn/uncreated", args = { target_page } }
end
local syn_table = { [=[
<div class="NavFrame" style="border:0px; max-width: 40em; text-align:center;"><div class="NavHead" style="font-size:105%; border:1px solid #aaaaaa; background-color:#CCCCFF; text-align:center;" cellpadding="3">Terms for ]=] ..
m_syndata["title"] .. ' in different branches of Christianity' ..
[=[</div><div class="NavContent">
{| class="wikitable" style="margin:0; text-align:center; width: 100%"
|-
! style="background:#E8ECFA" | Branch]=] .. "\n" }
if m_syndata["type"] == "book" then
table.insert(syn_table, [=[! style="background:#E8ECFA" | Names
! style="background:#E8ECFA" | Abbreviations]=] .. [=[
<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[]=] ..
tostring(mw.uri.fullUrl("Module:zh/data/Christian-syn/" .. target_page, { ["action"] = "edit" })) ..
' edit]</span></div>')
for _, branch in ipairs(branch_list) do
local colour = branch_colour[branch]
local formatted_names = {}
local formatted_abbs = {}
local synonym_set = m_syndata[branch] or { "" }
if synonym_set[1] ~= "" then
for i, synonym in ipairs(synonym_set) do
local synonym_note = mw.text.split(synonym, ":")
local syn, note = synonym_note[1], synonym_note[2]
local link = m_links.full_link( {
term = syn.."//",
lang = zh,
tr = "-"
} )
if note and note == "abb" then
table.insert(formatted_abbs, link)
else
note = note and ' <span style="font-size:60%"><i>' .. note .. '</i></span>' or ""
table.insert(formatted_names, link .. note)
end
end
table.insert(syn_table, "\n|-")
table.insert(syn_table, '\n|style="background:#' .. colour .. '"| ' .. '[[' .. branch .. ']]\n|style="background:#' .. colour .. '"| ' .. table.concat(formatted_names, ", ") .. '\n|style="background:#' .. colour .. '"| ' .. table.concat(formatted_abbs, ", "))
end
end
else
table.insert(syn_table, [=[! style="background:#E8ECFA" | Words]=] .. [=[
<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[]=] ..
tostring(mw.uri.fullUrl("Module:zh/data/Christian-syn/" .. target_page, { ["action"] = "edit" })) ..
' edit]</span></div>')
for _, branch in ipairs(branch_list) do
local colour = branch_colour[branch]
local formatted_synonyms = {}
local synonym_set = m_syndata[branch] or { "" }
if synonym_set[1] ~= "" then
for i, synonym in ipairs(synonym_set) do
local synonym_note = mw.text.split(synonym, ":")
local syn, note = synonym_note[1], synonym_note[2]
local synonym_link = m_links.full_link( {
term = syn.."//",
lang = zh,
tr = "-"
} )
note = note and ' <span style="font-size:60%"><i>' .. note .. '</i></span>' or ""
table.insert(formatted_synonyms, synonym_link .. note)
end
table.insert(syn_table, "\n|-")
table.insert(syn_table, '\n|style="background:#' .. colour .. '"| ' .. '[[' .. branch .. ']]\n|style="background:#' .. colour .. '"| ' .. table.concat(formatted_synonyms, ", "))
end
end
end
table.insert(syn_table, '\n|}</div></div>')
return table.concat(syn_table, "")
end
return export