Modul:ms-dial-sin
Penampilan
- Modul ini kekurangan sublaman pendokumenan. Sila mencipta laman pendokumenan berkaitan.
- 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 ms = m_languages.getByCode("ms")
local variety_list = {
"BN", "MY", "SG", "ID",
"Brunei", "Malaysia", "Singapura", "Indonesia", "Lain",
}
local variety_colour = {
["BN"] = "FAF0F2",
["MY"] = "FAF0F2",
["SG"] = "FAF0F2",
["ID"] = "FAF0F2",
["Proto"] = "FAF0F2",
["Kuno"] = "FAF0F2",
["Klasik"] = "FAF0F2",
["Pramoden"] = "FAF0F2",
["Brunei"] = "FAF0F2",
["Malaysia"] = "FAF0F2",
["Singapura"] = "FAF0F2",
["Indonesia"] = "FAF0F2",
["Lain"] = "FAF0F1",
}
local special_note = {
["BN"] = "Brunei",
["MY"] = "Malaysia",
["SG"] = "Singapura",
["ID"] = "Indonesia",
["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:ms/data/dial-sin/" .. target_page
local variety_data = require("Module:ms/data/dial")
local m_syndata
if mw.title.new(resource_page).exists then
m_syndata = require(resource_page).list
else
return frame:expandTemplate{ title = "Template:ms-dial/tidak_dicipta", args = { target_page } }
end
local template = {
["BN"] = {},
["MY"] = {},
["SG"] = {},
["ID"] = {},
["Proto"] = "Proto",
["Kuno"] = "Kuno",
["Klasik"] = "Klasik",
["Pramoden"] = "Pramoden",
["Brunei"] = {},
["Malaysia"] = {},
["Singapura"] = {},
["Indonesia"] = {},
["Lain"] = {},
}
local main_title = mw.ustring.gsub(m_links.full_link( { term = target_page, lang = ms } ), "[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:ms-dial-peta/" .. target_page .. '|<small>[peta]</small>]]\n' .. [=[</div><div class="NavContent">
{| class="wikitable" style="margin:0; text-align:center; width: 100%"
|-
! style="background:#E8ECFA" | Negara
! style="background:#E8ECFA" | Ragam/Dialek
! style="background:#E8ECFA" | Perkataan]=] .. [=[
<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[]=] ..
tostring(mw.uri.fullUrl("Module:ms/data/dial-sin/" .. 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-MY"][1] == "" then
m_syndata["Baku-MY"] = { target_page }
elseif m_syndata["Baku-MY"][1] == "-" then
m_syndata["Baku-MY"] = 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 = ms
} )
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