Module:User:DerekWinters/Hanunoo

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']='ᜧ', ['n']='ᜨ', 
	['p']='ᜩ', ['b']='ᜪ', ['m']='ᜫ',
	['y']='ᜬ', ['l']='ᜮ', ['r']='ᜭ',
	['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