มอดูล:blk-translit

จาก วิกิพจนานุกรม พจนานุกรมเสรี
local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = '(.['..u(0x0300)..'-'..u(0x036F)..']?)'

local pre = {
	['ျ'] = '္ယ', ['ြ'] = '္ရ', ['ွ'] = '္ဝ', ['ှ'] = '္ဟ',
}

local tt1 = {
	-- consonants
	['က'] = 'ก', ['ခ'] = 'ข', ['ဂ'] = 'ค', ['ဃ'] = 'ฆ', ['င'] = 'ง',
	['စ'] = 'จ', ['ဆ'] = 'ฉ', ['ဇ'] = 'ช', ['ဈ'] = 'ฌ', ['ဉ'] = 'ญ', ['ည'] = 'ญ',
	['ဋ'] = 'ฏ', ['ဌ'] = 'ฐ', ['ဍ'] = 'ฑ', ['ဎ'] = 'ฒ', ['ဏ'] = 'ณ',
	['တ'] = 'ต', ['ထ'] = 'ถ', ['ဒ'] = 'ท', ['ဓ'] = 'ธ', ['န'] = 'น',
	['ပ'] = 'ป', ['ဖ'] = 'ผ', ['ဗ'] = 'พ', ['ဘ'] = 'ภ', ['မ'] = 'ม',
	['ယ'] = 'ย', ['ရ'] = 'ร', ['လ'] = 'ล', ['ဝ'] = 'ว', ['သ'] = 'ส',
	['ဟ'] = 'ห', ['ဠ'] = 'ฬ', ['အ'] = 'อ',
	-- independent vowels (1)
	['ဣ'] = 'อิ', ['ဤ'] = 'อี', ['ဥ'] = 'อุ', ['ဦ'] = 'อู', ['ဩ'] = 'เอา',
	-- dependent vowels and diacritics (excluding front type)
	['ါ'] = 'า', ['ာ'] = 'า', ['ိ'] = 'ิ', ['ီ'] = 'ี', ['ု'] = 'ุ', ['ူ'] = 'ู',
	['ံ'] = 'ํ', ['့'] = '̥', ['း'] = ':', ['ႏ'] = '⁏', ['ꩻ'] = '⹁', ['္'] = 'ฺ', ['်'] = '์',
	-- numerals
	['၀'] = '๐', ['၁'] = '๑', ['၂'] = '๒', ['၃'] = '๓', ['၄'] = '๔',
	['၅'] = '๕', ['၆'] = '๖', ['၇'] = '๗', ['၈'] = '๘', ['၉'] = '๙',
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = '‼',
}

local adjust1 = {
	-- dependent vowels (front type)
	['ေ'] = 'เ%1', ['ဲ'] = 'แ%1', 
}



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

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

	text = gsub(text, '.', pre)

	text = gsub(text, '.', tt1)
	for k, v in pairs(adjust1) do
		text = gsub(text, letter_with_mark..k, v)
	end

	return text
 
end
 
return export