Module:Cyrs-translit

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

This module will transliterate text in the Old Cyrillic script. It is used to transliterate Old Church Slavonic, Old East Slavic, and Old Novgorodian. 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:Cyrs-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 = {
	='A', ='a',
	='B', ='b',
	='V', ='v',
	='G', ='g',
	='D', ='d',
	='E', ='e', ='E', ='e',
	='Ž', ='ž',
	='Dz', ='dz', ='Dz', ='dz', ='Dz', ='dz',
	='Z', ='z', ='Z', ='z',
	='I', ='i', ='I', ='i', ='I', ='i', ='Ì', ='ì', ='I', ='i', ='I', ='i',
	='Đ', ='đ',
	='K', ='k',
	='L', ='l',
	='M', ='m',
	='N', ='n',
	='O', ='o', ='O', ='o', ='Otŭ', ='otŭ', ='O', ='o', ='O', ='o', ='O', ='o', ='o', ='O', ='o', ='O', ='o',
	='P', ='p',
	='R', ='r',
	='S', ='s',
	='T', ='t',
	='U', ='u', ='U', ='u', ='U', ='u',
	='F', ='f',
	='X', ='x',
	='C', ='c',
	='Č', ='č',
	='Š', ='š',
	-- For Щ see below
	='Ŭ', ='ŭ',
	='Y', ='y', ='Y', ='y',
	='Ĭ', ='ĭ',
	='Ě', ='ě',
	='Ju', ='ju',
	='Ja', ='ja', ='Ja', ='ja',
	='Je', ='je',
	='Ę', ='ę', ='Ę', ='ę',
	='Ję', ='ję', ='Ję', ='ję',
	='Ǫ', ='ǫ',
	='Jǫ', ='jǫ',
	='Jě', ='jě',
	
	='Ks', ='ks',
	='Ps', ='ps',
	='Θ', ='θ',
	='Ü', ='ü', ='Ü' .. double_grave, ='ü' .. double_grave,
	='Q', ='q',
	-- newer letters
	='J', ='j', -- starting from 15th century
	='G', ='g',
	='E', ='e',
}

