Module:lyti-old-translit

From Linguifex
Revision as of 22:53, 5 April 2025 by Dillon (talk | contribs) (Dillon moved page Module:lyt-old-translit to Module:lyti-old-translit without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This module will transliterate Old Oltic language text. 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:lyti-old-translit/testcases.

Functions

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 = {}
 
local tt = {
	["Αυ"]='Au', ["αυ"]='au',
	["Ευ"]='Eu', ["ευ"]='eu',
	["Ου"]='Ou', ["ου"]='ou',
	["Ωυ"]='Ōu', ["ωυ"]='ōu',
	["Α"]='A', ["α"]='a',
	["Β"]='B', ["β"]='b',
	["Γγ"]='Ng', ["γγ"]='ng',
	["Γϝ"]='Nw', ["γϝ"]='nw',
	["Γκ"]='Nk', ["γκ"]='nk',
	["Γχ"]='Nkh', ["γχ"]='nkh',
	["Γξ"]='Nx', ["γξ"]='nx',
	["Γ"]='G', ["γ"]='g',
	["Ϝ"]='W', ["ϝ"]='w',
	["Δ"]='D', ["δ"]='d',
	["Ε"]='E', ["ε"]='e',
	["Ζ"]='Z', ["ζ"]='z',
	["Ι"]='I', ["ι"]='i',
	["Κ"]='K', ["κ"]='k',
	["Λ"]='L', ["λ"]='l',
	["Μ"]='M', ["μ"]='m',
	["Ν"]='N', ["ν"]='n',
	["Ο"]='O', ["ο"]='o',
	["Ω"]='Ō', ["ω"]='ō',
	["Π"]='P', ["π"]='p',
	["Ρ"]='R', ["ρ"]='r',
	["Σ"]='S', ["σ"]='s', ["ς"]='s',
	["Ͳ"]='Ss', ["Ͳ"]='ss',
	["Τ"]='T', ["τ"]='t',
	["Υ"]='Y', ["υ"]='y',
	["Φ"]='Ph', ["φ"]='ph',
	["Θ"]='Th', ["θ"]='th',
	["Χ"]='Kh', ["χ"]='kh',
	["Ξ"]='X', ["ξ"]='x',
	["Η"]='Ē', ["η"]='ē',
};

function export.tr(text, lang, sc)
	
	text = mw.ustring.toNFD(text)
	
	for pat, repl in pairs(tt) do
		text = mw.ustring.gsub(text, pat, repl)
	end
	
	text = mw.ustring.toNFD(text)
	
	return mw.ustring.toNFC(text)
end

return export