Module:Sarb-translit

Hello, you have come here looking for the meaning of the word Module:Sarb-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Sarb-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Sarb-translit in singular and plural. Everything you need to know about the word Module:Sarb-translit you have here. The definition of the word Module:Sarb-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Sarb-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 Ancient South Arabian script. It is used to transliterate Minaean, Old South Arabian, Harami, Hadrami, Qatabanian, and Sabaean. 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:Sarb-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 correspondences = {
	 = "h",  = "l",  = "ḥ",  = "m",  = "q",
	= "w",  = "s²",  = "r",  = "b",  = "t",
	 = "s¹",  = "k",  = "n",  = "ḫ",  = "ṣ",
	 = "s³",  = "f",  = "ʾ",  = "ʿ",  = "ḍ",
	 = "g",  = "d",  = "ġ",  = "ṭ",  = "z",
	 = "ḏ",  = "y",  = "ṯ",  = "ẓ",
	
	 = " ",
}

local numbers = {
	 = "1",
	 = "5",
	 = "10",
	 = "50",
	 = "100",
	 = "1000",
}

function export.tr(text, lang, sc)
	-- Interpret numbers.
	-- Will not work for thousands!
	text = text:gsub(
		"𐩿(..-)𐩿",
		function (number)
			local value = 0
			for digit in mw.ustring.gmatch(number, ".") do
				value = value + numbers or error("The character " .. digit .. " in " .. number .. " does not have a numeric value.")
			end
			return value
		end)
	
	text = mw.ustring.gsub(text, ".", correspondences)
	
	return text
end

return export