Module:kum-translit

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

A user suggests that this Kumyk module be cleaned up.
Please see the discussion on Requests for cleanup(+) or the talk page for more information and remove this template after the problem has been dealt with.

This module will transliterate Kumyk language text per WT:KUM TR. 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:kum-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 digraphs = {
	= 'h', ='H', ='ğ', ='Ğ', ='ü', ='Ü',
    ='q',  ='Q', ='ñ', ='Ñ', ='ö', ='Ö'
}

local single_letters = {
	='a', ='A',  ='b', ='B',  ='w', ='w',
	='g', ='G',  ='d', ='D',  ='e', ='E',
	='yo',='Yo', ='j', ='J',  ='z', ='Z',
	='i', ='İ',  ='y', ='Y',  ='k', ='K',
	='l', ='L',  ='m', ='M',  ='n', ='N',
	='o', ='O',  ='p', ='P',  ='r', ='R',
	='s', ='S',  ='t', ='T',  ='u', ='U',
	='f', ='F',  ='x', ='X',  ='ts',='Ts',
	='ç', ='Č',  ='ş', ='Ş',  ='şç',='Şç',
	='',  ='',   ='ı', ='I',  ='ʹ', ='ʹ',
	='e', ='E',  ='yu',='Yu', ='ya',='Ya',
}

function export.tr(text, lang, sc)
	for digraph, replacement in pairs(digraphs) do
		text = mw.ustring.gsub(text, digraph, replacement)
	end
	
 	text = mw.ustring.gsub(text,
 		"()()",
 		function (pos, iotated)
 			-- modifier letter apostrophe or right single quotation mark
 			local preceding = mw.ustring.sub(text, math.max(1, pos - 2), math.max(0, pos - 1))
 			local capital = iotated == "Е" or iotated == "Ю"
 			local lower = mw.ustring.lower(iotated)
 			
 			local translit
 			if preceding == "" or mw.ustring.match(preceding, "?$") then
 				if capital then
 					if lower == "ю" then return "Yu"
 					elseif lower == "ё" then return "Yo"
 					else return "Ye" end
 				else
 					if lower == "ю" then return "yu"
 					elseif lower == "ё" then return "yo"
 					else return "ye" end
 				end
 			else
 				if capital then
 					if lower == "ю" then return "Ü"
 					elseif lower == "ё" then return "Ö"
 					else return "E" end
 				else
 					if lower == "ю" then return "ü"
 					elseif lower == "ё" then return "ö"
 					else return "e" end
 				end
 			end
 			return translit
 		end)
	
	return (mw.ustring.gsub(text, '.', single_letters))
end

return export