এই মডিউলের জন্য মডিউল:tru-translit/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

local U = mw.ustring.char
local rsubn = mw.ustring.gsub

local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end

local rbasa_below = U(0x737)
local pthaha_below = U(0x731)
local rbasa = U(0x736)
local zqapha = U(0x733)
local pthaha = U(0x730)
local alaph = U(0x710)

local waw = U(0x718)
local yudh = U(0x71D)

local combining_tilde_below = U(0x330)
local qushshaya = U(0x741)
local rukkakha = U(0x742)

local fix = {
	{ "([" .. rbasa_below .. pthaha_below .. rbasa .. zqapha .. pthaha .. "])" .. qushshaya, qushshaya .. "%1" },
	{ "([" .. rbasa_below .. pthaha_below .. rbasa .. zqapha .. pthaha .. "])" .. rukkakha, rukkakha .. "%1" },
	{ "([" .. rbasa_below .. pthaha_below .. rbasa .. zqapha .. pthaha .. "])" .. combining_tilde_below, combining_tilde_below .. "%1" },
}

local tt = {
	["ܦ"] = "f", ["ܒ"] = "b", ["ܬ"] = "t", ["ܛ"] = "ṭ", ["ܕ"] = "d", ["ܟ"] = "k",
	["ܓ"] = "g", ["ܩ"] = "q", ["ܔ"] = "j", ["ܣ"] = "s", ["ܨ"] = "ṣ", ["ܙ"] = "z",
	["ܫ"] = "š", ["ܚ"] = "ḥ", ["ܥ"] = "c", ["ܗ"] = "h", ["ܡ"] = "m", ["ܢ"] = "n",
	["ܪ"] = "r", ["ܠ"] = "l",
}

local tt_next = {
	[waw] = "w",
	[yudh] = "y",

	[rbasa_below] = "ë",
	[pthaha_below] = "ä",
	[rbasa] = "e",
	[zqapha] = "o",
	[pthaha] = "a",
}

local consonants = "fbtṭdkgqjsṣzšḥchmnrlvžpvṯḏxġ" .. yudh .. waw
local consonants_class = "[" .. consonants .. "]"

function export.tr(text)

	text = rsub(text, " | ", "# | #")
	text = "##" .. rsub(text, " ", "# #") .. "##"
	text = rsub(text, "ـ", "")
	text = rsub(text, ".", fix)

	text = rsub(text, "ܫ" .. combining_tilde_below, "č")
	text = rsub(text, "ܙ" .. combining_tilde_below, "ž")

	text = rsub(text, "ܦ" .. qushshaya, "p")

	text = rsub(text, "ܒ" .. rukkakha, "v")
	text = rsub(text, "ܬ" .. rukkakha, "ṯ")
	text = rsub(text, "ܕ" .. rukkakha, "ḏ")
	text = rsub(text, "ܟ" .. rukkakha, "x")
	text = rsub(text, "ܓ" .. rukkakha, "ġ")

	text = rsub(text, ".", tt)

	text = rsub(text, "(" .. consonants_class .. ")" .. waw .. "(" .. consonants_class .. ")", "%1u%2")
	text = rsub(text, "(" .. consonants_class .. ")" .. yudh .. "(" .. consonants_class .. ")", "%1i%2")
	text = rsub(text, "#" .. waw .. "(" .. consonants_class .. ")", "#u%1")
	text = rsub(text, "#" .. yudh .. "(" .. consonants_class .. ")", "#i%1")

	text = rsub(text, alaph .. pthaha ..  waw .. "#", "#aw")
	text = rsub(text, alaph .. pthaha .. yudh .. "#", "#ay")
	
	text = rsub(text, "#" .. alaph .. waw, "#u")
	text = rsub(text, "#" .. alaph .. yudh, "#i")

	text = rsub(text, waw .. "#", "u#")
	text = rsub(text, yudh .. "#", "i#")

	text = rsub(text, pthaha .. alaph .. "#", "a#")
	text = rsub(text, rbasa .. alaph .. "#", "e#")
	text = rsub(text, zqapha .. alaph .. "#", "o#")
	text = rsub(text, alaph .. "#", "o#")
	text = rsub(text, alaph, "")

	text = rsub(text, ".", tt_next)

	text = rsub(text, "#", "")

	return text
end

return export