This module will transliterate text in the Limbu script.
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:Limb-Deva-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local gsub = mw.ustring.gsub
local consonants = {
='क', ='ख', ='ग', ='घ', ='ङ',
='च', ='छ', ='ज', ='झ', ='ञ',
='त', ='थ', ='द', ='ध', ='न',
='प', ='फ', ='ब', ='भ', ='म',
='य', ='र', ='ल', ='व',
='श', ='ष', ='स', ='ह',
='ज्ञ', ='त्र', ='अ',
}
local diacritics = {
='ा' , ='ि' , ='ु' , ='े' , ='ै' , ='ो' , ='ौ' , ='े़' , ='ो़'
}
--='ॅ' , --='',
local special = {
='ॽ', --mukphreng (glottalizer)
= 'ं' --anusvara (now obsolete)
}
local subjoined = {
='्र', ='्व', ='्य',
}
local finals = {
='क्', ='ङ्', ='त्', ='न्', ='प्', ='म्', ='र्', ='ल्',
}
local nonconsonants = {
-- digits
= '०', = '१', = '२', = '३', = '४',
= '५', = '६', = '७', = '८', = '९',
='॥', ='!', ='?', =',',
='लो'
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(text, '()᤻', '᤺%1') -- treat underscore as kemphreng
text = mw.ustring.gsub(
text,
'()'..
'(?)'..
'(?)'..
'(?)'..
'(?)',
function(c, d, e, f, g)
-- mw.log('match', c, d)
return (consonants or c) ..
(subjoined or d) ..
(diacritics or (e ~= "") and e or '') ..
(special or f) ..
(finals or g)
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
text = mw.ustring.gsub(text, '(.)⌫', '')
text = gsub(text, 'ाᤣ', 'ो')
text = gsub(text, 'ᤣᤣ', 'ै')
text = gsub(text, 'ाᤣᤣ', 'ौ')
text = gsub(text, 'ाःᤣ', 'ओः')
text = mw.ustring.gsub(text, '᤺', 'ः')
--text = mw.ustring.gsub(text, 'िः', 'ी')
--text = mw.ustring.gsub(text, 'ुः', 'ू')
text = mw.ustring.gsub(text, 'ᤰ', 'क्')
text = mw.ustring.gsub(text, 'ᤱ', 'ङ्')
text = mw.ustring.gsub(text, 'ᤳ', 'त्')
text = mw.ustring.gsub(text, 'ᤴ', 'न्')
text = mw.ustring.gsub(text, 'ᤵ', 'प्')
text = mw.ustring.gsub(text, 'ᤶ', 'म्')
text = mw.ustring.gsub(text, 'ᤷ', 'र्')
text = mw.ustring.gsub(text, 'ᤸ', 'ल्')
text = mw.ustring.gsub(text, "अा", "आ")
text = mw.ustring.gsub(text, "अि", "इ")
text = mw.ustring.gsub(text, "अी", "ई")
text = mw.ustring.gsub(text, "अु", "उ")
text = mw.ustring.gsub(text, "अू", "ऊ")
text = mw.ustring.gsub(text, "अे", "ए")
text = mw.ustring.gsub(text, "अै", "ऐ")
text = mw.ustring.gsub(text, "अो", "ओ")
text = mw.ustring.gsub(text, "अौ", "औ")
text = mw.ustring.gsub(text, "अॅ", "ऍ")
text = mw.ustring.gsub(text, "अे़", "ए़")
text = mw.ustring.gsub(text, "अो़", "ओ़")
text = gsub(text, 'ाःᤣ', 'ोः')
text = mw.ustring.gsub(text, 'ाःᤣ', 'ोः')
return mw.ustring.toNFC(text)
end
return export