Module:brx-translit

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

This module will transliterate Bodo (India) language text. 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:brx-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.

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

local conv = {
	-- consonants
	 = 'k',  = 'g',  = 'ŋ', 
	 = 'z',  = 't',  = 'd',  = 'n',  = 'f',  = 'b',  = 'm', 
	 = 'y',  = 'r',  = 'l',  = 'o',  = 's',  = 'h',

	-- vowel diacritics
	 = 'i',  = 'u',  = 'e',  = 'w',
     = 'a',  = 'wi',  = 'wu',  = 'o',

	-- vowel signs
	 = 'o',  = 'i',  = 'u',  = 'e',  = 'w',
	 = 'a',  = 'wi',  = 'wu',  = 'o',
	
	 = 'om',
	
	-- chandrabindu
	 = 'ṅ',
	
	-- anusvara
	 = 'ŋ',
	
	-- visarga
	 = 'ḥ',
	
	-- virama
	 = '',
	
	-- numerals
	 = '0',  = '1',  = '2',  = '3',  = '4',
	 = '5',  = '6',  = '7',  = '8',  = '9',
	
	-- punctuation
	 = '.', -- danda
	 = '.', -- double danda
	 = '', -- compound separator
	
	-- abbreviation sign
	 = '.',
}

-- These clusters when occurring word-finally will not trigger a schwa added
-- after them even though the second consonant is in special_cons, which normally
-- causes the extra schwa to be added. NOTE: The clusters are reversed from their
-- ultimate effect, e.g. the first cluster is written 'ml' but actually applies
-- to words ending in 'lm'. The clusters below overall refer to the six clusters
-- describable by , i.e. rm, rn, rv, lm, ln, lv.
local perm_cl = {
	 = true,  = true,  = true,
	 = true,  = true,  = true,
}

local all_cons, special_cons = 'कखगघङचछजझञटठडढतथदधपफबभशषसयरलवहणनम', 'यरलवहनम'
local vowel, vowel_sign = '*िुेोाैौ’o\'', 'अइउएओआऐऔअ’\''
local long_vowel, short_vowel = 'ाैौआऐऔ', '*िुेो’अइउएओअ\''
local syncope_pattern = '()(़?)o(़?)(?)'

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

function export.tr(text, lang, sc)
	--abbreviation dot
	text = gsub(text, '॰', '.')
	text = gsub(text, '(़?)(?)', function(c, d)
		return c .. (d == "" and 'o' or d) end)
	for word in mw.ustring.gmatch(text, "+") do
		local orig_word = word
		word = rev_string(word)
		word = gsub(word, '^o(़?)()(.)(.?)', function(opt, first, second, third)
			return (((match(first, '') and match(second, '्') and not perm_cl)
				or match(first .. second, 'य'))
				and 'o' or "") .. opt .. first .. second .. third end)
		while match(word, syncope_pattern) do
			word = gsub(word, syncope_pattern, '%1%2%3%4')
		end
		word = rev_string(word)
		-- Convert * to %* so we can match it in a regex.
		local escaped_orig_word = gsub(orig_word, "%*", "%*")
		text = gsub(text, escaped_orig_word, word)
	end
	text = gsub(text, '.़?', conv)
    text = gsub(text, '%*', 'o')
	return mw.ustring.toNFC(text)
end

return export