Module:Rohg-translit

From Linguifex
Revision as of 00:36, 30 March 2024 by wikt>Theknightwho (Use faster implementation of mw.ustring.char.)
(diff) ← Older revisionΒ | Latest revision (diff)Β | Newer revision β†’ (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Rohg-translit/doc

local export = {}
local u = require("Module:string/char")
 
local tt = {
	-- consonants
	["𐴀"]="", ["𐴁"]="b", ["𐴃"]="t", ["𐴄"]="th",
	["𐴅"]="j", ["𐴆"]="ch", ["𐴇"]="h", ["𐴈"]="kh",
	["𐴉"]="f", ["𐴂"]="p", ["𐴊"]="d", ["𐴋"]="dh",
	["𐴌"]="r", ["𐴍"]="ç", ["𐴎"]="z", ["𐴏"]="s",
	["𐴐"]="c", ["𐴑"]="k", ["𐴒"]="g", ["𐴓"]="l",
	["𐴔"]="m", ["𐴕"]="n", ["𐴖"]="w", ["𐴗"]="u",
	["𐴘"]="y", ["𐴙"]="i", ["𐴚"]="ng", ["𐴛"]="ny", ["𐴜"]="v",
	
	-- vowels
	["𐴝"]="a", ["𐴞"]="i", ["𐴟"]="u", ["𐴠"]="e", ["𐴑"]="o",

	-- others
	["𐴒"]="", --only used after some ending consonants
	["𐴣"]="ñ", --nasalization
	[u(0x200D)]="", --ZWJ, might appear to adjust consonants

	-- numerals
	["𐴰"]="0", ["𐴱"]="1", ["𐴲"]="2", ["𐴳"]="3", ["𐴴"]="4",
	["𐴡"]="5", ["𐴢"]="6", ["𐴷"]="7", ["𐴸"]="8", ["𐴹"]="9",
}

function export.tr(text, lang, sc)

	text = mw.ustring.gsub(text, ".", tt)

	-- tones and special mark
	text = mw.ustring.gsub(text, "(.)𐴀", "%1́")
	text = mw.ustring.gsub(text, "(.)π΄₯", "%1́%1")
	text = mw.ustring.gsub(text, "(.)𐴦", "%1%1́")
	text = mw.ustring.gsub(text, "(.)𐴧", "%1%1")

	return text

end

return export