Module:sa-Modi-translit
Jump to navigation
Jump to search
- The following documentation is generated by Module:documentation/functions/translit. [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-Modi-translit/testcases.
Functions
[edit]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', ['๐']='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',
-- 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
['แณต']='x', ['แณถ']='f',
--Om
['๐๐ฆ๐ฟ']='oแน',
--reconstructed
['*'] = '',
}
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ ๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ฌ๐ญ๐ฎ๐ฏ])'..
'([๐ฐ๐ฑ๐ฒ๐ณ๐ด๐ต๐ถ๐ท๐ธ๐น๐บ๐ป๐ผ๐ฟ]?)',
function(c, d)
if d == "" then
return consonants[c] .. 'a'
else
return consonants[c] .. diacritics[d]
end
end)
text = mw.ustring.gsub(text, '.', tt)
return text
end
return export