Module:tt-translit/sandbox

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


local export = {}

local rsubn = mw.ustring.gsub

-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end

-- apply rsub() repeatedly until no change
local function rsub_repeatedly(term, foo, bar)
	while true do
		local new_term = rsub(term, foo, bar)
		if new_term == term then
			return term
		end
		term = new_term
	end
end

local tt = {
	="ü",='Ü',   ="t",='T', ="r",='R',   ="f",='F',
	="yu",='Yu', ="ş",='Ş', ="’",='’',   ="ʺ",='ʺ', ="n",='N', 
	="p",='P',   ="y",='Y', ="l",='L',   ="z",='Z', ="e",='E', 
	="g",='G',   ="b",='B', ="u",='U',   ="s",='S', ="x",='X',
	="ç",='Ç', ="şç",='Şç', ="ya",='Ya', ="ı",='I', ="e",='E', 
	="m",='M',   ="o",='O', ="ö",='Ö',   ="i",='İ', ="yo",='Yo',
	="j",='J',   ="k",='K', ="d",='D',   ="w",='W', ="ts",='Ts',
	="a",='A',   ="ñ",='Ñ', ="c",='C',   ="h",='H', ="ə",='Ə'
};

function export.tr(text, lang, sc)
	text = rsub(
		text,
		"(?)()",
		function(a,e) return a..(e=='е' and 'ye' or 'Ye') end
	)
	
	-- ү/у should be transliterated as w after vowels (except у/ү itself)
	text = rsub_repeatedly(text, "()", "%1w")
	text = rsub_repeatedly(text, "()()", "%1w%2")
	
	text = rsub(text, "^Е", "Ye")
	text = rsub(text, "^е","ye")
	text = rsub(text, "ия$", "iyə") --not last word end handled in code end
	
	-- Deal with dual nature of к, г, transliterated either to "front" variants
	-- k/g or "back" variants q/ğ. The back variants occur before hard signs
	-- (Ъ/ъ), which then disappear, and also in the vicinity of the back vowels
	-- а/о/у/ы (and their capital equivalents А/О/У/Ы). The code below that
	-- handles this appears to say that the sound of word-initial к/г is
	-- determined by the following vowel, and the sound of non-word-initial
	-- к/г is determined by the preceding vowel. FIXME: Not sure if this is
	-- correct.
	
	-- glottal stop
	text = rsub(text, "()()", "%1'")
	
	local t = {='Q',='q',='Ğ',='ğ'}
	text = rsub(text, "()()", function(a,b) return t end)
	text = rsub(text,
		"(%a?)()(.?)",
		function(b,c,a)
			return b .. (mw.ustring.match(b>'' and b or a,"") and t or tt) .. a
		end
	)

	text = rsub(text, "ия%A", "iyə")
	text = rsub(text, ".", tt)
	return text
end

return export