Module:sa-Telu-translit
- The following documentation is located at Module:sa-Telu-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Sanskrit language text per WT:SA TR.
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:sa-Telu-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
.
Testcases
editModule:sa-Telu-translit/testcases:
All tests passed. (refresh)
Text | Expected | Actual | Comments | |
---|---|---|---|---|
వాక్ | vāk | vāk | ||
వాక | vāka | vāka | ||
అదృష్ట | adṛṣṭa | adṛṣṭa | ||
సోఽహమ్ | so’ham | so’ham | ||
దుఃఖ | duḥkha | duḥkha | ||
నీళ | nīḷa | nīḷa | ||
ౝ | n | n |
local gsub = mw.ustring.gsub
local export = {}
local consonants = {
['క']='k', ['ఖ']='kh', ['గ']='g', ['ఘ']='gh', ['ఙ']='ṅ',
['చ']='c', ['ఛ']='ch', ['జ']='j', ['ఝ']='jh', ['ఞ']='ñ',
['ట']='ṭ', ['ఠ']='ṭh', ['డ']='ḍ', ['ఢ']='ḍh', ['ణ']='ṇ',
['త']='t', ['థ']='th', ['ద']='d', ['ధ']='dh', ['న']='n',
['ప']='p', ['ఫ']='ph', ['బ']='b', ['భ']='bh', ['మ']='m',
['య']='y', ['ర']='r', ['ల']='l', ['వ']='v', ['ళ']='ḷ',
['శ']='ś', ['ష']='ṣ', ['స']='s', ['హ']='h',
}
local diacritics = {
['ా']='ā', ['ి']='i', ['ీ']='ī', ['ు']='u', ['ూ']='ū', ['ృ']='ṛ', ['ౄ']='ṝ',
['ౢ']='ḷ', ['ౣ']='ḹ', ['ే']='e', ['ై']='ai', ['ో']='o', ['ౌ']='au', ['్']='',
}
local tt = {
-- vowels
['అ']='a', ['ఆ']='ā', ['ఇ']='i', ['ఈ']='ī', ['ఉ']='u', ['ఊ']='ū', ['ఋ']='ṛ', ['ౠ']='ṝ',
['ఌ']='ḷ', ['ౡ']='ḹ', ['ఏ']='e', ['ఐ']='ai', ['ఓ']='o', ['ఔ']='au',
-- Nakaara Pollu
['ౝ']='n',
-- chandrabindu
['ఁ']='m̐', --until a better method is found
-- anusvara
['ం']='ṃ', --until a better method is found
-- visarga
['ః']='ḥ',
-- avagraha
['ఽ']='’',
--numerals
['౦']='0', ['౧']='1', ['౨']='2', ['౩']='3', ['౪']='4', ['౫']='5', ['౬']='6', ['౭']='7', ['౮']='8', ['౯']='9',
--punctuation
['॥']='.', --double danda
['।']='.', --danda
--Vedic extensions
-- ["ᳵ"] = "ᳵ", ["ᳶ"] = "ᳶ",
--Om
['ఓం']='oṃ',
--reconstructed
['*'] = '',
}
function export.tr(text, lang, sc)
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)
return text
end
return export