Модул:ksw-translit

Документација модула[прикажи] [уреди] [историја] [освежи]

Грешка у скрипти: Не постоји модул „documentation/translit”.

local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char

local tt1 = {
	-- consonants
	['က'] = 'kə', ['ခ'] = 'khə', ['ဂ'] = 'ghə', ['ဃ'] = 'chə', ['င'] = 'ngə',
	['စ'] = 'sə', ['ဆ'] = 'hsə', ['ၡ'] = 'shə', ['ည'] = 'nyə',
	['တ'] = 'tə', ['ထ'] = 'htə', ['ဒ'] = 'də', ['န'] = 'nə',
	['ပ'] = 'pə', ['ဖ'] = 'hpə', ['ဘ'] = 'bə', ['မ'] = 'mə',
	['ယ'] = 'yə', ['ရ'] = 'rə', ['လ'] = 'lə', ['ဝ'] = 'wə',
	['သ'] = 'thə', ['ဟ'] = 'hə', ['အ'] = '\'ə', ['ဧ'] = 'hhə',
	-- medials
	['ှ'] = 'ˣghə', ['ၠ'] = 'ˣyə', ['ြ'] = 'ˣrə', ['ျ'] = 'ˣlə', ['ွ'] = 'ˣwə',
	-- dependent vowels
	['ါ'] = 'a', ['ံ'] = 'i', ['ု'] = 'ʉ', ['ူ'] = 'u', ['ၢ'] = 'ø',
	['့'] = 'e', ['ဲ'] = 'ɛ', ['ိ'] = 'o', ['ီ'] = 'ɔ',
	-- numerals
	['၀'] = '0', ['၁'] = '1', ['၂'] = '2', ['၃'] = '3', ['၄'] = '4',
	['၅'] = '5', ['၆'] = '6', ['၇'] = '7', ['၈'] = '8', ['၉'] = '9',
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = '‼',
}

local adjust0 = {
	-- tones
	['ၢ်'] = u(0x0331), ['ာ်'] = u(0x0323), ['း'] = u(0x0308), ['ၣ်'] = u(0x0300),
	['ၤ'] = u(0x0304), --prolonged
}

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

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

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

	text = gsub(text, 'əˣ', '')
	text = gsub(text, '(ə)([aiʉuøeɛoɔ])', '%2')
	text = gsub(text, '(ə)(['..u(0x0331)..u(0x0323)..u(0x0308)..u(0x0300)..u(0x0304)..'])', 'a%2')

	return text
 
end
 
return export