Module:pine-translit

From Linguifex
Jump to navigation Jump to search


local export = {}

local tt = {}

-- from Teulgi to Tuġvut font
tt = {
    { "%-", "_" }, { "_t", "_0" },
	
	-- Voicelessness in consonant clusters
	{ "m(p[^p])", "ṃ%1" }, { "n([ktƛ][^ktƛ])", "ṇ%1" },
	{ "r([tkpƛġ][^tkpƛġ])", "ṛ%1" },
	{ "l([ptkġ][^ptkġ])", "ḷ%1" },
	
    -- Synthetic diphthongs
    { "uo", "aa-" }, { "ay", "aa--" },

    -- Short vowels
    { "o", "u-" }, { "e", "i-" },
    { "y", "a-" }, { "ů", "u--" },

    -- Geminate vowels
    { "ả", "aa" }, { "ủ", "uu" },
    { "ỏ", "u-u-" }, { "ỉ", "ii" },
    { "ẻ", "i-i-" }, { "ỷ", "a-a-" },

    -- m-series
    { "bm", "pm" }, { "ṃṃ", "m-m" }, { "ṃ", "m-" },

    -- n-series
    { "ng", "N-" }, { "dn", "t-n" }, { "tṇ", "t-n-" },
    { "nnį", "n--" }, { "ṇṇį", "N" },
    { "nį", "n--" }, { "ṇį", "N" },
    { "ṇṇ", "n-n" }, { "ṇ", "n-" },

    -- p-series
    { "bb", "p-p" }, { "b", "p-" },

    -- t-series
    { "ḍḍ", "t--t" }, { "dd", "t-t" },
    { "ḍv", "tf--" }, { "dv", "tf-" },
    { "ḍ", "t--" }, { "d", "t-" },

    -- ġ-series
    { "ḥḥ", "h--h" }, { "ġġ", "g-g" },
    { "ḥ", "h--" }, 
    { "tġv", "hf--" }, { "tġ", "hf-" },
    { "ġv", "hf" }, { "ġ", "g-" },

    -- h-series
    { "hhį", "h-h" }, { "hį", "h-" },

    -- s-series
    { "ttṡ", "c--c" }, { "tts", "c-c" },
    { "tṡ", "c--" }, { "ts", "c-" },
    { "ṡ", "c" },

    -- r-series
    { "ṛṛ", "r-r" }, { "ṛ", "r-" },

    -- l-series
    { "ḷḷį", "L--L" }, { "llį", "L-L" },
    { "ḷį", "L--" }, { "lį", "L-" },
    { "ḷ", "L" }, { "ƛ", "T" },

    -- į-series
    { "į", "j" },
    
    -- v-series
    { "v", "f" },
}

function export.tr(text, lang, sc)
	text = mw.ustring.lower(text)
	
	for _, rule in ipairs(tt) do
		text = mw.ustring.gsub(text, rule[1], rule[2])
	end

    return text
end

return export