मॉड्यूल:sa-translit
साँचा:translit module documentation
local export = {}
local consonants = {
['क']='क', ['ख']='कह', ['ग']='ग', ['घ']='घ', ['ङ']='ङ',
['च']='स', ['छ']='च', ['ज']='ज', ['झ']='झ', ['ञ']='ञ',
['ट']='ट', ['ठ']='ठह', ['ड']='ड', ['ढ']='ढ', ['ण']='ण',
['त']='टी', ['थ']='तह', ['द']='डी', ['ध']='ध', ['न']='न',
['प']='प', ['फ']='फ', ['ब']='ब', ['भ']='बह', ['म']='म',
['य']='य', ['र']='र', ['ल']='ल', ['व']='व्', ['ळ']='ळ',
['श']='श', ['ष']='ष', ['स']='स', ['ह']='ह',
}
local diacritics = {
['ा']='ा', ['ि']='ि', ['ी']='ी', ['ु']='ु', ['ू']='ू', ['ृ']='ृ', ['ॄ']='ॄ',
['ॢ']='ॢ', ['ॣ']='ॣ', ['े']='े', ['ै']='ै', ['ो']='ो', ['ौ']='ौ', ['्']='्',
}
local tt = {
-- vowels
['अ']='ा', ['आ']='आ', ['इ']='इ', ['ई']='ई', ['उ']='उ', ['ऊ']='ऊ', ['ऋ']='ऋ', ['ॠ']='ॠ',
['ऌ']='ऌ', ['ॡ']='ॡ', ['ए']='इ', ['ऐ']='ऐ', ['ओ']='ओ', ['औ']='औ',
-- chandrabindu
['ँ']='ँ', --until a better method is found
-- anusvara
['ं']='ं', --until a better method is found
-- visarga
['ः']='ः',
-- avagraha
['ऽ']='’',
--numerals
['०']='०', ['१']='१', ['२']='२', ['३']='३', ['४']='४', ['५']='५', ['६']='६', ['७']='७', ['८']='८', ['९']='९',
--punctuation
['॥']='॥', --double danda
['।']='।', --danda
--Vedic extensions
['ᳵ']='x', ['ᳶ']='f',
--Om
['ॐ']='ॐ',
--reconstructed
['*'] = '',
}
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([कखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसह])'..
'([ािीुूृॄॢॣेैोौ्]?)',
function(c, d)
if d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. diacritics[d]
end
end)
text = mw.ustring.gsub(text, '.', tt)
return text
end
return export