Module:ug-translit

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

This module will transliterate Uyghur 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:ug-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 data = {}

data = {
	-- consonants
	 = "m",   = "n",   = "d",   = "t",
	 = "b",   = "p",   = "f",   = "q",
	 = "k",   = "ng",  = "g",   = "gh",
	 = "h",   = "x",   = "ch",
	 = "j",  = "zh",  = "z",   = "s",
	 = "sh",  = "r",   = "l",   = "'",
	 = "y",   = "w",
	-- vowels
	 = "a",  = "e",  = "ë",  = "i",
	 = "o",  = "ö",  = "u",  = "ü",
	-- punctuation
	="?",
	=",",
	=";",
	="-"
}

data = data

data = {
	 = "A",  = "B",  = "W",  = "G",  = "Gh",  = "D",  = "Ë",  = "E",  = "Zh",  = "J",
	 = "Z",  = "I",  = "Y",  = "K",  = "Q",  = "L",  = "M",  = "N",  = "Ng",  = "O",
	 = "Ö",  = "P",  = "R",  = "S",  = "T",  = "U",  = "Ü",  = "F",  = "X",  = "H",
	 = "Ch",  = "Sh",  = "Yu",  = "Ya",
	 = "É",
	 = "a",  = "b",  = "w",  = "g",  = "gh",  = "d",  = "ë",  = "e",  = "zh",  = "j",
	 = "z",  = "i",  = "y",  = "k",  = "q",  = "l",  = "m",  = "n",  = "ng",  = "o",
	 = "ö",  = "p",  = "r",  = "s",  = "t",  = "u",  = "ü",  = "f",  = "x",  = "h",
	 = "ch",  = "sh",  = "yu",  = "ya",
	 = "é",
}


function export.tr(text, lang, sc)
	if not sc then
		sc = require("Module:languages").getByCode(lang):findBestScript(text):getCode()
	end
	
	if sc ~= "ug-Arab" and sc ~= "Arab" and sc ~= "Cyrl" then
		return nil
	end
	
	-- remove initial hamza
	text = mw.ustring.gsub(text, "^\216\166(.)", "%1")
	text = mw.ustring.gsub(text, "%s\216\166(.)", " %1")
	
	-- add apostrophe in some cases
	text = mw.ustring.gsub(text, "()()()", "%1'%2%3") -- V'ngV
	text = mw.ustring.gsub(text, "()()", "%1'%2") -- n'g & n'gh
	text = mw.ustring.gsub(text, "()()", "%1'%2") -- ng'h
	text = mw.ustring.gsub(text, "()()", "%1'%2") -- z'h

	text = mw.ustring.gsub(text, '.', data)

	return text
end

return export