This module will transliterate ภาษากะเหรี่ยงปะโอ 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:blk-translit/testcases.

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 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