Module:eve-translit

Hello, you have come here looking for the meaning of the word Module:eve-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:eve-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:eve-translit in singular and plural. Everything you need to know about the word Module:eve-translit you have here. The definition of the word Module:eve-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:eve-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate Even 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:eve-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 u = mw.ustring.char

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

local tab = { 
	='A', ='a', ='B', ='ʙ', ='W', ='w',
	='E', ='e', ='Jo', ='jo', ='G', ='g',
	='D', ='d', ='I', ='i',  ='Ī', ='ī',
	='J', ='j', ='K', ='k', ='L', ='l',
	='M', ='m', ='N', ='n', ='Ŋ', ='ŋ',
	='O', ='o', ='Ö', ='ö', ='Ö', ='ö',
	='P', ='p', ='R', ='r',	='S', ='s',
	='T', ='t', ='U', ='u', ='Ū', ='ū',
	='F', ='f', ='H', ='h', ='C', ='c',
	='I', ='i', ='Ə', ='ə', ='Ju', ='ju',
	='Ẹ', ='ẹ', -- Not present in the original latinisation
	-- non-native letters
	 ='Z', ='z',	='Z', ='z',
	 ='C', ='c',  ='S', ='s', ='S', ='s', 
	 ='ʺ', ='ʺ', ="’", ="’",
	 
	 -- non-standard letters
	 ='Γ', ='γ', ='Ŋ', ='ŋ', ='Ü', ='ü',
	 ='Ḥ', ='ḥ', ='Q', ='q'							
}


local iotatedTranslit = {
	 = "je",
	 = "ja",
	 = "ji",
	 = "jī",
	 = "Je",
	 = "Ja",
}

local replacements = {
	{ "Ё", 'Jo' },
	{ "ё", 'jo' },
	{ "Ӫ", 'Jö' },
	{ "ӫ", 'jö' },
	{ "Ю", 'Ju' },
	{ "ю", 'ju' },
	
	-- Unfortunately the Cyrillic alphabet doesn't distinguish between ʒe and ʒə
	{ "Де", 'Ʒe' },
	{ "де", 'ʒe' },
	{ "Не", 'Ņe' },
	{ "не", 'ņe' },
	
	{ "Ди", 'Ʒi' },
	{ "ди", 'ʒi' },
	{ "Ни", 'Ņi' },
	{ "ни", 'ņi' },
	
	{ "Дя", 'Ʒa' },
	{ "дя", 'ʒa' },
	{ "Ня", 'Ņa' },
	{ "ня", 'ņa' },
	
	{ "Дj", 'Ʒ' },
	{ "дj", 'ʒ' },
	{ "Нj", 'Ņ' },
	{ "нj", 'ņ' },
	
	-- The following is non-standard but supposedly used in non-standard spelling and dialect forms
	{ "Дь", 'Ʒ' },
	{ "дь", 'ʒ' },
	{ "Нь", 'Ņ' },
	{ "нь", 'ņ' },
	
	{ "Нг", 'Ŋ' },
	{ "нг", 'ŋ' },
}
 
function export.tr(text, lang, sc)
	local ugsub, str_gsub = mw.ustring.gsub, string.gsub
	local UTF8char = '*'
	
	for i, replacement in ipairs(replacements) do
		text = str_gsub(text, unpack(replacement))
	end
	
	-- е after a vowel or at the beginning of a word becomes ye
	-- Again, the Cyrillic alphabet doesn't distinguish between je and jə
	text = ugsub(text,
		"(?)()", 
		function(preceding, iotated)
			return preceding .. iotatedTranslit
		end)
	
	text = ugsub(text, "^", iotatedTranslit)
	
	text = ugsub(text, "()()",
		function(preceding, iotated)
			return preceding .. iotatedTranslit
		end)
	
	text = str_gsub(text, UTF8char, tab)
	
	return text
end

return export