Module:Mult-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:Mult-translit/documentation. [edit]
- Useful links: subpage list โข links โข transclusions โข testcases โข sandbox
This module will transliterate text in the Multani script. It is used to transliterate Saraiki.
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:Mult-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', ['๐']='รฑ',
['๐']='แนญ', ['๐']='แนญh', ['๐']='แธ', ['๐']='แธh', ['๐']='แน',
['๐']='t', ['๐']='th', ['๐']='d', ['๐']='dh', ['๐']='n',
['๐']='p', ['๐']='ph', ['๐']='b', ['๐']='bh', ['๐ ']='m',
['๐ก']='y', ['๐ข']='r', ['๐ฃ']='l', ['๐ค']='v',
['๐ฅ']='s', ['๐ฆ']='h',
['๐']='วฐ', ['๐']='แธ', ['๐ง'] = 'แน', ['๐จ'] = 'แนh',
}
local nonconsonants = {
-- vowels
['๐']='a', ['๐']='i', ['๐']='u', ['๐']='e',
-- other symbols
['๐ฉ']='.', -- section mark
-- digits
['เฉฆ'] = '0', ['เฉง'] = '1', ['เฉจ'] = '2', ['เฉฉ'] = '3', ['เฉช'] = '4',
['เฉซ'] = '5', ['เฉฌ'] = '6', ['เฉญ'] = '7', ['เฉฎ'] = '8', ['เฉฏ'] = '9',
}
-- 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