Module:Modi-translit
Appearance
- The following documentation is located at Module:Modi-translit/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Modi script. It is used to transliterate Old Marathi.
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:Modi-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', ['𑘏']='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',
-- virama
['𑘿'] = '',
}
local tt = {
-- vowel signs
['𑘀'] = 'a', ['𑘂'] = 'i', ['𑘄'] = 'u', ['𑘊'] = 'e', ['𑘌'] = 'o',
['𑘁'] = 'ā', ['𑘃'] = 'ī', ['𑘅'] = 'ū',
['𑘆'] = 'ŕ',
['𑘋'] = 'ai', ['𑘍'] = 'au',
['𑘁𑙀'] = 'ŏ',
['𑘀𑙀'] = 'ĕ', ['𑘊𑙀'] = 'ĕ',
-- anusvara
['𑘽'] = 'ṃ',
-- visarga
['𑘾'] = 'ḥ',
-- numerals
['𑙐'] = '0', ['𑙑'] = '1', ['𑙒'] = '2', ['𑙓'] = '3', ['𑙔'] = '4', ['𑙕'] = '5', ['𑙖'] = '6', ['𑙗'] = '7', ['𑙘'] = '8', ['𑙙'] = '9',
--punctuation
['𑙁'] = '.', -- danda
['𑙂'] = '.', -- double danda
['+'] = '', -- compound separator
-- abbreviation sign
['𑙃'] = '.',
--Om
['ॐ']='oṃ',
}
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)
text = mw.ustring.gsub(text," ?[𑙁𑙂]",".")
return text
end
return export