Module:Orkh-translit

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module will transliterate text in the Orkhon runes script. It is used to transliterate Old Turkic. 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:Orkh-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 = {
	["𐰀"] = "a", -- ORKHON A
	["𐰁"] = "a", -- YENISEI A
	["𐰂"] = "a", -- YENISEI A
	["𐰃"] = "i", -- ORKHON I
	["𐰄"] = "i", -- YENISEI I
	["𐰅"] = "é", -- YENISEI E
	["𐰆"] = "u", -- ORKHON O
	["𐰇"] = "ü", -- ORKHON OE
	["𐰈"] = "ü", -- YENISEI OE
	["𐰉"] = "b¹", -- ORKHON AB
	["𐰊"] = "b¹", -- YENISEI AB
	["𐰋"] = "b²", -- ORKHON AEB
	["𐰌"] = "b²", -- YENISEI AEB
	["𐰍"] = "ǧ", -- ORKHON AG
	["𐰎"] = "ǧ", -- YENISEI AG
	["𐰏"] = "g", -- ORKHON AEG
	["𐰐"] = "g", -- YENISEI AEG
	["𐰑"] = "d¹", -- ORKHON AD
	["𐰒"] = "d¹", -- YENISEI AD
	["𐰓"] = "d²", -- ORKHON AED
	["𐰔"] = "z", -- ORKHON EZ
	["𐰕"] = "z", -- YENISEI EZ
	["𐰖"] = "y¹", -- ORKHON AY
	["𐰗"] = "y¹", -- YENISEI AY
	["𐰘"] = "y²", -- ORKHON AEY
	["𐰙"] = "y²", -- YENISEI AEY
	["𐰚"] = "k", -- ORKHON AEK
	["𐰛"] = "k", -- YENISEI AEK
	["𐰜"] = "k̥", -- ORKHON OEK
	["𐰝"] = "k̥", -- YENISEI OEK
	["𐰞"] = "l¹", -- ORKHON AL
	["𐰟"] = "l¹", -- YENISEI AL
	["𐰠"] = "l²", -- ORKHON AEL
	["𐰡"] = "lt", -- ORKHON ELT
	["𐰢"] = "m", -- ORKHON EM
	["𐰣"] = "n¹", -- ORKHON AN
	["𐰤"] = "n²", -- ORKHON AEN
	["𐰥"] = "n²", -- YENISEI AEN
	["𐰦"] = "nt", -- ORKHON ENT
	["𐰧"] = "nt", -- YENISEI ENT
	["𐰨"] = "nč", -- ORKHON ENC
	["𐰩"] = "nč", -- YENISEI ENC
	["𐰪"] = "ń", -- ORKHON ENY
	["𐰫"] = "ń", -- YENISEI ENY
	["𐰬"] = "ń", -- YENISEI ENY
	["𐰭"] = "ŋ", -- ORKHON ENG
	["𐰮"] = "ŋ", -- YENISEI ENG
	["𐰯"] = "p", -- ORKHON EP
	["𐰰"] = "p̊", -- ORKHON OP
	["𐰱"] = "č̥", -- ORKHON IC
	["𐰲"] = "č", -- ORKHON EC
	["𐰳"] = "č", -- YENISEI EC
	["𐰴"] = "q", -- ORKHON AQ
	["𐰵"] = "q", -- YENISEI AQ
	["𐰶"] = "q̊²", -- ORKHON IQ
	["𐰷"] = "q̊²", -- YENISEI IQ
	["𐰸"] = "q̊¹", -- ORKHON OQ
	["𐰹"] = "q̊¹", -- YENISEI OQ
	["𐰺"] = "r¹", -- ORKHON AR
	["𐰻"] = "r¹", -- YENISEI AR
	["𐰼"] = "r²", -- ORKHON AER
	["𐰽"] = "s¹", -- ORKHON AS
	["𐰾"] = "s²", -- ORKHON AES
	["𐰿"] = "š̥", -- ORKHON ASH
	["𐱀"] = "š", -- ORKHON ASH
	["𐱁"] = "š", -- ORKHON ESH
	["𐱂"] = "š", -- ORKHON ESH
	["𐱃"] = "t¹", -- ORKHON AT
	["𐱄"] = "t¹", -- YENISEI AT
	["𐱅"] = "t²", -- ORKHON AET
	["𐱆"] = "t²", -- YENISEI AET
	["𐱇"] = "t̥", -- ORKHON OT
	["𐱈"] = "bš", -- ORKHON BASH
	["⁚"] = ":", -- punctuation
}

function export.tr(text, lang, sc)
	-- If the script is not Orkh, do not transliterate
	if sc ~= "Orkh" then
		return
	end
	
	-- Transliterate characters
	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end

return export