模組:Ta-translit
這個模組會將泰米爾語未確定的文字拉丁化。
最好不要直接從模板或其他模組調用此模組。要從模板中使用它,請以{{xlit}}
做為替代;若要在模組中使用,則以Module:languages#Language:transliterate替代。
關於測試用例,請參閱Module:Ta-translit/testcases。
函數
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. When the transliteration fails, returnsnil
.
-- Transliteration for Tamil 泰米爾語轉譯
local export = {}
local consonants = {
['க']='k' , ['ங']='ṅ' , ['ச']='c' , ['ஞ']='ñ' , ['ட']='ṭ' , ['ண']='ṇ' , ['த']='t' ,
['ந']='n' , ['ப']='p', ['ம']='m' , ['ய']='y' , ['ர']='r' , ['ல']='l' , ['வ']='v' ,
['ழ']='ḻ' , ['ள']='ḷ' , ['ற']='ṟ' , ['ன']='ṉ' , ['ஶ']='ś' , ['ஜ']='j' , ['ஷ']='ṣ' ,
['ஸ']='s' , ['ஹ']='h' , ['ஃப']='f' , ['ஃஜ']='z' , ['ஃஸ']='x' ,
['ஃ']='ḥ' , ['ௐ']='о̄m',
}
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' , ['ௐ']='о̄m',
-- other symbols
-- ['ஃ']='' , ['ௐ']='о̄m',
}
-- 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