Module:tcy-Tutg-translit
Documentation for this module may be created at Module:tcy-Tutg-translit/doc
local export = {}
local gsub = mw.ustring.gsub
local consonants = {
['๐'] = 'k', ['๐'] = 'kh', ['๐'] = 'g', ['๐'] = 'gh', ['๐']='แน
',
['๐'] = 'c', ['๐'] = 'ch', ['๐'] = 'j', ['๐'] = 'jh', ['๐']='รฑ',
['๐'] = 'แนญ', ['๐'] = 'แนญh', ['๐'] = 'แธ', ['๐'] = 'แธh', ['๐ ']='แน',
['๐ก'] = 't', ['๐ข'] = 'th', ['๐ฃ'] = 'd', ['๐ค'] = 'dh', ['๐ฅ']='n',
['๐ฆ'] = 'p', ['๐ง'] = 'ph', ['๐จ'] = 'b', ['๐ฉ'] = 'bh' , ['๐ช']='m',
['๐ซ'] = 'y', ['๐ฌ'] = 'r', ['๐'] = 'r', ['๐ญ'] = 'l', ['๐ณ'] = 'แธท', ['๐ฎ'] = 'v', ['๐ฏ'] = 'ล', ['๐ฐ'] = 'แนฃ', ['๐ฑ'] = 's', ['๐ฒ'] = 'h',
}
local diacritics = {
['๐ธ'] = 'ฤ', ['๐น'] = 'i', ['๐บ'] = 'ฤซ',['๐ป'] = 'u', ['๐ผ'] = 'ลซ',
['๐ฝ'] = 'rฬฅ', ['๐พ'] ='rฬฅฬ', ['๐ฟ'] ='lฬฅ', ['๐'] = 'lฬฅฬ', ['๐'] = 'ฤ', ['๐
'] = 'ai', ['๐'] = 'ล', ['๐'] = 'au', ['๐'] = '', ['๐'] = '',
}
local tt = {
-- vowels
['๐'] = 'a', ['๐'] ='ฤ' , ['๐'] ='i' , ['๐'] = 'ฤซ' , ['๐'] = 'u' , ['๐
'] = 'ลซ' ,
['๐'] = 'rฬฅ', ['๐'] ='rฬฅฬ', ['๐'] ='lฬฅ', ['๐'] = 'lฬฅฬ', ['๐'] = 'ฤ', ['๐'] ='ai', ['๐'] ='ล', ['๐'] = 'au',
-- other symbols
['๐ท'] = 'แน',-- avagraha
['๐'] = 'แน',-- anusvara
['๐'] = 'แธฅ' , -- visarga
['๐'] = 'ลm' , -- om
}
-- translit any words or phrases
function export.tr(text, lang, sc)
local VIRAMA = '๐'
-- final virama rules
if lang == "tcy" then
text = gsub(text, VIRAMA .. "([%,%.%!%?%:%;]?)$", VIRAMA .. "ลญ%1")
text = gsub(text, VIRAMA .. "([%,%.%!%?%:%;]?) ", VIRAMA .. "ลญ%1 ")
end
text = gsub(
text,
'([๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ ๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ฌ๐ญ๐ฎ๐ฏ๐ฐ๐ฑ๐ฒ๐ณ๐ด])'..
'([๐ธ๐น๐บ๐ป๐ผ๐ฝ๐พ๐ฟ๐๐๐
๐๐๐๐]?)',
function(c, d)
if d == "" then
return consonants[c] ..'a'
else
return consonants[c] .. diacritics[d]
end
end)
text = gsub(text,'.', tt)
-- anusvara
text = gsub(text,'แน([kgแน
])','แน
%1')
text = gsub(text,'แน([cjรฑ])','รฑ%1')
text = gsub(text,'แน([แนญแธแน])','แน%1')
text = gsub(text,'แน([tdn])','n%1')
text = gsub(text,'แน([pbm])','m%1')
return text
end
return export