Module:as-translit

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

This module will transliterate Assamese language text per WT:AS TR. It is also used to transliterate Kamta. 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:as-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 Assamese

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

local conv = {
	-- consonants
	 = "kh",
	 = "k",	 = "kh",	 = "g",	 = "gh",	 = "ṅ",
	 = "s",	 = "s",	 = "z",	 = "zh",	 = "ñ",
	 = "t",	 = "th",	 = "d",	 = "dh",	 = "n",
	 = "t",	 = "th",	 = "d",	 = "dh",	 = "n",
	 = "p",	 = "ph",	 = "b",	 = "bh",	 = "m",
	 = "z",	 = "r",	 = "l",	 = "w", 
	 = "x",	 = "x",	 = "x",	 = "h",	
	 = "y",	 = "r",	 = "rh",

	-- vowel diacritics
	 = "ö",	 = "i",	 = "u",	
	 = "ri",	 = "e",	 = "ë",	 = "ü",
	 = "a",	 = "i",	 = "u",	 = "oi",	 = "ou",

	-- visarga
	 = "h",

	-- vowel signs
	 = "o", 	 = "ó",	 = "i",	 = "u",	
	 = "ri",	 = "e", 	 = "é",	 = "ü",
	 = "a",	 = "i",	 = "u",	 = "oi",	 = "ou",

	--hosonto
	 = "",

	-- sondrobindu
	 = "̃",
	
	-- owogroho
	='o',
		
	-- onusor
	 = "ṅ",

	-- hosonto to, 
	 = "t",

	-- numerals
	 = "0",  = "1",  = "2",  = "3",  = "4", 
	 = "5",  = "6",  = "7",  = "8",  = "9",
 
	-- punctuation
	 = ".", -- dari
}

local conv2 = {
	 = "ḱ",	 = "ḱ",
	 = "ǵ",
	 = "ŋ",	 = "ŋ",
	 = "ź",
	 = "ṫ",	 = "ṫ",
	 = "ḋ",	 = "ḋ",
	 = "ṗ",
	 = "ḃ",
	 = "ŕ",
	 = "ṙ",	 = "ṙ",
	 = "ʏ",	 = "ʏ",
	 = "ɵ",	 = "ɵ",
}

local consonant, vowel, vowel_sign = "ক-হড়-য়ৰৱ", "oা-ৌ’", "অ-ঔ"
local c = ""
local cc = "়?" .. c
local v = ""
local syncope_pattern = "(" .. v .. cc .. v .. cc .. ")o(" .. cc .. "ঁ?" .. v .. ")"

local function rev_string(text)
	local result, length = "", mw.ustring.len(text)
	for i = 1, length do
		result = result .. mw.ustring.sub(text, length - i + 1, length - i + 1)
	end
	return result
end

function export.tr(text, lang, sc, mode)
	text = gsub(text, "()্য", "%1্য়")
	text = gsub(text, "্ব", "্ৱ")
	text = gsub(text, "্", "চ্")
	text = gsub(text, "্স", "্চ")
	text = gsub(text, "ৱ", "্ও") 
	text = gsub(text, "ক্ষ", "খ")
	text = gsub(text, "’ৱ", "্অ’")
	text = gsub(text, "ৱ(.)", "্উ%1")
	text = gsub(text, "ৱ(.)", "্ও%1")
	text = gsub(text, "োঁৱ(.)", "্ওঁ%1")
	text = gsub(text, "ৱ", "্ঔ")
	text = gsub(text, "য়(.)", "্ই%1") 
	text = gsub(text, "ৃয়", "্ঋ")
	text = gsub(text, "য়(.)", "্এ%1")
	text = gsub(text, "য়", "্এ’")
	text = gsub(text, "য়(.)", "্ঐ%1")
	text = gsub(text, "য়(.)", "্ঈ%1") 
	text = gsub(text, "য়", "্ঈঅ") -- end
	text = gsub(text, "ৱ", "্ঊ") 
	text = gsub(text, "݁", "্অ")
	text = gsub(text, "", "্")
	text = gsub(text, "বাৰ" , "্বাৰ")
	text = gsub(text, "বিলাক", "্বিলাক")
	text = gsub(text, "টো" , "্টো")
	text = gsub(text, "খন" , "্খন")
	text = gsub(text, "ডাল" , "্ডাল")
	text = gsub(text, "খিনি" , "্খিনি")
	text = gsub(text, "জন" , "্জন")
	text = gsub(text, "জনী" , "্জনী")
	text = gsub(text, "গৰাকী" , "্গৰাকী")
	text = gsub(text, "সকল" , "্সকল")
	text = gsub(text, "কৈ" , "্কৈ")
text = gsub(text, "কে" , "্কে")
	text = gsub(text, "ফাল" , "্ফাল")
	text = gsub(text, "কেই" , "্কেই")
	text = gsub(text, "মান" , "্মান")
	text = gsub(text, "ঞ", "্ইঅ͂")
	text = gsub(text, "ঞ্", "ন্̃")
	
	text = gsub(text, "(" .. c .. "়?)(?)", function(a, b)
		return a .. (b == "" and "o" or b) end)
	
	for word in mw.ustring.gmatch(text, "+") do
		local orig_word = word
		word = rev_string(word)
		word = gsub(word, "^o(়?" .. 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
	
	if mode == "IPA" then
		text = gsub(text, ".?", conv2)
		text = gsub(text, ".", conv2)
	end
	
	text = gsub(text, ".?", conv)
	text = gsub(text, ".", conv)
	
	local consonants_Latn_no_h = ""

	-- Cw
	text = gsub(text, "mw", "mb") -- special case
	text = gsub(text, "^(" .. consonants_Latn_no_h .. "h?)w", "%1") -- initial
	text = gsub(text, "hw", "hb")
	text = gsub(text, "(" .. consonants_Latn_no_h .. ")w", "%1%1") -- medial
	
	-- zñ
	text = gsub(text, "^zñ", "gy") -- initial
	text = gsub(text, "zñ", "gg") -- medial
	
	-- Cy
	text = gsub(text, "^khy", "kh" )
	text = gsub(text, "()(" .. consonants_Latn_no_h .. ")y", "%1i%2%2")

	-- final "b" has inherent vowel
	text = gsub(text, "b$", "bo")
	text = gsub(text, "b ", "bo ")
	
	-- final r conjuncts
	text = gsub(text, "r()o$", "r%1")
	text = gsub(text, "r()o ", "r%1 ")
	text = gsub(text, "rkho$", "rkh")
	text = gsub(text, "rkho ", "rkh ")
	
	if match(text, "") and mode ~= "debug" then
		return nil
	else
		return mw.ustring.toNFC(text)
	end
end
 
return export