Language code in page name (Diak) not recognized.


local export = {}
local u = mw.ustring.char

local consonants = {
--consonants
	['𑤌']='k', ['𑤍']='kh', ['𑤎']='g', ['𑤏']='gh', ['𑤏']='ṅ',
	['𑤑']='c', ['𑤒']='ch', ['𑤓']='j', ['𑤕']='ñ', 
	['𑤖']='ṭ', ['𑤘']='ḍ', ['𑤙']='ḍh', ['𑤚']='ṇ', 
	['𑤛']='t', ['𑤜']='th', ['𑤝']='d', ['𑤞']='dh', ['𑤟']='n', 
	['𑤠']='p', ['𑤡']='ph', ['𑤢']='b', ['𑤣']='bh', ['𑤤']='m',
	['𑤥']='y', ['𑤦']='ẏ', ['𑤧']='r', ['𑤨']='l', ['𑤩']='v', ['𑤮']='ḷ',
	['𑤪']='ś', ['𑤫']='ṣ', ['𑤬']='s', ['𑤭']='h', ['𑤯']='z', 
	['𑥀']='y', ['𑥂']='r', ['f']='f'
}

local diacritics = {
--matras
	['𑤰']='ā', ['𑤱']='i', ['𑤲']='ī', ['𑤳']='u', ['𑤴']='ū',
	['𑤵']='e', ['𑤷']='ai', ['𑤸']='o', 
--virama
	['𑤾'] = '',
--halant
	['𑤽'] = 'ᵘ',
}

local tt = {

--vowels
	['𑤀']='a', ['𑤁']='ā', ['𑤂']='i', ['𑤃']='ī', ['𑤄']='u', ['𑤅']='ū',  
	['𑤆']='e', ['𑤉']='o', ['𑤿']='ⁿ', ['𑥁']='r', 
	-- chandrabindu    
	['𑤼']='m̐', --until a better method is found
	-- anusvara    
	['𑤻']='ṃ', --until a better method is found
	--numerals
	['𑥐']='0', ['𑥑']='1', ['𑥒']='2', ['𑥓']='3', ['𑥔']='4', ['𑥕']='5', ['𑥖']='6', ['𑥗']='7', ['𑥘']='8', ['𑥙']='9',
	--punctuation        
    ['𑥄']='.', --double danda
    ['𑥅']='.', --gap filler
    ['𑥆']='.' --end of text mark
}

function export.tr(text, lang, sc)
	if sc ~= "Diak" then
		return nil
	end
	
	text = mw.ustring.gsub(text,'𑥀','𑤾𑥀') 
	text = mw.ustring.gsub(text,'𑥂','𑤾𑥂') 
	text = mw.ustring.gsub(text,'𑤠𑥃','f') 

	text = mw.ustring.gsub(
		text,
		'([f𑤌-𑤯𑥀𑥂])'..
		'([𑤰𑤱𑤲𑤳𑤴𑤵𑤷𑤸𑤽𑤾]?)',
		function(c, d)
			if d == "" then
				return consonants[c] .. 'a'
			else
     			return consonants[c] .. diacritics[d]
			end
		end)
		text = mw.ustring.gsub(text, '.[𑤾𑤽]?', tt)
		text = mw.ustring.gsub(text," ?[𑥄𑥅𑥆]",".")
		text = mw.ustring.gsub(text,"ⁿb","ᵐb")

	return text
end
 
return export