বিষয়বস্তুতে চলুন

মডিউল:khv-translit

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:khv-translit/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

local mapping1 = {
	["п"] = "p", ["б"] = "b",
	["т"] = "t", ["д"] = "d",
	["к"] = "k", ["г"] = "g",
	["ц"] = "c", ["ч"] = "č",
	["с"] = "s", ["з"] = "z", ["ш"] = "š", ["ж"] = "ž", ["х"] = "x",
	["м"] = "m", ["н"] = "n",
	["р"] = "r", ["л"] = "l",
	["в"] = "v", ["й"] = "y",
    ["а"] = "a", ["е"] = "e", ["э"] = "e", ["и"] = "i", ["о"] = "o", ["у"] = "u", ["ы"] = "ɨ",
	["ā"] = "ā", ["е̄"] = "ē", ["ӣ"] = "ī", ["о̄"] = "ō", ["ӯ"] = "ū", ["ы̄"] = "ɨ̄",
    ["ъ"] = "ʾ",
}

local mapping2 = {
	["пӏ"] = "p’", ["тӏ"] = "t’", ["кӏ"] = "k’", ["къ"] = "q’",
	["цӏ"] = "c’", ["лӏ"] = "ƛ", ["кь"] = "ƛ’", ["чӏ"] = "č’", ["хъ"] = "q",
	["лъ"] = "λ", ["гъ"] = "ġ", ["хӏ"] = "ḥ", ["гӏ"] = "a̯", ["гь"] = "h",
	["аᵸ"] = "ã", ["еᵸ"] = "ẽ", ["эᵸ"] = "ẽ", ["иᵸ"] = "ĩ", ["оᵸ"] = "õ", ["уᵸ"] = "ũ",
    ["аӏ"] = "aʿ", ["еӏ"] = "eʿ", ["иӏ"] = "iʿ", ["оӏ"] = "oʿ", ["уӏ"] = "uʿ",
}

function export.tr(text, lang, sc)
	local str_gsub = string.gsub
	local UTF8_char = "[%z\1-\127\194-\244][\128-\191]*"
	
	text = str_gsub(text, mw.ustring.char(0x4C0), mw.ustring.char(0x4CF))
	
	for pat, repl in pairs(mapping2) do
		text = str_gsub(text, pat, repl)
	end
	text = str_gsub(text, UTF8_char, mapping1)

	return text
end

return export