Module:User:DerekWinters/Baybayin


This is a private module sandbox of DerekWinters, for their own experimentation. Items in this module may be added and removed at DerekWinters's discretion; do not rely on this module's stability.


local export = {}

local consonants = {
--consonants
	['k']='ᜃ', ['g']='ᜄ', ['ŋ']='ᜅ',
	['t']='ᜆ', ['d']='ᜇ', ['r']='ᜇ', ['n']='ᜈ', 
	['p']='ᜉ', ['b']='ᜊ', ['m']='ᜋ',
	['y']='ᜌ', ['l']='ᜎ',
	['w']='ᜏ', ['s']='ᜐ', ['h']='ᜑ',
}

local diacritics = {
--vowels
	['a']='', ['i']='ᜒ', ['e']='ᜒ', ['u']='ᜓ', ['o']='ᜓ',
}

local tt = {

--vowels
	['a']='ᜀ', ['i']='ᜁ', ['e']='ᜁ', ['u']='ᜂ', ['o']='ᜂ',
}

function export.tr(text, lang, sc)
	if sc ~= "Latn" then
		return nil
	end
	text = mw.ustring.gsub(text, 'ng', 'ŋ')
	text = mw.ustring.gsub(
		text,
		'([kgŋtdrnpbmylwsh])'..
		'([aieuo]?)',
		function(c, d)
			if d == "" then        
				return consonants[c] .. '᜔'
			else
				return consonants[c] .. diacritics[d]
			end
		end)

	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end
 
return export