Module:gon-convert

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a module to convert between Gondi written in Devanagari script to other scripts used to write the language (the native Masaram and Gunjala scripts as well as Telugu and Odia), based on Module:sa-convert. Although Odia is not commonly cited as a script used for Gondi, it has been included due to the high concentration of Gondis in Odisha and the use of Odia script in the government's Gondi-English-Odia dictionary.


local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local sub = mw.ustring.sub

local conv = {
	["Masa"] = {
		["क"] = "𑴌", ["ख"] = "𑴍", ["ग"] = "𑴎", ["घ"] = "𑴏", ["ङ"] = "𑴐", 
		["च"] = "𑴑", ["छ"] = "𑴒", ["ज"] = "𑴓", ["झ"] = "𑴔", ["ञ"] = "𑴕", 
		["ट"] = "𑴖", ["ठ"] = "𑴗", ["ड"] = "𑴘", ["ढ"] = "𑴙", ["ण"] = "𑴚", 
		["त"] = "𑴛", ["थ"] = "𑴜", ["द"] = "𑴝", ["ध"] = "𑴞", ["न"] = "𑴟", 
		["प"] = "𑴠", ["फ"] = "𑴡", ["ब"] = "𑴢", ["भ"] = "𑴣", ["म"] = "𑴤", 
		["य"] = "𑴥", ["र"] = "𑴦", ["ल"] = "𑴧", ["व"] = "𑴨", ["ळ"] = "𑴭", 
		["श"] = "𑴩", ["ष"] ="𑴪", ["स"] = "𑴫", ["ह"] = "𑴬",
	
		["अ"] = "𑴀", ["आ"] = "𑴁", ["इ"] = "𑴂", ["ई"] = "𑴃", ["उ"] = "𑴄", ["ऊ"] = "𑴅", 
		["ए"] = "𑴆", ["ऐ"] = "𑴈", ["ओ"] = "𑴉", ["औ"] = "𑴋",
		
		["ा"] = "𑴱", ["ि"] = "𑴲", ["ी"] = "𑴳", ["ु"] = "𑴴", ["ू"] = "𑴵", ["ृ"] = "𑴶", 
		["े"] = "𑴺", ["ै"] = "𑴼", ["ो"] = "𑴽", ["ौ"] = "𑴿",  ["्"] = "𑵄",
	
		["ं"] = "𑵀", ["ः"] = "𑵁",

		["०"] = "𑵐", ["१"] = "𑵑", ["२"] = "𑵒", ["३"] = "𑵓", ["४"] = "𑵔", ["५"] = "𑵕", ["६"] = "𑵖", ["७"] = "𑵗", ["८"] = "𑵘", ["९"] = "𑵙",
	        
	    -- ["॥"] = "॥", ["।"] = "।",
	    
	    -- ["ᳵ"] = "", ["ᳶ"] = "",
    	
    	["*"] = "*",
	},
	["Gunj"] = {
		["क"] = "କ", ["ख"] = "ଖ", ["ग"] = "ଗ", ["घ"] = "ଘ", ["ङ"] = "ଙ", 
		["च"] = "ଚ", ["छ"] = "ଛ", ["ज"] = "ଜ", ["झ"] = "ଝ", ["ञ"] = "ଞ", 
		["ट"] = "ଟ", ["ठ"] = "ଠ", ["ड"] = "ଡ", ["ढ"] = "ଢ", ["ण"] = "ଣ", 
		["त"] = "ତ", ["थ"] = "ଥ", ["द"] = "ଦ", ["ध"] = "ଧ", ["न"] = "ନ", 
		["प"] = "ପ", ["फ"] = "ଫ", ["ब"] = "ବ", ["भ"] = "ଭ", ["म"] = "ମ", 
		["य"] = "ଯ", ["र"] = "ର", ["ल"] = "ଲ", ["व"] = "ଵ", ["ळ"] = "ଳ", 
		["श"] = "ଶ", ["ष"] ="ଷ", ["स"] = "ସ", ["ह"] = "ହ",
	
		["अ"] = "𑵠", ["आ"] = "𑵡", ["इ"] = "𑵢", ["ई"] = "𑵣", ["उ"] = "𑵤", ["ऊ"] = "𑵥", 
		["ए"] = "𑵧", ["ऐ"] = "𑵨", ["ओ"] = "ଓ", ["औ"] = "ଔ",
		
		["ा"] = "ା", ["ि"] = "ି", ["ी"] = "ୀ", ["ु"] = "ୁ", ["ू"] = "ୂ", ["ृ"] = "ୃ", ["ॄ"] = "ୄ", 
		["ॢ"] = "ୢ", ["ॣ"] = "ୣ", ["े"] = "େ", ["ै"] = "ୈ", ["ो"] = "ୋ", ["ौ"] = "ୌ",  ["्"] = "୍",
	
		["ँ"] = "ଁ", ["ं"] = "ଂ", ["ः"] = "ଃ", ["ऽ"] = "ଽ",

		["०"] = "୦", ["१"] = "୧", ["२"] = "୨", ["३"] = "୩", ["४"] = "୪", ["५"] = "୫", ["६"] = "୬", ["७"] = "୭", ["८"] = "୮", ["९"] = "୯",
	        
	    ["॥"] = "॥", ["।"] = "।",
	    
	    -- ["ᳵ"] = "ᳵ", ["ᳶ"] = "ᳶ",
    
		["ॐ"] = "ଓମ୍",
    	
    	["*"] = "*",
	},
	["Telu"] = {
		["क"] = "క", ["ख"] = "ఖ", ["ग"] = "గ", ["घ"] = "ఘ", ["ङ"] = "ఙ", 
		["च"] = "చ", ["छ"] = "ఛ", ["ज"] = "జ", ["झ"] = "ఝ", ["ञ"] = "ఞ", 
		["ट"] = "ట", ["ठ"] = "ఠ", ["ड"] = "డ", ["ढ"] = "ఢ", ["ण"] = "ణ", 
		["त"] = "త", ["थ"] = "థ", ["द"] = "ద", ["ध"] = "ధ", ["न"] = "న", 
		["प"] = "ప", ["फ"] = "ఫ", ["ब"] = "బ", ["भ"] = "భ", ["म"] = "మ", 
		["य"] = "య", ["र"] = "ర", ["ल"] = "ల", ["व"] = "వ", ["ळ"] = "ళ", 
		["श"] = "శ", ["ष"] ="ష", ["स"] = "స", ["ह"] = "హ",
	
		["अ"] = "అ", ["आ"] = "ఆ", ["इ"] = "ఇ", ["ई"] = "ఈ", ["उ"] = "ఉ", ["ऊ"] = "ఊ", ["ऋ"] = "ఋ", ["ॠ"] = "ౠ",
		["ऌ"] = "ఌ", ["ॡ"] = "ౡ", ["ए"] = "ఏ", ["ऐ"] = "ఐ", ["ओ"] = "ఓ", ["औ"] = "ఔ",
		
		["ा"] = "ా", ["ि"] = "ి", ["ी"] = "ీ", ["ु"] = "ు", ["ू"] = "ూ", ["ृ"] = "ృ", ["ॄ"] = "ౄ", 
		["ॢ"] = "ౢ", ["ॣ"] = "ౣ", ["े"] = "ే", ["ै"] = "ై", ["ो"] = "ో", ["ौ"] = "ౌ",  ["्"] = "్",
	
		["ँ"] = "ఀ", ["ं"] = "ం", ["ः"] = "ః", ["ऽ"] = "ఽ",

		["०"] = "౦", ["१"] = "౧", ["२"] = "౨", ["३"] = "౩", ["४"] = "౪", ["५"] = "౫", ["६"] = "౬", ["७"] = "౭", ["८"] = "౮", ["९"] = "౯",
	        
	    ["॥"] = "॥", ["।"] = "।",
	    
	    -- ["ᳵ"] = "", ["ᳶ"] = "",
    
		["ॐ"] = "ఓం",
    	
    	["*"] = "*",
	},
	["Orya"] = {
		["क"] = "କ", ["ख"] = "ଖ", ["ग"] = "ଗ", ["घ"] = "ଘ", ["ङ"] = "ଙ", 
		["च"] = "ଚ", ["छ"] = "ଛ", ["ज"] = "ଜ", ["झ"] = "ଝ", ["ञ"] = "ଞ", 
		["ट"] = "ଟ", ["ठ"] = "ଠ", ["ड"] = "ଡ", ["ढ"] = "ଢ", ["ण"] = "ଣ", 
		["त"] = "ତ", ["थ"] = "ଥ", ["द"] = "ଦ", ["ध"] = "ଧ", ["न"] = "ନ", 
		["प"] = "ପ", ["फ"] = "ଫ", ["ब"] = "ବ", ["भ"] = "ଭ", ["म"] = "ମ", 
		["य"] = "ଯ", ["र"] = "ର", ["ल"] = "ଲ", ["व"] = "ଵ", ["ळ"] = "ଳ", 
		["श"] = "ଶ", ["ष"] ="ଷ", ["स"] = "ସ", ["ह"] = "ହ",
	
		["अ"] = "ଅ", ["आ"] = "ଆ", ["इ"] = "ଇ", ["ई"] = "ଈ", ["उ"] = "ଉ", ["ऊ"] = "ଊ", ["ऋ"] = "ଋ", ["ॠ"] = "ୠ",
		["ऌ"] = "ଌ", ["ॡ"] = "ୡ", ["ए"] = "ଏ", ["ऐ"] = "ଐ", ["ओ"] = "ଓ", ["औ"] = "ଔ",
		
		["ा"] = "ା", ["ि"] = "ି", ["ी"] = "ୀ", ["ु"] = "ୁ", ["ू"] = "ୂ", ["ृ"] = "ୃ", ["ॄ"] = "ୄ", 
		["ॢ"] = "ୢ", ["ॣ"] = "ୣ", ["े"] = "େ", ["ै"] = "ୈ", ["ो"] = "ୋ", ["ौ"] = "ୌ",  ["्"] = "୍",
	
		["ँ"] = "ଁ", ["ं"] = "ଂ", ["ः"] = "ଃ", ["ऽ"] = "ଽ",

		["०"] = "୦", ["१"] = "୧", ["२"] = "୨", ["३"] = "୩", ["४"] = "୪", ["५"] = "୫", ["६"] = "୬", ["७"] = "୭", ["८"] = "୮", ["९"] = "୯",
	        
	    ["॥"] = "॥", ["।"] = "।",
	    
	    -- ["ᳵ"] = "ᳵ", ["ᳶ"] = "ᳶ",
    
		["ॐ"] = "ଓମ୍",
    	
    	["*"] = "*",
	}
}

local function return_error(text)
	return error(("Unrecognised part: \"%s\""):format(text))
end

function export.tr(text, script)
	if type(text) == "table" then
		text, script = text.args[1], text.args[2]
	end
	text = mw.ustring.lower(text)
	if not conv[script] then return "" end
	text = gsub(text, ".",
		function(c)
			return conv[script][c] or c
		end)

	if post_replace_fix[script] then
		for _, data in ipairs(post_replace_fix[script]) do
			text = gsub(text, data[1], data[2])
		end
	end
	
	return text
end
 
return export