digraphs = {
	)ѵ"]="%1v",
	)Ѵ"]="%1V",
	"]="U", "]="u",
	"]="Y", ="y",
	-- numbers
	а҃"]="1", в҃"]="2", г҃"]="3", д҃"]="4",
	е҃"]="5", є҃"]="5", ѕ҃"]="6", ꙅ҃"]="6", з҃"]="7", ꙁ҃"]="7", и҃"]="8", ѳ҃"]="9",
	і҃"]="10", а҃і"]="11", в҃і"]="12", г҃і"]="13", д҃і"]="14",
	е҃і"]="15", є҃і"]="15", ѕ҃і"]="16", ꙅ҃і"]="16", з҃і"]="17", ꙁ҃і"]="17", и҃і"]="18", ѳ҃і"]="19",
	к҃"]="20", к҃а"]="21", к҃в"]="22", к҃г"]="23", к҃д"]="24",
	к҃е"]="25", к҃є"]="25", к҃ѕ"]="26", к҃ꙅ"]="26", к҃з"]="27", к҃ꙁ"]="27", к҃и"]="28", к҃ѳ"]="29",
	л҃"]="30", л҃а"]="31", л҃в"]="32", л҃г"]="33", л҃д"]="34",
	л҃е"]="35", л҃є"]="35", л҃ѕ"]="36", л҃ꙅ"]="36", л҃з"]="37", л҃ꙁ"]="37", л҃и"]="38", л҃ѳ"]="39",
	м҃"]="40", м҃а"]="41", м҃в"]="42", м҃г"]="43", м҃д"]="44",
	м҃е"]="45", м҃є"]="45", м҃ѕ"]="46", м҃ꙅ"]="46", м҃з"]="47", м҃ꙁ"]="47", м҃и"]="48", м҃ѳ"]="49",
	н҃"]="50", н҃а"]="51", н҃в"]="52", н҃г"]="53", н҃д"]="54",
	н҃е"]="55", н҃є"]="55", н҃ѕ"]="56", н҃ꙅ"]="56", н҃з"]="57", н҃ꙁ"]="57", н҃и"]="58", н҃ѳ"]="59",
	ѯ҃"]="60", ѯ҃а"]="61", ѯ҃в"]="62", ѯ҃г"]="63", ѯ҃д"]="64",
	ѯ҃е"]="65", ѯ҃є"]="65", ѯ҃ѕ"]="66", ѯ҃ꙅ"]="66", ѯ҃з"]="67", ѯ҃ꙁ"]="67", ѯ҃и"]="68", ѯ҃ѳ"]="69",
	о҃"]="70", о҃а"]="71", о҃в"]="72", о҃г"]="73", о҃д"]="74",
	о҃е"]="75", о҃є"]="75", о҃ѕ"]="76", о҃ꙅ"]="76", о҃з"]="77", о҃ꙁ"]="77", о҃и"]="78", о҃ѳ"]="79",
	ѻ҃"]="70", ѻ҃а"]="71", ѻ҃в"]="72", ѻ҃г"]="73", ѻ҃д"]="74",
	ѻ҃е"]="75", ѻ҃є"]="75", ѻ҃ѕ"]="76", ѻ҃ꙅ"]="76", ѻ҃з"]="77", ѻ҃ꙁ"]="77", ѻ҃и"]="78", ѻ҃ѳ"]="79",
	п҃"]="80", п҃а"]="81", п҃в"]="82", п҃г"]="83", п҃д"]="84",
	п҃е"]="85", п҃є"]="85", п҃ѕ"]="86", п҃ꙅ"]="86", п҃з"]="87", п҃ꙁ"]="87", п҃и"]="88", п҃ѳ"]="89",
	ч҃"]="90", ч҃а"]="91", ч҃в"]="92", ч҃г"]="93", ч҃д"]="94",
	ч҃е"]="95", ч҃є"]="95", ч҃ѕ"]="96", ч҃ꙅ"]="96", ч҃з"]="97", ч҃ꙁ"]="97", ч҃и"]="98", ч҃ѳ"]="99",
	ҁ҃"]="90", ҁ҃а"]="91", ҁ҃в"]="92", ҁ҃г"]="93", ҁ҃д"]="94",
	ҁ҃е"]="95", ҁ҃є"]="95", ҁ҃ѕ"]="96", ҁ҃ꙅ"]="96", ҁ҃з"]="97", ҁ҃ꙁ"]="97", ҁ҃и"]="98", ҁ҃ѳ"]="99",
	р҃"]="100", р҃а"]="101", р҃в"]="102", р҃г"]="103", р҃д"]="104",
	р҃е"]="105", р҃є"]="105", р҃ѕ"]="106", р҃ꙅ"]="106", р҃з"]="107", р҃ꙁ"]="107", р҃и"]="108", р҃ѳ"]="109",
	р҃і"]="110", ра҃і"]="111", рв҃і"]="112", рг҃і"]="113", рд҃і"]="114",
	ре҃і"]="115", рє҃і"]="115", рѕ҃і"]="116", рꙅ҃і"]="116", рз҃і"]="117", рꙁ҃і"]="117", ри҃і"]="118", рѳ҃і"]="119",
	р҃к"]="120", рк҃а"]="121", рк҃в"]="122", рк҃г"]="123", рк҃д"]="124",
	рк҃е"]="125", рк҃є"]="125", рк҃ѕ"]="126", рк҃ꙅ"]="126", рк҃з"]="127", рк҃ꙁ"]="127", рк҃и"]="128", рк҃ѳ"]="129",
	р҃л"]="130", рл҃а"]="131", рл҃в"]="132", рл҃г"]="133", рл҃д"]="134",
	рл҃е"]="135", рл҃є"]="135", рл҃ѕ"]="136", рл҃ꙅ"]="136", рл҃з"]="137", рл҃ꙁ"]="137", рл҃и"]="138", рл҃ѳ"]="139",
	р҃м"]="140", рм҃а"]="141", рм҃в"]="142", рм҃г"]="143", рм҃д"]="144",
	рм҃е"]="145", рм҃є"]="145", рм҃ѕ"]="146", рм҃ꙅ"]="146", рм҃з"]="147", рм҃ꙁ"]="147", рм҃и"]="148", рм҃ѳ"]="149",
	р҃н"]="150", рн҃а"]="151", рн҃в"]="152", рн҃г"]="153", рн҃д"]="154",
	рн҃е"]="155", рн҃є"]="155", рн҃ѕ"]="156", рн҃ꙅ"]="156", рн҃з"]="157", рн҃ꙁ"]="157", рн҃и"]="158", рн҃ѳ"]="159",
	р҃ѯ"]="160", рѯ҃а"]="161", рѯ҃в"]="162", рѯ҃г"]="163", рѯ҃д"]="164",
	рѯ҃е"]="165", рѯ҃є"]="165", рѯ҃ѕ"]="166", рѯ҃ꙅ"]="166", рѯ҃з"]="167", рѯ҃ꙁ"]="167", рѯ҃и"]="168", рѯ҃ѳ"]="169",
	р҃о"]="170", ро҃а"]="171", ро҃в"]="172", ро҃г"]="173", ро҃д"]="174",
	ро҃е"]="175", ро҃є"]="175", ро҃ѕ"]="176", ро҃ꙅ"]="176", ро҃з"]="177", ро҃ꙁ"]="177", ро҃и"]="178", ро҃ѳ"]="179",
	р҃ѻ"]="170", рѻ҃а"]="171", рѻ҃в"]="172", рѻ҃г"]="173", рѻ҃д"]="174",
	рѻ҃е"]="175", рѻ҃є"]="175", рѻ҃ѕ"]="176", рѻ҃ꙅ"]="176", рѻ҃з"]="177", рѻ҃ꙁ"]="177", рѻ҃и"]="178", рѻ҃ѳ"]="179",
	р҃п"]="180", рп҃а"]="181", рп҃в"]="182", рп҃г"]="183", рп҃д"]="184",
	рп҃е"]="185", рп҃є"]="185", рп҃ѕ"]="186", рп҃ꙅ"]="186", рп҃з"]="187", рп҃ꙁ"]="187", рп҃и"]="188", рп҃ѳ"]="189",
	р҃ч"]="190", рч҃а"]="191", рч҃в"]="192", рч҃г"]="193", рч҃д"]="194",
	рч҃е"]="195", рч҃є"]="195", рч҃ѕ"]="196", рч҃ꙅ"]="196", рч҃з"]="197", рч҃ꙁ"]="197", рч҃и"]="198", рч҃ѳ"]="199",
	р҃ҁ"]="190", рҁ҃а"]="191", рҁ҃в"]="192", рҁ҃г"]="193", рҁ҃д"]="194",
	рҁ҃е"]="195", рҁ҃є"]="195", рҁ҃ѕ"]="196", рҁ҃ꙅ"]="196", рҁ҃з"]="197", рҁ҃ꙁ"]="197", рҁ҃и"]="198", рҁ҃ѳ"]="199",
	с҃"]="200",
	т҃"]="300",
	у҃"]="400", ѵ҃"]="400",
	ф҃"]="500",
	х҃"]="600",
	ѱ҃"]="700",
	ѡ҃"]="800", ѿ҃"]="800",
	ц҃"]="900", ѧ҃"]="900",
	҂а"]="1000",
	҂в"]="2000",
	҂г"]="3000",
	҂д"]="4000",
	҂е"]="5000", ҂є"]="5000",
	҂ѕ"]="6000", ҂ꙅ"]="6000",
	҂з"]="7000",
	҂и"]="8000",
	҂ѳ"]="9000",
	҂і"]="10,000",
	҂к"]="20,000",
	҂л"]="30,000",
	҂м"]="40,000",
	҂н"]="50,000",
	҂ѯ"]="60,000",
	҂о"]="70,000", ҂ѻ"]="70,000",
	҂п"]="80,000",
	҂ч"]="90,000", ҂ҁ"]="90,000",
	҂р"]="100,000",
	҂с"]="200,000",
	҂т"]="300,000",
	҂у"]="400,000", ҂ѵ"]="400,000",
	҂ф"]="500,000",
	҂х"]="600,000",
	҂ѱ"]="700,000",
	҂ѡ"]="800,000", ҂ѿ"]="800,000",
	҂ц"]="900,000", ҂ѧ"]="900,000",
	҂҂а"]="1,000,000",
}

function export.tr(text, lang, sc)
	if not sc then
		sc = require("Module:languages").getByCode(lang):findBestScript(text):getCode()
	end
	
	-- Щ was pronounced differently in Old Church Slavonic
	if lang == "cu" then
		letters='Št'
		letters='št'
	else
		letters='Šč'
		letters='šč'
	end
	
	-- Ѿ was pronounced differently in Old Novgorodian
	if lang == "zle-ono" then
		letters='Ote'
		letters='ote'
	else
		letters='Otŭ'
		letters='otŭ'
	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