Module:sish-translit

Revision as of 19:47, 12 June 2026 by Sware (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This module will transliterate Ossamic language text. 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:sish-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 tt = {}
tt["Armn"] = {
	{"Ու", "U"}, {"ու", "u"},
	
	{"Ա", "A"}, {"ա", "a"},
	{"Բ", "B"}, {"բ", "b"},
	{"Վ", "V"}, {"վ", "v"},
	{"Գ", "G"}, {"գ", "g"},
	{"Դ", "D"}, {"դ", "d"},
	{"Ե", "E"}, {"ե", "e"},
	{"Է", "Ē"}, {"է", "ē"},
	{"Ժ", "Ž"}, {"ժ", "ž"},
	{"Զ", "Z"}, {"զ", "z"},
	{"Ի", "I"}, {"ի", "i"},
	{"Ձ", "J"}, {"ձ", "j"},
	{"Կ", "K"}, {"կ", "k"},
	{"Լ", "L"}, {"լ", "l"},
	{"Մ", "M"}, {"մ", "m"},
	{"Ն", "N"}, {"ն", "n"},
	{"Ո", "O"}, {"ո", "o"},
	{"Օ", "Ō"}, {"օ", "ō"},
	{"Պ", "P"}, {"պ", "p"},
	{"Ր", "R"}, {"ր", "r"},
	{"Ս", "S"}, {"ս", "s"},
	{"Տ", "T"}, {"տ", "t"},
	{"Ֆ", "F"}, {"ֆ", "f"},
	{"Հ", "H"}, {"հ", "h"},
	{"Ծ", "C"}, {"ծ", "c"},
	{"Ճ", "Č"}, {"ճ", "č"},
	{"Ջ", "J̌"}, {"ջ", "ǰ"},
	{"Շ", "Š"}, {"շ", "š"},
	{"Յ", "Y"}, {"յ", "y"},
	{"Խ", "X"}, {"խ", "x"},
	{"Ղ", "Ġ"}, {"ղ", "ġ"},
	{"Ը", "Ə"}, {"ը", "ə"},
	{"Ռ", "Ṙ"}, {"ռ", "ṙ"},
	{"Փ", "Pʻ"}, {"փ", "pʻ"},
	{"Թ", "Tʻ"}, {"թ", "tʻ"},
	{"Ք", "Kʻ"}, {"ք", "kʻ"},
	{"Ց", "Cʻ"}, {"ց", "cʻ"},
	{"Չ", "Čʻ"}, {"չ", "čʻ"},
	{"ւ", "w"},
	{"՝", ","}, {"։", "."}, {"․", ";"}, {"՛", "́"}, {"՜", "<sup>!</sup>"}, {"՞", "<sup>?</sup>"},
	{"՟", "."}, {"֊", "-"}, {"՚", "’"}, {"«", "“"}, {"»", "”"}, {"ՙ", "ʻ"}

};

tt["Latn"] = {
	--Digraphs
	{"U", "Ու"}, {"u", "ու"},

	{"A", "Ա"}, {"a", "ա"},
	{"B", "Բ"}, {"b", "բ"},
	{"V", "Վ"}, {"v", "վ"},
	{"G", "Գ"}, {"g", "գ"},
	{"D", "Դ"}, {"d", "դ"},
	{"E", "Ե"}, {"e", "ե"},
	{"Ē", "Է"}, {"ē", "է"},
	{"Ž", "Ժ"}, {"ž", "ժ"},
	{"Z", "Զ"}, {"z", "զ"},
	{"I", "Ի"}, {"i", "ի"},
	{"J", "Ձ"}, {"j", "ձ"},
	{"K", "Կ"}, {"k", "կ"},
	{"L", "Լ"}, {"l", "լ"},
	{"M", "Մ"}, {"m", "մ"},
	{"N", "Ն"}, {"n", "ն"},
	{"O", "Ո"}, {"o", "ո"},
	{"Ō", "Օ"}, {"ō", "օ"},
	{"P", "Պ"}, {"p", "պ"},
	{"R", "Ր"}, {"r", "ր"},
	{"S", "Ս"}, {"s", "ս"},
	{"T", "Տ"}, {"t", "տ"},
	{"F", "Ֆ"}, {"f", "ֆ"},
	{"H", "Հ"}, {"h", "հ"},
	{"C", "Ծ"}, {"c", "ծ"},
	{"Č", "Ճ"}, {"č", "ճ"},
	{"J̌", "Ջ"}, {"ǰ", "ջ"},
	{"Š", "Շ"}, {"š", "շ"},
	{"Y", "Յ"}, {"y", "յ"},
	{"X", "Խ"}, {"x", "խ"},
	{"Ġ", "Ղ"}, {"ġ", "ղ"},
	{"Ə", "Ը"}, {"ə", "ը"},
	{"Ṙ", "Ռ"}, {"ṙ", "ռ"},
	{"Pʻ", "Փ"}, {"pʻ", "փ"},
	{"Tʻ", "Թ"}, {"tʻ", "թ"},
	{"Kʻ", "Ք"}, {"kʻ", "ք"},
	{"Cʻ", "Ց"}, {"cʻ", "ց"},
	{"Čʻ", "Չ"}, {"čʻ", "չ"},
	{"w", "ւ"},
	{"%-", "֊"}
};

function export.tr(text, lang, sc)
	for _, rule in ipairs(tt[sc]) do
		text = mw.ustring.gsub(text, rule[1], rule[2])
	end

    return text
end

return export