Module:bn-translit

ពីWiktionary

Documentation for this module may be created at Module:bn-translit/doc

local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = '(.['..u(0x0300)..'-'..u(0x036F)..']?)'

local tt = {
	-- consonants
	['ক'] = 'ក', ['খ'] = 'ខ', ['গ'] = 'គ', ['ঘ'] = 'ឃ', ['ঙ'] = 'ង',
	['চ'] = 'ច', ['ছ'] = 'ឆ', ['জ'] = 'ជ', ['ঝ'] = 'ឈ', ['ঞ'] = 'ញ',
	['ট'] = 'ដ', ['ঠ'] = 'ឋ', ['ড'] = 'ឌ', ['ঢ'] = 'ឍ', ['ণ'] = 'ណ',
	['ত'] = 'ត', ['ৎ'] = 'ត្', ['থ'] = 'ថ', ['দ'] = 'ទ', ['ধ'] = 'ធ', ['ন'] = 'ន',
	['প'] = 'ប', ['ফ'] = 'ផ្វ', ['ব'] = 'ព', ['ভ'] = 'ភ', ['ম'] = 'ម',
	['য'] = 'យ', ['র'] = 'រ', ['ৰ'] = 'រ', ['ল'] = 'ល', ['ৱ'] = 'វ',
	['শ'] = 'ឝ', ['ষ'] = 'ឞ', ['স'] = 'ស', ['হ'] = 'ហ',
	[u(0x09DC)] = 'ឡ', [u(0x09DD)] = 'ឡ្ល', [u(0x09DF)] = 'យ្យ',
	-- independent vowels
	['অ'] = 'អ', ['আ'] = 'អា', ['ই'] = 'ឥ', ['ঈ'] = 'ឦ', ['উ'] = 'ឧ', ['ঊ'] = 'ឩ',
	['ঋ'] = 'ឫ', ['ৠ'] = 'ឬ', ['ঌ'] = 'ឭ', ['ৡ'] = 'ឮ',
	['এ'] = 'ឯ', ['ঐ'] = 'ឰ', ['ও'] = 'ឱ', ['ঔ'] = 'ឳ',
	-- dependent vowels and diacritics (excluding front type)
	['া'] = 'ា', ['ি'] = 'ិ', ['ী'] = 'ី', ['ু'] = 'ុ', ['ূ'] = 'ូ',
	['ৃ'] = '្ឫ', ['ৄ'] = '្ឬ', ['ৢ'] = '្ឭ', ['ৣ'] = '្ឮ',
	['ৗ'] = '~', ['ং'] = 'ំ', ['ঃ'] = 'ះ', ['্'] = '្', ['ে'] = 'េ', ['ৈ'] = 'ៃ', ['ো'] = 'ោ', ['ৌ'] = 'ៅ',
	['়'] = u(0x0331), -- macron below
	['ঁ'] = 'ม̐', -- candrabindu
	-- marks
	['ঽ'] = '-',
	-- numerals
	['০'] = '0', ['১'] = '1', ['২'] = '2', ['৩'] = '3', ['৪'] = '4',
	['৫'] = '5', ['৬'] = '6', ['৭'] = '7', ['৮'] = '8', ['৯'] = '9',
	['৴'] = '¹⁄₁₆', ['৵'] = '⅛', ['৶'] = '³⁄₁₆', ['৷'] = '¼', ['৸'] = '¾', ['৹'] = '16',
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = "‼",
	-- zero-width non-joiner and joiner (display it if it hides in a word)
	[u(0x200C)] = "₋",
	[u(0x200D)] = "₊",
}

local adjust0 = {
	-- for convenience
	['ড'..'়'] = u(0x09DC), ['ঢ'..'়'] = u(0x09DD), ['য'..'়'] = u(0x09DF),
	['ে'..'া'] = 'ো', ['ে'..'ৗ'] = 'ৌ',
}

function export.tr(text, lang, sc, debug_mode)

	if type(text) == 'table' then -- called directly from a template
		text = text.args[1]
	end

	if lang == "pi" or lang == "sa" then
		text = gsub(text, "ৰ", "ৱ") -- Pali and Sanskrit use ৰ for va
	end

	for k, v in pairs(adjust0) do
		text = gsub(text, k, v)
	end
	text = gsub(text, '.', tt)
	
	return text

end

return export