Module:syl-translit

Hello, you have come here looking for the meaning of the word Module:syl-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:syl-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:syl-translit in singular and plural. Everything you need to know about the word Module:syl-translit you have here. The definition of the word Module:syl-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:syl-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

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.

Functions

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns 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