Module:typing-aids/data/Cyrs

From Wiktionary, the free dictionary
Jump to navigation Jump to search
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local U = mw.ustring.char

local caron = U(0x30C)
local breve = U(0x306)
local grave = U(0x300)
local hook = U(0x328)

local data = {
	{
		-- Letters with diacritics in a shortcut sequence are decomposed before
		-- being run through the substitutions
		["s" .. caron .. "t"] = "щ",
	},
	{
		["jo~"] = "ѭ",
		["je~"] = "ѩ",
		["i" .. breve] = "ь",	-- ĭ
		["e" .. caron] = "ѣ",	-- ě
		["o" .. hook] = "ѫ",	-- ǫ
		["e" .. hook] = "ѧ",	-- ę
		["i" .. grave] = "і",	-- ì
		["z" .. caron] = "ж",	-- ž
		["c" .. caron] = "ч",	-- č
		["s" .. caron] = "ш",	-- š
		["sht"] = "щ",
		["u" .. breve] = "ъ",	-- ŭ
	},
	{
		["zh"] = "ж",
		["d^z"] = "ѕ",
		["i\\"] = "і",
		["o_"] = "ѡ",
		["ch"] = "ч",
		["sh"] = "ш",
		["uh"] = "ъ",
		["ih"] = "ь",
		["eh"] = "ѣ",
		["ja"] = "ꙗ",
		["je"] = "ѥ",
		["ju"] = "ю",
		["o~"] = "ѫ",
		["jǫ"] = "ѭ",
		["e~"] = "ѧ",
		["ję"] = "ѩ",
		["k^s"] = "ѯ",
		["p^s"] = "ѱ",
		["th"] = "ѳ",
		["y\\"] = "ѵ",
	},
	{
		["a"] = "а",
		["b"] = "б",
		["v"] = "в",
		["g"] = "г",
		["d"] = "д",
		["e"] = "е",
		["z"] = "з",
		["i"] = "и",
		["k"] = "к",
		["l"] = "л",
		["m"] = "м",
		["n"] = "н",
		["o"] = "о",
		["p"] = "п",
		["r"] = "р",
		["s"] = "с",
		["t"] = "т",
		["u"] = "оу",
		["f"] = "ф",
		["x"] = "х",
		["ō"] = "ѡ",
		["c"] = "ц",
		["y"] = "ꙑ",
		["ξ"] = "ѯ",
		["ѱ"] = "ѱ",
		["θ"] = "ѳ",
		["ü"] = "ѵ",
		["q"] = "ҁ",
	},
}

-- Add replacements for capitals: both an all-caps version ("JA")
-- and capitalized version ("Ja").
for _, replacements in ipairs(data) do
	-- sortedPairs saves the list of table keys so that we can modify the table
	-- while iterating over it.
	for text, replacement in require "Module:table".sortedPairs(replacements) do
		replacement = mw.ustring.upper(replacement)
		replacements[mw.ustring.upper(text)] = replacement
		replacements[mw.ustring.gsub(text, "^.", mw.ustring.upper)] = replacement
	end
end

return data