This module will transliterate text in the Chakma script. It is used to transliterate Chakma and Pali.
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:Cakm-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 u = require("Module:string/char")
-- Stage 1: IAST-style
local consonants = {
--consonants
-- 'ⓨ' is a convenience for language specific modifications.
='',
='k', ='kh', ='g', ='gh', ='ṅ',
='c', ='ch', ='j', ='jh', ='ñ',
='ṭ', ='ṭh', ='ḍ', ='ḍh', ='ṇ',
='t', ='th', ='d', ='dh', ='n',
='p', ='ph', ='b', ='bh', ='m',
='y', ='ⓨ', ='r', ='l', ='v', ='v',
-- ='ś', ='ṣ',
='s', ='h', ='ḷ',
}
local diacritics = {
--matras
='ā', ='i', ='ī', ='u', ='ū',
-- ='ṛ', ='ṝ', ='l̥', ='l̥̄',
='e', ='ai', ='o', ='au', ='', ='',
-- Oddities
='ă', ='oi', ='ei',
}
local tt = {
--vowels
='a', ='i', ='u', ='e',
-- chandrabindu
='m̐', --until a better method is found
-- anusvara
='ṃ', --until a better method is found
-- visarga
='ḥ',
--numerals
='0', ='1', ='2', ='3', ='4', ='5', ='6', ='7', ='8', ='9',
--punctuation
='.', --danda
='.', --double danda
='?', -- question mark
}
function export.tr(text, lang, sc)
if sc ~= "Cakm" then
return nil
end
text = mw.ustring.gsub(
text,
'()'.. -- consonant
'(?)'.. -- vowel, joiner or no vowel
'(?)', -- independent vowel
function(c, d, e)
if d == "" and e ~= "" then
if tt == "i" or tt == "u" then return consonants .. 'a' .. tt .. '̈'
else return consonants .. 'a' .. tt end
elseif e ~= "" then
return consonants .. diacritics .. tt
elseif d == "" then
return consonants .. 'a'
else
return consonants .. diacritics
end
end)
text = mw.ustring.gsub(text, '.', tt)
if (lang == 'ccp') then
text = mw.ustring.gsub(text, '.',
{
='a', ='ā', ='A',
-- ='ṅ',
='w',
='ẏ' ,='y',
})
text = mw.ustring.gsub(text, 'ṃ$', 'ṅ')
elseif (lang == 'pi') then
text = mw.ustring.gsub(text, 'aḥ', 'ā')
end
if (lang == 'sa' or lang == 'pi') and mw.ustring.match(text, 'l̥') then
text = mw.ustring.gsub(text, 'l̥', 'ḷ')
text = mw.ustring.toNFC(text)
end
return text
end
return export