Module:ta-translit: difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
DerekWinters (talk | contribs) No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
['எ']='e' , ['ஏ']='ē' , ['ஐ']='ai' , ['ஒ']='o' , ['ஓ']='ō' , ['ஔ']='au' , |
['எ']='e' , ['ஏ']='ē' , ['ஐ']='ai' , ['ஒ']='o' , ['ஓ']='ō' , ['ஔ']='au' , |
||
-- other symbols |
-- other symbols |
||
['்']='' |
['்']='', --halant, supresses the inherent vowel "a" |
||
-- ['ஃ']='' , |
|||
} |
} |
||
Line 29: | Line 30: | ||
function(c, d) |
function(c, d) |
||
mw.log('match', c, d) |
mw.log('match', c, d) |
||
-- this was an attempt to avoid error messages |
|||
-- if not c then c = "" |
|||
-- end |
|||
-- if not d then d = "" |
|||
-- end |
|||
if d == "" then |
if d == "" then |
||
return consonants[c] .. 'a' |
return consonants[c] .. 'a' |
||
Line 36: | Line 43: | ||
end) |
end) |
||
-- text = mw.ustring.gsub(text, 'ஃப', 'f') |
|||
-- text = mw.ustring.gsub(text, 'ஃஜ', 'z') |
|||
-- text = mw.ustring.gsub(text, 'ஃஸ', 'x') |
|||
text = mw.ustring.gsub(text, '.', nonconsonants) |
text = mw.ustring.gsub(text, '.', nonconsonants) |
||
Revision as of 02:58, 31 January 2014
- The following documentation is located at Module:ta-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Tamil language text. It is also used to transliterate Irula, Kota (India), and Mannan.
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 Module:ta-translit/testcases.
Functions
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, 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' ,
}
local nonconsonants = {
-- vowels
['அ']='a' , ['ஆ']='ā' , ['இ']='i' , ['ஈ']='ī' , ['உ']='u' , ['ஊ']='ū' ,
['எ']='e' , ['ஏ']='ē' , ['ஐ']='ai' , ['ஒ']='o' , ['ஓ']='ō' , ['ஔ']='au' ,
-- other symbols
['்']='', --halant, supresses the inherent vowel "a"
-- ['ஃ']='' ,
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([கஙசஞடணதநபமயரலவழளறனஶஜஷஸஹஃபஃஜஃஸ])'..
'([ாிீுூெேைொோௌ்]?)',
function(c, d)
mw.log('match', c, d)
-- this was an attempt to avoid error messages
-- if not c then c = ""
-- end
-- if not d then d = ""
-- end
if d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. (diacritics[d] or d)
end
end)
-- text = mw.ustring.gsub(text, 'ஃப', 'f')
-- text = mw.ustring.gsub(text, 'ஃஜ', 'z')
-- text = mw.ustring.gsub(text, 'ஃஸ', 'x')
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export