မဝ်ဂျူ:ta-translit
မံက်ပြာကတ်
မဝ်ဂျူတဏအ်မစွံလဝ်ပရေၚ်ကၠာဲမလိက်တမဳလ်. It is also used to transliterate အဳရုလာ, ကိုဝ်တာ (အိန္ဒိယ), မာန်နာန်, and ဗေတ်တာ ကူရုန်ဗါ.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{xlit}}.
Within a module, use Module:languages#Language:transliterate.
For testcases, see မဝ်ဂျူ:ta-translit/testcases.
Functions
tr(text, lang, sc)- Transliterates a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. - When the transliteration fails, returns
nil.
local export = {}
local consonants = {
['க']='k' , ['ங']='ṅ' , ['ச']='c' , ['ஞ']='ñ' , ['ட']='ṭ' , ['ண']='ṇ' , ['த']='t' ,
['ந']='n' , ['ப']='p', ['ம']='m' , ['ய']='y' , ['ர']='r' , ['ல']='l' , ['வ']='v' ,
['ழ']='ḻ' , ['ள']='ḷ' , ['ற']='ṟ' , ['ன']='ṉ' , ['ஶ']='ś' , ['ஜ']='j' , ['ஷ']='ṣ' ,
['ஸ']='s' , ['ஹ']='h' , ['ஃப']='f' , ['ஃஜ']='z' , ['ஃஸ']='x' ,
['ஃ']='ḥ' ,
}
local diacritics = {
['ா']= 'ā' , ['ி']='i' , ['ீ']='ī' , ['ு']='u' , ['ூ']='ū' , ['ெ']='e' ,
['ே']='ē' , ['ை']='ai' , ['ொ']='o' , ['ோ']='ō' , ['ௌ']='au' ,
['்']='', --halant, supresses the inherent vowel "a"
-- no diacritic
[''] = 'a'
}
local nonconsonants = {
-- vowels
['அ']='’a' , ['ஆ']='’ā' , ['இ']='’i' , ['ஈ']='’ī' , ['உ']='’u' , ['ஊ']='’ū' ,
['எ']='’e' , ['ஏ']='’ē' , ['ஐ']='’ai' , ['ஒ']='’o' , ['ஓ']='’ō' , ['ஔ']='’au' ,
-- other symbols
-- ['ஃ']='' ,
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'(ஃ?)([க-ஹ])([ா-்]?)',
function(h, c, d)
return (consonants[h..c] or consonants[h] .. (consonants[c] or c)) .. diacritics[d]
end)
text = mw.ustring.gsub(text, '[அ-ஔ]', nonconsonants)
text = mw.ustring.gsub(text, '^’', '')
text = mw.ustring.gsub(text, '([%s%p])’', '%1')
return text
end
return export