Module:User:Aryamanarora/hi-dial-syn

local export = {}

local variety_list = { "Standard Hindi", "Poetic Hindi", "Standard Urdu", "Hindustani", "Braj", "Haryanvi", "Bundeli", "Kannauji", "Awadhi", "Bagheli", "Bhojpuri", "Chhattisgarhi", }

local variety_colour = { ["Standard Hindi"]	= "FAF0F2", ["Poetic Hindi"]	= "FAF0F2", ["Standard Urdu"]	= "FAF5F0", ["Hindustani"]		= "F0F5FA", ["Braj"]			= "F0F5FA", ["Haryanvi"]		= "F0F5FA", ["Bundeli"]			= "F0F5FA", ["Kannauji"]		= "F0F5FA", ["Awadhi"]			= "F0FAF3", ["Bagheli"]			= "F0FAF3", ["Bhojpuri"]		= "F0FAF3", ["Chhattisgarhi"]	= "F0FAF3", }

local special_note = { ["Standard Hindi"] = "Modern Standard Hindi", ["Standard Urdu"] = "Modern Standard Urdu", }

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:User:Aryamanarora/hi-dial-syn/data" .. target_page local variety_data = require("Module:User:Aryamanarora/hi-dial-syn/data/dial") if mw.title.new(resource_page).exists then m_syndata = require(resource_page).list else return frame:expandTemplate{ title = "Template:hi-dial/uncreated", args = { target_page } } end local template = { ["Standard Hindi"]	= {}, ["Poetic Hindi"]	= {}, ["Standard Urdu"]	= {}, ["Hindustani"]		= {}, ["Braj"]			= {}, ["Haryanvi"]		= {}, ["Bundeli"]			= {}, ["Kannauji"]		= {}, ["Awadhi"]			= {}, ["Bagheli"]			= {}, ["Bhojpuri"]		= {}, ["Chhattisgarhi"]	= {}, }

main_title = mw.ustring.gsub((target_page == pagename and pagename or  .. target_page .. ), "[0-9%-]", "") text = [=[ {| class="wikitable mw-collapsible mw-collapsed" style="margin:0; text-align:center;" |-	! style="background:#FCFFFC; width:40em" colspan=3 | Dialectal synonyms of  ]=] .. main_title .. '  (“' .. m_syndata["meaning"] .. '”) ' .. " &#91;map&#93; \n' .. [=[	|-	! style="background:#E8ECFA" | Variety ! style="background:#E8ECFA" | Location ! style="background:#E8ECFA" | Words]=] .. [=[	 []=] ..		tostring(mw.uri.fullUrl("Module:User:Aryamanarora/hi-dial-syn/data/" .. target_page, { ["action"] = "edit" })) .. ' edit] ' m_syndata["meaning"] = nil if m_syndata["note"] then note = m_syndata["note"] m_syndata["note"] = 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_decomp = mw.text.split(synonym, ":") table.insert(formatted_synonyms, "" .. synonym_decomp[1] .. "" ..					(synonym_decomp[2] and ' ''' .. synonym_decomp[2] .. ''' ' ..					(i < #synonym_set and ' ' or "") or "")) end local location_data = variety_data[location] local location_name = mw.ustring.gsub(location_data.english or location, "(%(.*%))", " %1 ") 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 text = text .. "\n|-" if i == 1 then text = text .. "\n!rowspan=" .. #template[variety] .. (special_note[variety] and " colspan=2" or "") .. ' style="background:#' .. colour .. '"| ' .. (special_note[variety] or variety) end text = text .. ((point_data[2] and not special_note[variety]) and ('\n|style="background:#' .. colour .. '"| ' ..  .. point_data[2] .. ) or '') .. '\n|style="background:#' .. colour .. '"| ' .. table.concat(point_data[4], "、") .. ' '			end end end

if note and note ~= "" then text = text .. '\n|-\n! style="background:#FFF7FB; padding-top:5px; padding-bottom: 5px" | ' .. " Note \n| colspan=2| ''" .. note .. "'' "	end return text .. '\n|}' end

return export