Module:kmr-translit

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

This module will transliterate Northern Kurdish 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:kmr-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 = {
	="a", ="b", ="c", ="ç", ="d", ="e",
	="ê", ="ê", ="f", ="g", ="h", ="i",
	="î", ="j", ="k", ="l", ="m", ="n",
	="o", ="p", ="q", ="r", ="s", ="ş",
	="t", ="u", ="û", ="v", ="w", ="x", 
	="y", ="z",
	="A", ="B", ="C", ="Ç", ="D", ="E",
	="Ê", ="Ê", ="F", ="G", ="H", ="I",
	="Î", ="J", ="K", ="L", ="M", ="N",
	="O", ="P", ="Q", ="R", ="S", ="Ş",
	="T", ="U", ="Û", ="V", ="W", ="X", 
	="Y", ="Z",

	 = "ẍ",   = "Ẍ",  = "ḧ",  = "Ḧ",
	};

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, '’', tt)
	
	text = mw.ustring.gsub(text, '.', tt)	
	
	text = mw.ustring.gsub(text, '^()’', "%1") -- р’ож: roj
	text = mw.ustring.gsub(text, '()’', "%1%1") -- пьр’: pirr
	
	local consonants = "bcçdfghḧjklmnpqrsştvwxẍzBCÇDFGHḦJKLMNPQRSŞTVWXẌZ"
	local vowels = "aeêiîouûAEÊIÎOUÛ"
	
	-- handle ә’
	text = mw.ustring.gsub(text, '()()’',
		function (pos, e)
			if pos == 1 then -- ә’ at beginning of string
				local after1, after2 = mw.ustring.match(text, "^(.?)(.?)", pos + 2)
				if consonants:find(after1)
						and (after2 == '' -- followed by single consonant: ә’к → 'ek
						or consonants:find(after2)) then -- followed by two consonants: ә’скәр → 'esker
					return "'" .. e
				end
			else
				local before = mw.ustring.sub(text, pos - 1, pos - 1)
				if vowels:find(before) then -- preceded by vowel: щьмаә’т → cima'et
					return "'" .. e
				end
			end
			
			return e .. "'"
		end)

	return text
end

return export