This module will transliterate Sylheti language text per WT:SYL TR.
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:syl-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.-- Transliteration for Sylheti in Sylheti Nagri script
local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local conv = {
-- consonants
= 'x', = 'x', = 'g', = 'g',
= 's', = 's', = 'z', = 'z',
= 'ṭ', = 'ṭ', = 'ḍ', = 'ḍ',
= 't', = 't', = 'd', = 'd', = 'n',
= 'f', = 'f', = 'b', = 'b', = 'm',
= 'r', = 'l', = 'ṛ',
= 'ś', = 'h', = 'ṅ',
-- vowel diacritics
= 'a', = 'i', = 'u', = 'e', = 'o',
-- vowel signs
= 'a', = 'i', = 'u', = 'e', = 'o',
-- virama
= '',
-- anusvar
= 'ṅ',
-- dvisvara
= 'i',
-- numerals
]'] = '0',
]'] = '1',
]'] = '2',
]'] = '3',
]'] = '4',
]'] = '5',
]'] = '6',
]'] = '7',
]'] = '8',
]'] = '9' ,
-- punctuation
= ',',
= ',',
= ':',
= '.',
= ';',
= '.'
}
local aspirates = "ꠈꠊꠍꠏꠑꠓꠕꠗꠚꠜ"
local consonant, vowel, vowel_sign = "ꠇ-ꠊꠌ-ꠢ", "ꠣ-ꠧ", "ꠀꠁꠃ-ꠅ"
local c = ""
local v = ""
local syncope_pattern = "(" .. v .. c .. v .. c .. ")ô(" .. c .. "ঁ?" .. v .. ")"
local function rev_string(text)
local result, length = "", mw.ustring.len(text)
for i = 1, length do
result = result .. mw.ustring.sub(text, -i, -i)
end
return result
end
function export.tr(text, lang, sc)
-- from ]
text = gsub(text, "(" .. c .. ")(?)", function(a, b)
local res = a .. (b == "" and "ô" or b)
if match(a, "") then res = res .. "’" end
return res end)
for word in mw.ustring.gmatch(text, "+") do
local orig_word = word
word = rev_string(word)
word = gsub(word, "^ô(" .. c .. ")(" .. v .. ")", "%1%2")
while match(word, syncope_pattern) do
word = gsub(word, syncope_pattern, "%1%2")
end
text = gsub(text, orig_word, rev_string(word))
end
text = gsub(text, ".", conv)
-- ô is really just o
text = mw.ustring.gsub(text, 'ô', 'o')
-- velars
text = mw.ustring.gsub(text, 'x()', 'k%1')
text = mw.ustring.gsub(text, '()x', '%1k')
text = mw.ustring.gsub(text, 'xx', 'kk')
-- palatals (I think?)
text = mw.ustring.gsub(text, 'ss', 'cc')
-- affricates (I'm just guessing now)
text = mw.ustring.gsub(text, 'jj', 'zz')
text = mw.ustring.gsub(text, 'zs', 'jc')
-- final r/l
text = mw.ustring.gsub(text, '()o$', '%1')
text = mw.ustring.gsub(text, '()o ', '%1 ')
-- tone
text = gsub(text, '’', '́')
return text
end
return export