Module:bho-Kthi-translit

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

This module will transliterate Bhojpuri language text. It is also used to transliterate Angika, Magahi, Maithili, and Sadri. 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:bho-Kthi-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 Bhojpuri

local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match

local conv = {
	-- consonants
	 = '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',
	 = 'ṛ',  = 'ṛ',  = 'ṛh',  = 'ṛh',
	--  = 'gy',

	-- vowel diacritics
	 = 'i',  = 'u',  = 'e',  = 'o', 
	 = 'ā',  = 'ī',  = 'ū', 
	 = 'ai',  = 'au',

	-- vowel signs
	 = 'a',  = 'i',  = 'u',  = 'e',  = 'o',
	 = 'ā',  = 'ī',  = 'ū',  
	 = 'ai',  = 'au', 
	
	 = 'om',
	
	-- chandrabindu
	 = '̃',
	
	-- anusvara
	 = 'ṁ',
	
	-- visarga
	 = 'ḥ',
	
	-- virama
	 = '',
	
	-- numerals
	 = '0',  = '1',  = '2',  = '3',  = '4',
	 = '5',  = '6',  = '7',  = '8',  = '9',
	
	-- punctuation
	 = '.', -- danda
	 = '.', -- double danda
	 = '', -- compound separator
	
	-- abbreviation sign
	 = '.',
}

local nasal_assim = {
	 = '𑂑',  = '𑂑',  = '𑂑',  = '𑂑',
	 = '𑂖',  = '𑂖',  = '𑂖',  = '𑂖',
	 = '𑂝',  = '𑂝',  = '𑂝',  = '𑂝',
	 = '𑂧',  = '𑂧',  = '𑂧',  = '𑂧',  = '𑂧',
}

local perm_cl = {
	 = true,  = true,  = true,  = true,
	
}

local all_cons, special_cons = '𑂍𑂎𑂏𑂐𑂑𑂒𑂓𑂔𑂕𑂖𑂗𑂘𑂙𑂚𑂛𑂜𑂞𑂟𑂠𑂡𑂣𑂤𑂥𑂦𑂬𑂭𑂮𑂨𑂩𑂪𑂫𑂯𑂝𑂢𑂧', '𑂨𑂩𑂪𑂥𑂫𑂯𑂢𑂧'
local vowel, vowel_sign = 'a𑂰𑂱𑂲𑂳𑂴𑂵𑂶𑂷𑂸', '𑂃𑂄𑂅𑂆𑂇𑂈𑂉𑂊𑂋𑂌'
local syncope_pattern = '()(𑂺?)a(𑂺?)(?)'

local function rev_string(text)
	local result, length = {}, mw.ustring.len(text)
	for i = 1, length do
		table.insert(result, mw.ustring.sub(text, length - i + 1, length - i + 1))
	end
	return table.concat(result)
end

function export.tr(text, lang, sc)
	text = gsub(
		text,
		'(𑂺?)(?)',
		function(c, d)
			return c .. (d == "" and 'a' or d)
		end
	)

	for word in mw.ustring.gmatch(text, "+") do
		local orig_word = word
		
		word = rev_string(word)
		
		word = gsub(
			word,
			'^a(𑂺?)()(.)(.?)',
			function(opt, first, second, third)
				local a = ""
				if match(first, '')
					and match(second, '𑂹')
					and not perm_cl
					or match(first .. second, '𑂨') then
						a = "a"
				end
				
				return a .. opt .. first .. second .. third
			end
		)
		
		while match(word, syncope_pattern) do
			word = gsub(word, syncope_pattern, '%1%2%3%4')
		end
		
		word = gsub(
			word,
			'(.?)𑂁(.)',
			function(succ, prev)
				local mid = nasal_assim or "n"
				if succ..prev == "a" then
					mid = "𑂺𑂧" 
				elseif succ == "" and match(prev, '') then
					mid = "̃" 
				end
				return succ .. mid .. prev
			end
		)
		
		text = gsub(text, orig_word, rev_string(word))
	end
	text = gsub(text, '.𑂺?', conv)
	text = gsub(text, 'a()̃', 'a͠%1')
    text = gsub(text, '𑂔𑂹𑂖', conv)
    text = gsub(text, '%*', 'a')

	return mw.ustring.toNFC(text)
end

return export