Module:Mong-translit

Hello, you have come here looking for the meaning of the word Module:Mong-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Mong-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Mong-translit in singular and plural. Everything you need to know about the word Module:Mong-translit you have here. The definition of the word Module:Mong-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Mong-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 Mongolian script. It is used to transliterate Buryat, Classical Mongolian, Daur, Mongolian, Sanskrit, Dukhan, Classical Tibetan, Middle Mongol, and Khamnigan Mongol. 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:Mong-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 gsub = mw.ustring.gsub
local match = mw.ustring.match

local export = {}

local chars = {
	 = "a",  = "e",
	 = "i",
	 = "o",  = "u",
	 = "ö",  = "ü",
	 = "ē",
	 = "n",
	 = "ng",
	 = "b",  = "p",
	 = "q",  = "ɣ",
	 = "m",  = "l",
	 = "s",  = "š",
	 = "t",  = "d",
	 = "č",  = "š̤",
	 = "ǰ",  = "y",  = "r",
	 = "w",
	 = "f",
	 = "k",  = "k",
	 = "c",  = "z",
	 = "h",
	 = "ř",
	 = "lh",
	 = "ž",
	 = "č̭",
	 = "0",  = "1",  = "2",  = "3",
	 = "4",  = "5",  = "6",  = "7",
	 = "8",  = "9",
	 = "∞",  = "…",  = ",",  = ".",  = ":",  = "::",
	 = "?",  = "!",
	 = "-",  = "-",  = "-",
	 = "",  = "",  = "",  = "",
}

local front_vowel = {
	 = "g",
	 = "k"
}

function export.tr(text, lang, sc)
	if sc ~= "Mong" then
		return nil
	end
	local bad_diphthong = match(text, "ᠥᠶ?ᠢ")
	if bad_diphthong then
		error("Diphthong " .. diphthong .. " does not exist. Please replace with " .. gsub(bad_diphthong, "ᠥ", "ᠦ") .. ".")
	end
	text = gsub(text, ".", chars)
	text = gsub(text, "%f", front_vowel)
	return text
end

return export