Module:sa-Brah-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-Brah-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