Module:tkr-translit
Appearance
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Tsakhur 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:tkr-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 gsub = mw.ustring.gsub
local u = require("Module:string utilities").char
local export = {}
function export.tr(text, lang, sc)
if sc ~= "Cyrl" then
return nil
end
-- Convert capital to lowercase palochka. Lowercase is found in tables.
text = gsub(text, u(0x4C0), u(0x4CF))
-- Digraphs with soft and hard sign.
text = gsub(text, "([хХ])х([ьъ])", "%1%2:")
text = gsub(text, "[гкхГКХ][ьъ]", {
["гь"]="h", ["Гь"]="H",
["гъ"]="ʁ", ["Гъ"]="ʁ",
["кь"]="qӏ", ["Кь"]="Qӏ",
["къ"]="q:", ["Къ"]="Q:",
["хь"]="x", ["Хь"]="X",
["хъ"]="q", ["Хъ"]="Q",
})
-- Дж and гӏ digraphs.
text = gsub(gsub(text, "дж", "ǯ"), "Дж", "Ǯ")
text = gsub(gsub(text, "гӏ", "ɣ"), "Гӏ", "Ɣ")
-- Geminate consonants.
text = gsub(text, "[птцчксхПТЦЧКСХ][птцчксх]", {
["пп"]="п:", ["Пп"]="П:",
["тт"]="т:", ["Тт"]="Т:",
["цц"]="ц:", ["Цц"]="Ц:",
["чч"]="ч:", ["Чч"]="Ч:",
["кк"]="к:", ["Кк"]="К:",
["сс"]="с:", ["Сс"]="С:",
["хх"]="х:", ["Хх"]="Х:",
})
-- General consonants.
text = gsub(text, "[птцчксшщхнлдзжгъбфмрвПТЦЧКСШЩХНЛДЗЖГЪБФМРВ]", {
["п"]="p", ["П"]="P",
["т"]="t", ["Т"]="T",
["ц"]="c", ["Ц"]="C",
["ч"]="č", ["Ч"]="Č",
["к"]="k", ["К"]="K",
["с"]="s", ["С"]="S",
["ш"]="š", ["Ш"]="Š",
["щ"]="š:", ["Щ"]="Š:",
["х"]="ꭓ", ["Х"]="Ꭓ",
["н"]="n", ["Н"]="N",
["л"]="l", ["Л"]="L",
["д"]="d", ["Д"]="D",
["з"]="z", ["З"]="Z",
["ж"]="ž", ["Ж"]="Ž",
["г"]="g", ["Г"]="G",
["ъ"]="ʔ", ["Ъ"]="ʔ",
["б"]="b", ["Б"]="B",
["ф"]="f", ["Ф"]="F",
["м"]="m", ["М"]="M",
["р"]="r", ["Р"]="R",
["в"]="v", ["В"]="V",
})
-- Palatised consonants.
text = gsub(text, "([tckdgszxnlTCKDGSZXNL]ӏ?)(:?)([иеёюя])", function (con, gem, vow)
return con .. "ʲ" .. gem .. (({ ["ё"]="о", ["ю"]="у", ["я"]="a" })[vow] or vow)
end)
-- Rounded consonants.
text = gsub(text, "([tcčkqǯgzšžxꭓʁTCČKQǮGZŠŽXꞳ]ӏ?:?)v", "%1ʷ")
-- Iotated е.
text = gsub(text, "%f[%a]е", "je")
text = gsub(text, "%f[%a]Е", "Je")
-- Ejective consonants.
text = gsub(text, "[ptcčkgqPTCČKGQ]ӏ", {
["pӏ"]="ṗ", ["Pӏ"]="Ṗ",
["tӏ"]="ṭ", ["Tӏ"]="Ṭ",
["cӏ"]="c̣", ["Cӏ"]="C̣",
["čӏ"]="č̣", ["Čӏ"]="Č̣",
["kӏ"]="ḳ", ["Kӏ"]="Ḳ",
["qӏ"]="q̇", ["Qӏ"]="Q̇",
})
-- Umlaut vowels.
text = gsub(text, "[аоуАОУ]ь", {
["аь"]="ä", ["Аь"]="Ä",
["оь"]="ö", ["Оь"]="Ö",
["уь"]="ü", ["Уь"]="Ü",
})
-- Glottalised vowels.
text = gsub(text, "([аоуыАОУЫ])ӏ", "%1ˤ")
-- Long и.
text = gsub(gsub(text, "ий", "ī"), "Ий", "Ī")
-- General vowels.
text = gsub(text, "[йиеэаыоуюяё’ЙИЕЭАЫОУЮЯЁ]", {
["й"]="j", ["Й"]="J",
["и"]="i", ["И"]="I",
["е"]="e", ["Е"]="E",
["э"]="e", ["Э"]="E",
["а"]="a", ["А"]="A",
["ы"]="ɨ", ["Ы"]="Ɨ",
["о"]="o", ["О"]="O",
["у"]="u", ["У"]="U",
["ю"]="ju", ["Ю"]="Ju",
["я"]="ja", ["Я"]="Ja",
["ё"]="jo", ["Ё"]="Jo",
["’"]="ʲ",
})
return text
end
return export