Modul:mfa-varian
Penampilan
- Laman modul ini kekurangan sublaman pendokumenan. Sila cipta laman pendokumenan tersebut.
- Pautan berguna: senarai sublaman • pautan • transklusi • kes ujian • kotak pasir
local export = {}
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local mfa = m_languages.getByCode("mfa")
local variety_list = {
"PT", "KL", "RM", "SM",
"Patani", "Kelantan", "Reman", "Samsam", "Lain",
}
local variety_colour = {
["PT"] = "FAF0F2",
["KL"] = "FAF0F2",
["RM"] = "FAF0F2",
["SM"] = "FAF0F2",
["Proto"] = "FAF0F2",
["Kuno"] = "FAF0F2",
["Klasik"] = "FAF0F2",
["Pramoden"] = "FAF0F2",
["Patani"] = "FAF0F2",
["Kelantan"] = "FAF0F2",
["Reman"] = "FAF0F2",
["Samsam"] = "FAF0F2",
["Lain"] = "FAF0F1",
}
local special_note = {
["PT"] = "Patani",
["KL"] = "Kelantan",
["RM"] = "Reman",
["SM"] = "Samsam",
["Proto"] = "Proto",
["Kuno"] = "Kuno",
["Klasik"] = "Klasik",
["Pramoden"] = "Pramoden",
}
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:mfa/data/varian/" .. target_page
local variety_data = require("Module:mfa/data/varian")
local m_syndata
if mw.title.new(resource_page).exists then
m_syndata = require(resource_page).list
else
return frame:expandTemplate{ title = "Template:mfa-varian/tidak_dicipta", args = { target_page } }
end
local template = {
["PT"] = {},
["KL"] = {},
["RM"] = {},
["SM"] = {},
["Proto"] = "Proto",
["Kuno"] = "Kuno",
["Klasik"] = "Klasik",
["Pramoden"] = "Pramoden",
["Patani"] = {},
["Kelantan"] = {},
["Reman"] = {},
["Indonesia"] = {},
["Samsam"] = {},
}
local main_title = mw.ustring.gsub(m_links.full_link( { term = target_page, lang = mfa } ), "[0-9%-]", "")
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; margin-left:-1px; background-color:#CCCCFF; text-align:center;" cellpadding="3">Sinonim dialek bagi ]=] ..
main_title .. ' (“' .. m_syndata["maksud"] .. '”) ' ..
"[[Templat:mfa-varian-peta/" .. target_page .. '|<small>[peta]</small>]]\n' .. [=[</div><div class="NavContent">
{| class="wikitable" style="margin:0; text-align:center; width: 100%"
|-
! style="background:#E8ECFA" | Varian
! style="background:#E8ECFA" | Lokasi
! style="background:#E8ECFA" | Perkataan]=] .. [=[
<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[]=] ..
tostring(mw.uri.fullUrl("Module:mfa/data/varian/" .. target_page, { ["action"] = "edit" })) ..
' sunting]</span></div>' }
m_syndata["maksud"] = nil
if m_syndata["nota"] then
note = m_syndata["nota"]
m_syndata["nota"] = nil
end
if m_syndata["Baku-PT"][1] == "" then
m_syndata["Baku-PT"] = { target_page }
elseif m_syndata["Baku-PT"][1] == "-" then
m_syndata["Baku-PT"] = nil
end
for location, synonym_set in pairs(m_syndata) do
if synonym_set[1] ~= "" then
local formatted_synonyms = {}
for i, synonym in ipairs(synonym_set) do
local synonym_note = mw.text.split(synonym, ":")
local synonym_etym = mw.text.split(synonym_note[1], "_")
local syn, etym, note = synonym_etym[1], synonym_etym[2], synonym_note[2]
local synonym_link = m_links.full_link( {
term = syn .. (etym and string.format("#Etimologi %s", etym) or ""),
alt = etym and (syn .. string.format("<sub>%s</sub>", etym)),
lang = mfa
} )
note = note and ' <span style="font-size:60%"><i>' .. note .. '</i></span>' or ""
table.insert(formatted_synonyms, synonym_link .. note)
end
local location_data = variety_data[location] or error("Tiada data bagi lokasi " .. location .. "!")
local location_name = mw.ustring.gsub(location_data.melayu or location, "(%(.*%))", "<small>%1</small>")
local location_link = location_data.link or location_name
table.insert(template[location_data.group],
{ location_data.order, location_name, location_link, formatted_synonyms })
end
end
for _, variety in ipairs(variety_list) do
local colour = variety_colour[variety]
if #template[variety] > 0 then
table.sort(template[variety], function(first, second) return first[1] < second[1] end)
for i, point_data in ipairs(template[variety]) do
table.insert(syn_table, "\n|-")
if i == 1 then
table.insert(syn_table, "\n!rowspan=" .. #template[variety] .. (special_note[variety] and " colspan=2" or "") ..
' style="background:#' .. colour .. '"| ' .. (special_note[variety] or variety))
end
table.insert(syn_table, ((point_data[2] and not special_note[variety]) and ('\n|style="background:#' .. colour .. '"| ' ..
'[[w:' .. point_data[3] .. '|' .. point_data[2] .. ']]') or '') ..
'\n|style="background:#' .. colour .. '"| ' ..
table.concat(point_data[4], ", "))
end
end
end
if note and note ~= "" then
table.insert(syn_table, '\n|-\n! style="background:#FFF7FB; padding-top:5px; padding-bottom: 5px" | ' ..
"<small>Nota</small>\n| colspan=2|<small><i>" .. note .. "</i></small>")
end
table.insert(syn_table, '\n|}</div></div>')
return table.concat(syn_table, "")
end
return export