Module:peo-translit

Hello, you have come here looking for the meaning of the word Module:peo-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:peo-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:peo-translit in singular and plural. Everything you need to know about the word Module:peo-translit you have here. The definition of the word Module:peo-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:peo-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate Old Persian 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:peo-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 alphabetic_tt = {
	-- this should only contain alphabetic characters
	 = "a",
	 = "i",
	 = "u",
	 = "k",
	 = "ku",
	 = "g",
	 = "gu",
	 = "x",
	 = "c",
	 = "j",
	 = "ji",
	 = "t",
	 = "tu",
	 = "d",
	 = "di",
	 = "du",
	 = "θ",
	 = "p",
	 = "b",
	 = "f",
	 = "n",
	 = "nu",
	 = "m",
	 = "mi",
	 = "mu",
	 = "y",
	 = "v",
	 = "vi",
	 = "r",
	 = "ru",
	 = "l",
	 = "s",
	 = "z",
	 = "š",
	 = "ç",
	 = "h",
	 = "AM", -- Auramazdā
	 = "AM", -- Auramazdā
	 = "AMha", -- Auramazdāha
	 = "XŠ", -- xšāyathiya 
	 = "DH", -- dahyāuš
	 = "DH", -- dahyāuš
	 = "BG", -- baga
	 = "BU", -- būmiš
}

local nonalphabetic_tt = {
	 = " : ", --word divider
}

local numbers = {
	 = 1,
	 = 2,
	 = 10,
	 = 20,
	 = 100,
}

function export.convert_numbers(numeric_str)
	local total = 0
	for c in mw.ustring.gmatch(numeric_str, ".") do
		total = total + numbers
	end
	return total
end

function export.tr(text, lang, sc)
	-- If the script is not Xpeo, do not transliterate
	if sc ~= "Xpeo" then
		return
	end
	
	local t = {}
	local preceding_num = false
	local need_hyphen = false
	-- Transliterate characters
	text = mw.ustring.gsub(text,
		".",
		function(c)
			if alphabetic_tt then
				if need_hyphen then
					t = "-"
				end
				t = alphabetic_tt
				need_hyphen = true
			else
				need_hyphen = false
				if numbers then
					if preceding_num then
						t = t + numbers
					else
						t = numbers
					end
					preceding_num = true
				else
					preceding_num = false
					t = nonalphabetic_tt or c
				end
			end
		end)

	return table.concat(t)
end

return export