Module:Mahj-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:Mahj-translit/documentation. [edit]
- Useful links: subpage list โข links โข transclusions โข testcases โข sandbox
This module will transliterate text in the Mahajani script. It is used to transliterate Marwari.
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:Mahj-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',
['๐
ญ']='r', ['๐
ฎ']='l', ['๐
ฏ']='v',
['๐
ฐ']='s', ['๐
ฑ']='h', ['๐
ฒ'] = 'แน',
}
local nonconsonants = {
-- vowels
['๐
']='a', ['๐
']='i', ['๐
']='u', ['๐
']='e', ['๐
']='o',
-- other symbols
['๐
ดโ']='.', -- abbreviation mark
['๐
ต']='ยง', -- section mark
['๐
ถ']='Shri', -- ligature [[เคถเฅเคฐเฅ]]
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([๐
๐
๐
๐
๐
๐
๐
๐
๐
๐
๐
๐
๐
ก๐
ข๐
ฃ๐
ค๐
ฅ๐
ฆ๐
ง๐
จ๐
ฉ๐
ช๐
ซ๐
ฌ๐
ญ๐
ฎ๐
ฏ๐
ฐ๐
ฑ๐
ฒ])'..
'([๐
ณ]?)',
function(c, d)
-- mw.log('match', c, d)
return (consonants[c] or c)
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export