Module:Ital-translit

From Linguifex
Revision as of 22:35, 12 January 2025 by Sware (talkΒ | contribs) (Created page with "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', ['πŒ—'] = '...")
(diff) ← Older revisionΒ | Latest revision (diff)Β | Newer revision β†’ (diff)
Jump to navigation Jump to search

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

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',
	['πŒ›'] = 'Ε™',
	['𐌜'] = 'ç',
	['𐌝'] = 'í',
	['𐌞'] = 'ú',
	['𐌟'] = 'Ε›',
	-- Numerals
	['𐌠'] = 'β… ',
	['𐌑'] = 'β…€',
	['𐌒'] = 'β…©',
	['𐌣'] = 'β…¬',
	-- Punctuation
	['Β·'] = ' ',
	['⁚'] = ' ',
	['⁝'] = ' ',
}

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

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

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

	-- North Picene
	['nrp'] = {
		['πŒ‚'] = 'g',
	},

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

	-- South Picene
	['spx'] = {
		['πŒ‚'] = 'g',
		['πŒ‘'] = 'Γ­',
	},

	-- Camunic
	['xcc'] = {
		['𐌁'] = 'Ε›',
		['πŒ‚'] = 'g',
		['πŒ‘'] = 'b',
		['πŒ™'] = 's',
		['𐌟'] = 'þþ',
		['𐌣'] = 'þ',
	},

	-- Faliscan
	['xfa'] = {
		['πŒ…'] = 'f', -- looks more like an up-arrow, but this is how it should be encoded
	},

	-- Raetic
	['xrr'] = {
		['𐌁'] = 'þ',
		['πŒ‚'] = '?',
	},

	-- Umbrian
	['xum'] = {
		['πŒ‘'] = 's',
	},

	-- Venetic
	['xve'] = {
		['πŒ‚'] = 'j',
		['πŒ†'] = 'd',
		['𐌘'] = '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