Module:Ital-translit

local export = {}

-- Standard transcription
local common_rules = {
	['πŒ€'] = 'a',
	['𐌁'] = 'b',
	['πŒ‚'] = 'c',
	['πŒƒ'] = 'd',
	['πŒ„'] = 'e',
	['πŒ…'] = 'v',
	['πŒ†'] = 'z',
	['πŒ‡'] = 'h',
	['𐌈'] = 'θ',
	['πŒ‰'] = 'i',
	['𐌊'] = 'k',
	['πŒ‹'] = 'l',
	['𐌌'] = 'm',
	['𐌍'] = 'n',
	['𐌎'] = 'ő',
	['𐌏'] = 'o',
	['𐌐'] = 'p',
	['πŒ‘'] = 'Ε›',
	['πŒ’'] = 'q',
	['πŒ“'] = 'r',
	['πŒ”'] = 's',
	['πŒ•'] = 't',
	['πŒ–'] = 'u',
	['πŒ—'] = 'x',
	['𐌘'] = 'Ο†',
	['πŒ™'] = 'Ο‡',
	['𐌚'] = 'f',
	['πŒ›'] = 'Ε™',
	['𐌜'] = 'ç',
	['𐌝'] = 'í',
	['𐌞'] = 'ú',
	['𐌟'] = 'k',
	-- Numerals
	['𐌠'] = 'β… ',
	['𐌑'] = 'β…€',
	['𐌒'] = 'β…©',
	['𐌣'] = 'β…¬',
	-- Punctuation
	['Β·'] = ' ',
	['⁚'] = ' ',
	['⁝'] = ' ',
}

local lang_rules = {
	['ett'] = {		-- Etruscan
		['𐌟'] = 'β…­',
	};

	['itc-ola'] = {		-- Old Latin
		['πŒ…'] = 'f',
	};

	['nrc'] = {		-- Noric
		['πŒ‚'] = 'g',
		['𐌈'] = 'd',
		['πŒ™'] = 'g',
	};
	
	['nrp'] = {		-- North Picene
		['πŒ‚'] = 'g',
	};

	['osc'] = {		-- Oscan
		['πŒ‚'] = 'g',
	};

	['spx'] = {		-- South Picene
		['πŒ‚'] = 'g',
		['πŒ‘'] = 'Γ­',
		['Β·'] = 'o',
		['⁚'] = 'f',
	};
	
	['xcc'] = {		-- Camunic
		['𐌁'] = 'Ε›',
		['πŒ‚'] = 'g',
		['πŒ‘'] = 'b',
		['πŒ™'] = 's',
		['𐌟'] = 'þþ',
		['𐌣'] = 'þ',
	};
	
	['xrr'] = {		-- Raetic
		['𐌁'] = 'þ',
		['πŒ‚'] = '?',
	};
	
	['xum'] = {		-- Umbrian
		['𐌈'] = 't',
	};
	
	['xve'] = {		-- Venetic
		['πŒ‚'] = 'j',
		['πŒ†'] = 'd',
		['πŒ‡πŒ…'] = 'f',
		['𐌘'] = 'b',
		['πŒ™'] = 'g',
	};
}

function export.tr(text, lang, sc)
	-- If the script is not Ital, do not transliterate
	if sc ~= "Ital" then
		return
	end
	
	-- Transliterate language-specific exceptions
	if lang == "xve" then
		text = mw.ustring.gsub(text, 'πŒ‡πŒ…', 'f')
	end
	
	if lang_rules[lang] then
		text = mw.ustring.gsub(text, '.', lang_rules[lang])
	end
	
	-- Transliterate remaining characters
	text = mw.ustring.gsub(text, '.', common_rules)
	
	return text
end

return export