Module:cr-translit

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

This module will transliterate Cree language text. It is also used to transliterate Southern East Cree, Northern East Cree, and Inuktitut. 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:cr-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 = {}

function export.tr(text, lang, sc)
	text = require("Module:Cans-translit").tr(text, lang, sc)
	text = mw.ustring.gsub(text,"ī","ii")
	text = mw.ustring.gsub(text,"ō","oo")
	text = mw.ustring.gsub(text,"ā","aa")
	text = mw.ustring.gsub(text,"š","sh")
	text = mw.ustring.gsub(text,"ð","th")
	return text
end

function export.transcribe(text)
	local replace = {"sh","th","hk","kw","sk"}
	local s = "ᐁᐃᐅᐊᐯᐱᐳᐸᑌᑎᑐᑕᑫᑭᑯᑲᒉᒋᒍᒐᒣᒥᒧᒪᓀᓂᓄᓇᓭᓯᓱᓴᔦᔨᔪᔭᖊᖋᖌᖍᕃᕆᕊᕍᔐᔑᔓᔕᕓᕕᕗᕙᘚᘛᘕᘔᓓᓕᓗᓚ"
	local s_tr1 = "0ptkcmnsyrl1f2z"
	local s_tr2 = "eioa"
	local w = "ᐍᐏᐓᐘᐻᐽᑁᑅᑘᑚᑞᑢᑵᑷᑻᑿᒓᒕᒙᒝᒭᒯᒳᒷᓊ ᓌ ᓷᓹᓽᔁᔰᔲᔶᔺᔘᔚᔞᔢᓝᓟᓣᓧ"
	local w_tr1 = "0ptkcmnsyrz"
	local w_tr2 = "eioa"
	local l = "ᐄᐆᐋᐲᐴᐹᑏᑑᑖᑮᑰᑳᒌᒎᒑᒦᒨᒫᓃᓅᓈᓰᓲᓵᔩᔫᔮᕇᕋᕎᔒᔔᔖᕖᕘᕚᓖᓘᓛᐐᐔᐙ"
	local l_tr1 = "0ptkcmnsyr1flw23"
	local l_tr2 = "īōā"
	local f = "ᐤᐦᕽᑉᑦᒡᒃᒻᓐᔅᔥᔾᓪᕐ‡ᒄᔉ"
	local f_tr = "wh3ptckmns1ylr45"
	text = mw.ustring.gsub(text,"ê","e")
	text = mw.ustring.gsub(text,"u","o")
	text = mw.ustring.gsub(text,"ii","ī")
	text = mw.ustring.gsub(text,"oo","ō")
	text = mw.ustring.gsub(text,"aa","ā")
	text = mw.ustring.gsub(text,"()(w?)","%1 0%2")
	text = mw.ustring.gsub(text,"^(w?)"," 0%1")
	text = mw.ustring.gsub(text," 0","0")
	mw.log(text)
	text = mw.ustring.gsub(
		text,
		"()w()",
		function(a, b)
			a = w_tr1:find(a)
			b = w_tr2:find(b)
			local i = a * 4 + b - 4
			return mw.ustring.sub(w, i, i)
		end
	)
	for i = 1, 3 do
		text = mw.ustring.gsub(text, replace, tostring(i))
	end
	mw.log(text)
	text = mw.ustring.gsub(
		text,
		"()()",
		function(a, b)
			a = s_tr1:find(a)
			b = s_tr2:find(b)
			local i = a * 4 + b - 4
			return mw.ustring.sub(s, i, i)
		end
	)
	text = mw.ustring.gsub(
		text,
		"()()",
		function(a, b)
			a = l_tr1:find(a)
			b = l_tr2:find(b)
			local i = a * 3 + b - 3
			return mw.ustring.sub(l, i, i)
		end
	)
	for i=4, 5 do
		text = mw.ustring.gsub(text, replace, tostring(i))
	end
	mw.log(text)
	text = mw.ustring.gsub(
		text,
		"()",
		function(a)
			a = f_tr:find(a)
			return mw.ustring.sub(f, a, a)
		end
	)
	return text
end

return export