Module:zle-ort-translit

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

This module will transliterate Old Ruthenian language text per WT:ZLE-ORT 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:zle-ort-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 letters = {}
local digraphs = {}

local double_grave = mw.ustring.char(0x30F)

letters = {
	-- main letters
	='A', ='B', ='V', ='H', ='D', ='E', ='Ž', ='Z', ='I', ='I', ='J',
	='K', ='L', ='M', ='N', ='O', ='P', ='R', ='S', ='T', ='U', ='F',
	='X', ='O', ='Ot', ='C', ='Č', ='Š', ='Šč', ='', ='Y', ='ʹ',
	='Jě', ='Je', ='Ju', ='Ja', ='Ja',
	='a', ='b', ='v', ='h', ='d', ='e', ='ž', ='z', ='i', ='i', ='j',
	='k', ='l', ='m', ='n', ='o', ='p', ='r', ='s', ='t', ='u', ='f',
	='x', ='o', ='ot', ='c', ='č', ='š', ='šč', ='', ='y', ='ʹ',
	='jě', ='je', ='ju', ='ja', ='ja',
	-- extended letters
	='G', ='Z', ='I', ='U', ='U', ='Ks', ='Ps', ='F', ='I', ='Ja',
	='g', ='z', ='i', ='u', ='u', ='ks', ='ps', ='f', ='i', ='ja',
	-- archaic letters & other
	='E', ='Z', ='O', ='O', ='Ô', ='Y', ='Jě', ='Je', ='Ja', ='Ju', ='I' .. double_grave,
	='e', ='z', ='o', ='o', ='ô', ='y', ='jě', ='je', ='ja', ='ju', ='i' .. double_grave, ='',
}

digraphs = {
	="bělou", ="běloú",
	"]="U", "]="u", "]="G", ="g", ="ja",
	)"]="ʺ%1",
	)е"]="%1je",
	)и"]="%1j",
	)ⸯ"]="%1j",
	)ѡ"]="%1ô",
	)ѣ"]="%1ě",
	)ѵ"]="%1v", )Ѵ"]="%1V",
	="cʹ",
	)"]="j%1", )"]="J%1", )"]="j%1", )"]="J%1", 
}

function export.tr(text, lang, sc)
	if not sc then
		sc = require("Module:languages").getByCode(lang):findBestScript(text):getCode()
	end
	
	-- Ѣ was pronounced differently in Middle Ukrainian
	if lang == "zle-muk" then
		letters='Y'
		letters='y'
		letters='Y'
		letters='y'
		letters='Ji'
		letters='ji'
		digraphs)ѣ"]='%1i'
	else
		letters='I'
		letters='i'
		letters='I'
		letters='i'
		letters='Jě'
		letters='jě'
		digraphs)ѣ"]='%1ě'
	end
	
	-- Transliterate the kamora as prime
	text = string.gsub(text, "\210\132", "ʹ")
	-- Transliterate the titlo as colon
	text = string.gsub(text, mw.ustring.char(0x0483), ":")
	
	if sc == "Cyrs" then
		for key, repl in pairs(digraphs) do
			text = mw.ustring.gsub(text, key, repl)
		end
		
		-- pattern for one non-ASCII character
		text = string.gsub(text, '+', letters)
	end

	return text
end

return export