Module:niv-translit

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

This module will transliterate Nivkh 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:niv-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 UTF8_char = "*"

local export = {}

local tab = {
	='A', ='a', ='V', ='v', ='E', ='e',
	='Jo', ='jo',	='G', ='g', ='Ğ', ='ğ',
	='Γ', ='γ', ='Ġ', ='ġ', ='D', ='d',
	='I', ='i', ='J', ='j',
	='K', ='k', ='Q', ='q', ='Q', ='q',
	='L', ='l', ='M', ='m', ='N', ='n',
	='Ŋ', ='ŋ', ='Ŋ', ='ŋ',
	='O', ='o', ='P', ='p', ='R', ='r',
	='Ř', ='ř', ='S', ='s', ='T', ='t',
	='U', ='u', ='W', ='w', ='F', ='f',
	='X', ='x', ='Ẋ', ='ẋ', ='Ẋ', ='ẋ', 
	='H', ='h', ='Ț’', ='ț’',
	='Ə', ='ə', ='E', ='e', ='Ju', ='ju',
	='Ja', ='ja', ='ʼ', ='ʼ',
	-- non-native letters
	='B', ='b', ='ž', ='ž',	='Z', ='z',
	='C', ='c', ='Š', ='š', ='Šč', ='šč',
	='ʺ', ='ʺ', ="’", ="’"
}

local palatal = {
	{ 'Дj', 'D̦' },
	{ 'дj', 'd̦' },
	{ 'Нj', 'Ņ' },
	{ 'нj', 'ņ' },
	{ 'Тj', 'Ț' },
	{ 'тj', 'ț' },
}

function export.tr(text, lang, sc)
	--[=[
	Unfortunately the Cyrillic alphabet doesn't distinguish between ţi and ti
	or ţe and te and so on.
	
	Represent iotation with j to allow the palatal consonant replacements.
	]=]
	text = string.gsub(text, UTF8_char,
		{
			 = 'Ja',  = 'ja',
			 = 'Jo',  = 'jo',
			 = 'Ju',  = 'ju',
			 = 'j'
		}
	)

	for _, item in ipairs(palatal) do
		text = string.gsub(text, unpack(item))
	end
	
	local vowels = {}
	for char in string.gmatch("АОУЫЕИЪЬаӣиоуыэеъьaeiou", UTF8_char) do
		vowels = true
	end
 	text = mw.ustring.gsub(text,
 		"(.?)()",
 		function (preceding, e)
 			-- modifier letter apostrophe or right single quotation mark
 			local capital = e == "Е"
 			if preceding == "ʼ" or preceding == "’" then
 				e = capital and "E" or "e"
 			elseif preceding == "" or vowels or mw.ustring.find(preceding, "") then
 				e = capital and "Je" or "je"
 			else
 				mw.log("Module:niv-translit could not decide how to transliterate " .. e ..
 					" after " .. preceding .. ".")
 			end
 			return preceding .. e
 		end)
 	text = mw.ustring.gsub(text, "ни", "ņi")
 	text = mw.ustring.gsub(text, "Ни", "Ņi")
 	text = mw.ustring.gsub(text, "НИ", "ŅI")
 	text = mw.ustring.gsub(text, "ди", "d̦i")
 	text = mw.ustring.gsub(text, "Ди", "D̦i")
 	text = mw.ustring.gsub(text, "ДИ", "D̦I")
 	text = mw.ustring.gsub(text, "ти", "ți")
 	text = mw.ustring.gsub(text, "Ти", "Ți")
 	text = mw.ustring.gsub(text, "ТИ", "ȚI")
    
    return string.gsub(text, UTF8_char, tab)
end

return export