Module:ysr-translit

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module will transliterate Sirenik 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:ysr-translit/testcases.

Functions

[edit]
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 u = mw.ustring.char

local MACRON    = u(0x0304)
local DOTABOVE  = u(0x0307)

local tab = { 
	["А"]='A', ["а"]='a', ["В"]='V', ["в"]='v',
	["Е"]='E', ["е"]='e', ["Ё"]='Jo', ["ё"]='jo', 
	["Г"]='G', ["г"]='g', ["Ӷ"]='Ǧ',["ӷ"]='ǧ',
	["И"]='I', ["и"]='i', ["Ӣ"]='Ī', ["ӣ"]='ī',
	["Й"]='J', ["й"]='j', ["К"]='K', ["к"]='k', ["Л"]='L', ["л"]='l', ["Ӄ"]='Q', ["ӄ"]='q',
	["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n', ["Ӈ"]='Ŋ', ["ӈ"]='ŋ', ["О"]='O', ["о"]='o', 
	["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r',	["С"]='S', ["с"]='s',
	["Т"]='T', ["т"]='t', ["У"]='U', ["у"]='u', ["Х"]='H', ["х"]='h', 
	["Ч"]='Č', ["ч"]='č', ["Ӽ"]='X̌', ["ӽ"]='x̌',["Ы"]='Y', ["ы"]='y',
	["Э"]='Ə', ["э"]='ə', ["Ю"]='Ju', ["ю"]='ju',["Я"]='Ja', ["я"]='ja', ['Ъ']='ʺ', ['ъ']='ʺ',
	
	["А́"]='Á', ["а́"]='á',
	["Е́"]='É', ["е́"]='é',
	["И́"]='Í', ["и́"]='í',
	["О́"]='Ó', ["о́"]='ó',
	["У́"]='Ú', ["у́"]='ú',
	["Ы́"]='Ý', ["ы́"]='ý',
	["Я́"]='Já', ["я́"]='já',
	["Ю́"]='Jú', ["ю́"]='jú',
	["Ё́"]='Jó', ["ё́"]='jó',
	
	["А̄"]='Ā', ["а̄"]='ā',
	["Е̄"]='Ē', ["е̄"]='ē',
	["Ӣ"]='Ī', ["ӣ"]='ī',
	["О̄"]='Ō', ["о̄"]='ō',
	["Ӯ"]='Ū', ["ӯ"]='ū',
	["Ы̄"]='Ȳ', ["ы̄"]='ȳ',
	["Я̄"]='Jā', ["я̄"]='jā',
	["Ю̄"]='Jū', ["ю̄"]='jū',
	["Ё̄"]='Jō', ["ё̄"]='jō',
	
	["А̄́"]='Ā́', ["а̄́"]='ā́',
	["Е̄́"]='Ḗ', ["е̄́"]='ḗ',
	["Ӣ́"]='Ī́', ["ӣ́"]='ī́',
	["О̄́"]='Ṓ', ["о̄́"]='ṓ',
	["Ӯ́"]='Ū́', ["ӯ́"]='ū́',
	["Ы̄́"]='Ȳ́', ["ы̄́"]='ȳ́',
	["Я̄́"]='Jā́', ["я̄́"]='jā́',
	["Ю̄́"]='Jū́', ["ю̄́"]='jū́',
	["Ё̄́"]='Jṓ', ["ё̄́"]='jṓ',
	
	
	
	-- Not present in the original latinisation
	-- non-native letters
	 ["Ж"]='Z', ["ж"]='z',	["З"]='Ž', ["з"]='ž',
	 ["Ц"]='C', ["ц"]='c',  ["Ш"]='Š', ["ш"]='š', ["Щ"]='Šč', ["щ"]='šč', 
	 ['Ъ']='ʺ', ['ъ']='ʺ', ["Ь"]="’", ["ь"]="’",["Ф"]='F', ["ф"]='f',
	 ["Б"]='B', ["б"]='ʙ',["Д"]='D', ["д"]='d',
	 
	 -- non-standard letters
	 ["Ҕ"]='Γ', ["ҕ"]='γ', ["Ҥ"]='Ŋ', ["ҥ"]='ŋ', 
	 ["Ӄ"]='Q', ["ӄ"]='q',	["Ҕ"]='Ǧ', ["ҕ"]='ǧ',	
	 
	 ["Йъ"]='J̊', ["йъ"]='j̊', ["Лъ"]='L̊', ["лъ"]='l̊', 
	 ["Нъ"]='N̊', ["нъ"]='n̊'
}


local iotatedTranslit = {
	["е"] = "je",
	["я"] = "ja",
	["и"] = "ji",
	["Е"] = "Je",
	["Я"] = "Ja",

}

	text = str_gsub(text, UTF8char, tab)
	
return text