Module:uz-Latn-Cyrl-translit
Jump to navigation
Jump to search
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Uzbek 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:uz-Latn-Cyrl-translit/testcases.
Functions
[edit]tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local export = {}
local tt = {
["t"] = "т",
["T"] = "Т",
["r"] = "р",
["R"] = "Р",
["f"] = "ф",
["F"] = "Ф",
["oʻ"] = "ў",
["Oʻ"] = "Ў",
["yu"] = "ю",
["Yu"] = "Ю",
["sh"] = "ш",
["Sh"] = "Ш",
["n"] = "н",
["N"] = "Н",
["p"] = "п",
["p"] = "П",
["u"] = "у",
["U"] = "У",
["l"] = "л",
["L"] = "Л",
["z"] = "з",
["Z"] = "З",
["е"] = "е",
["E"] = "Э",
["Ye"] = "Е",
["g"] = "г",
["G"] = "Г",
["b"] = "б",
["B"] = "Б",
["s"] = "с",
["S"] = "С",
["x"] = "х",
["X"] = "Х",
["ch"] = "ч",
["Ch"] = "Ч",
["ya"] = "я",
["Ya"] = "Я",
["h"] = "ҳ",
["H"] = "Ҳ",
["E"] = "Э",
["m"] = "м",
["m"] = "М",
["о"] = "و",
["О"] = "و",
["i"] = "и",
["I"] = "И",
["yo"] = "ё",
["Yo"] = "Ё",
["j"] = "ж",
["J"] = "Ж",
["k"] = "к",
["K"] = "К",
["d"] = "д",
["D"] = "Д",
["v"] = "в",
["V"] = "В",
["s"] = "с",
["S"] = "С",
["a"] = "а",
["A"] = "А",
["ng"] = "нг",
["Ng"] = "Нг",
["q"] = "қ",
["Q"] = "Қ",
["gʻ"] = "ғ",
["Gʻ"] = "Ғ"
}
local vowels = "AaEeIiOoUuOʻoʻ"
local consonants = "BbChchDdGgGʻgʻHhJjKkLlMmNnNgngPpRrSsShshTtVvХхYyZz"
function export.tr(text, lang, sc)
if type(text) == "table" then
options = {}
text, script = text.args[1], text.args[2]
end
if not sc then
sc = require("Module:languages").getByCode("ky"):findBestScript(text):getCode()
end
if sc ~= "Cyrl" then
return nil
end
text =
mw.ustring.gsub(
text,
"([АОӨҮУЫЕЯЁЮИЕаоөүуыэяёюиеъь%A][́̀]?)([Ее])",
function(a, e)
return a .. (e == "е" and "йе" or "Йе")
end
):gsub("^Е", "Йе"):gsub("^е", "йе")
text = mw.ustring.gsub(text, "^([" .. consonants .. "])и([" .. consonants .. "])([^" .. e .. "])", "%1И%2%3")
text = mw.ustring.gsub(text, "([" .. vowels .. "])([" .. consonants .. "])и", "%1%2И")
text = mw.ustring.gsub(text, "^и([" .. consonants .. "])([^" .. e .. "])", "И%1%2")
text = mw.ustring.gsub(text, "([^" .. vowels .. "])([" .. consonants .. "])([" .. consonants .. "])и", "%1%2%3И")
return (mw.ustring.gsub(text, ".", tt))
end
return export