local m_translit = require("Module:translit-redirect")
local sub = mw.ustring.sub
local export = {}
local variety_list = {
"Central", "East", "Northwest", "West", "South"
}
local variety_colour = {
= "FAF5F0",
= "F0F5FA",
= "F0FAF3",
= "FAF0F6",
= "FAF9F0",
}
local special_note = {
-- none yet
}
function export.main(frame)
local args = frame:getParent().args
local pagename = mw.title.getCurrentTitle().text
local target_page = args or pagename
local resource_page = "Module:inc-ash/dial/data/" .. target_page
local variety_data = require("Module:inc-ash/dial/data")
if mw.title.new(resource_page).exists then
m_syndata = require(resource_page).list
else
return frame:expandTemplate{ title = "Template:inc-ash-dial/uncreated", args = { target_page } }
end
local template = {
= {},
= {},
= {},
= {},
= {},
}
main_title = mw.ustring.gsub((target_page == pagename and pagename or ']'), "", "")
text = [=[
{| class="wikitable mw-collapsible mw-collapsed" style="margin:0; text-align:center;"
|-
! style="background:#FCFFFC; width:40em" colspan=3 | Dialectal forms of <b><span class="Brah" lang="inc-ash">]=] ..
main_title .. '</span></b> (“' .. m_syndata .. '”) ' .. [=[
|-
! style="background:#E8ECFA" | Variety
! style="background:#E8ECFA" | Location
! style="background:#E8ECFA" | Forms]=] .. [=[
<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">=] ..
tostring(mw.uri.fullUrl("Module:inc-ash/dial/data/" .. target_page, { = "edit" })) ..
' edit]</span></div>'
m_syndata = nil
if m_syndata then
note = m_syndata
m_syndata = nil
end
local categories = ""
for location, synonym_set in pairs(m_syndata) do
-- check if location is in alias list and use the proper one if so
if variety_data ~= nil then location = variety_data end
local sc = "Brah"
if location == "Shahbazgarhi" or location == "Mansehra" then
sc = "Khar"
end
if synonym_set ~= "" then
local formatted_synonyms = {}
for i, synonym in ipairs(synonym_set) do
local synonym_decomp = mw.text.split(synonym, ":")
table.insert(formatted_synonyms,
", "(.+)_()", "%1#Etymology %2|%1<sub>%2</sub>") .. "]]" ..
(synonym_decomp and '</span> <span style="font-size:60%"><i>' .. synonym_decomp .. '</i>' ..
(i < #synonym_set and '<span class="' .. sc .. '" lang="inc-ash">' or "") or ""))
end
local location_data = variety_data
local location_name = mw.ustring.gsub(location_data.english or location, "(%(.*%))", "<small>%1</small>")
local location_link = location_data.link or location_name
table.insert(template,
{ location_data.order, location_name, location_link, formatted_synonyms })
end
end
local attested = {}
for _, variety in ipairs(variety_list) do
local sc = "Brah"
if variety == "Northwest" then
sc = "Khar"
end
local colour = variety_colour
if #template > 0 then
table.sort(template, function(first, second) return first < second end)
for i, point_data in ipairs(template) do
local result = {}
for _, word in ipairs(point_data) do
if mw.ustring.gsub(sub(word, 3, -3), "%]%].+$", "") == pagename then
table.insert(attested, {point_data, point_data})
categories = categories .. " .. " Ashokan Prakrit]]"
end
local tr = mw.ustring.gsub(m_translit.tr(sub(word, 3, -3), "inc-ash", sc), "%]%].+$", "")
local add = '<span class="' .. sc .. '" lang="inc-ash">' .. word .. "</span> <small>(" .. tr
if point_data ~= nil then add = add .. " /" .. point_data .. "/" end
add = add .. ")</small>"
table.insert(result, add)
end
text = text .. "\n|-"
if i == 1 then
text = text .. "\n!rowspan=" .. #template .. (special_note and " colspan=2" or "") ..
' style="background:#' .. colour .. '"| ' .. (special_note or variety)
end
text = text .. ((point_data and not special_note) and ('\n|style="background:#' .. colour .. '"| ' ..
' .. '|' .. point_data .. ']]') or '') ..
'\n|style="background:#' .. colour .. "'| " ..
table.concat(result, ", ")
end
end
end
if note and note ~= "" then
text = text .. '\n|-\n! style="background:#FFF7FB; padding-top:5px; padding-bottom: 5px" | ' ..
"<small>Note</small>\n| colspan=2|<small><i>" .. note .. "</i></small>"
end
local res = "Attested at "
table.sort(attested, function(first, second) return first < second end)
for i, dialect in ipairs(attested) do
if i == #attested and i ~= 1 then
res = res .. " and "
elseif i ~= 1 then
res = res .. ", "
end
res = res .. ' .. '|' .. dialect .. ']]'
end
return res .. '.\n' .. text .. '\n|}' .. categories
end
return export