Modul:Ital-translit

Modul ini akan mentransliterasi teks dalam Tulisan Old Italic. Ia digunakan untuk mentransliterasi Etruscan, North Picene, Oscan, South Picene, Camunic, Faliscan, Lemnian, Lepontic, Raetic, Umbrian, and Venetic. The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:Ital-translit/testcases.

Functions

sunting
tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

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