Notice: This module is not the primary transliteration module for Kazakh, for that see Module:languages/data/2. This module generates Latin spellings for Template:kk-alt.
For the Yañalif (old Latin spelling) correspondence, see this correspondence chart written in 1931 in the Soviet Union, and this chart on Kazakh Wikipedia.
This module will transliterate Kazakh language text per WT:KK TR.
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:kk-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local vowels = "үҮиИеЕәӘөӨӯӮАаоОЫыІіЯяЮюЁё"
local rsubn = mw.ustring.gsub
local tt = {
="ü",="Ü",="t",="T",="h",="H",="r",="R"
,="f",="F",="ş",="Ş",="n",="N",="p",="P"
,="i",="İ",="l",="L",="z",="Z",="e",="E"
,="g",="G",="b",="B",="u",="U",="s",="S"
,="x",="X",="y",="Y",="m",="M",="o",="O"
,="i",="I",="j",="J",="k",="K",="d",="D"
,="v",="V",="a",="A",="ñ",="Ñ",="ä",="Ä"
,="e",="E",="ū",="Ū",="q",="Q",="ğ",="Ğ"
,="ı",="ı",="ö",="Ö"
--mostly in loanwords from Russian
,="io",="İo",="ts",="TS",="tş",="Tş",="ştş",="Ştş"
,="",="",="e",="E",="iu",="İu"
,="ia",="İa",="u",="U"
};
-- Main translit
function export.tr(text, lang, sc)
if type(text) == "table" then
options = {}
text, script = text.args, text.args
end
if not sc then
sc = require("Module:languages").getByCode("kk"):findBestScript(text):getCode()
end
if sc ~= "Cyrl" then
return nil
end
text = rsubn(text, "нг()", "ң%1")
text = rsubn(text, "Нг()", "Ң%1")
text = rsubn(text, "нг$", "ң")
text = rsubn(text, "()я", "%1ә")
text = rsubn(text, "()Я", "%1Ә")
text = rsubn(text, "()", "%1")
--currently it is not clear how these two are romanized
text = rsubn(text, "щ", "ш")
text = rsubn(text, "Щ", "Ш")
text = rsubn(text,"" , "" )
--remove them if their romanization changes
text = rsubn(text, '.', tt)
return text
end
-- NOT MAIN TRANSLIT
-- Yañalif 1938 version
local yanalif = {
="y",="Y",="c",="C",="i",="I",="ʙ"
,="ь",="Ь",="i",="I",="ç",="Ç"
,="ꞑ",="Ꞑ",="ə",="Ə",="ƣ",="Ƣ"
,="j",="J",="ɵ",="Ɵ"
--mostly in loanwords from Russian
,="io",="Io",="c",="Tc",="cc",="Cc"
,="ʼ",="ʼ",="iu",="Iu"
,="ia",="Ia"}
--Yañalif 1927 version
local oldyan = {
="y",="Y",="c",="C",="i",="I",="ʙ"
,="ь",="Ь",="j",="J",="ç",="Ç"
,="ꞑ",="Ꞑ",="ə",="Ə",="ƣ",="Ƣ"
,="i",="I",="ɵ",="Ɵ",="ʙ",="B"
,="p",="P",="h",="H",="v",="V"
,="u",="U"
--mostly in loanwords from Russian
,="io",="Io",="c",="Tc",="cc",="Cc"
,="ʼ",="ʼ",="iu",="Iu"
,="ia",="Ia"}
--Pinyin
local pinyin = {
="ü",="Ü",="x",="X",="y",="Y"
,="e",="E",="y",="Y",="w",="W"
,="ng",="ng",="ə",="Ə",="ƣ",="Ƣ"
,="i",="I",="ɵ",="Ɵ",="ⱨ",="Ⱨ"
,="h",="H",="ⱪ",="Ⱪ",="ê",="ê"
,="u",="U"
--mostly in loanwords from Russian
,="io",="Io",="q",="Q",="x",="X"
,="ʼ",="ʼ",="iu",="Iu",="",=""
,="ia",="Ia"}
-- Yanalif 1938 version
function export.yanalif(text, lang, sc)
if type(text) == "table" then
options = {}
text, script = text.args, text.args
end
if not sc then
sc = require("Module:languages").getByCode("kk"):findBestScript(text):getCode()
end
if sc ~= "Cyrl" then
return nil
end
text = rsubn(text, "нг()", "ң%1")
text = rsubn(text, "Нг()", "Ң%1")
text = rsubn(text, "нг$", "ң")
text = rsubn(text, "()я", "%1ә")
text = rsubn(text, "()Я", "%1Ә")
text = rsubn(text, "()", "%1")
text = rsubn(text, '.', yanalif)
text = rsubn(text, '.', tt)
return text
end
local frontur = "әӘіІ"
local backur = "АаЫы"
local frontround = "үҮөӨ"
local backround = "ӯӮоОҰұ"
local consonant = ""
-- Yanalif pre 1927 version
function export.oldyan(text, lang, sc)
if type(text) == "table" then
options = {}
text, script = text.args, text.args
end
if not sc then
sc = require("Module:languages").getByCode("kk"):findBestScript(text):getCode()
end
if sc ~= "Cyrl" then
return nil
end
text = rsubn(text, "нг()", "ң%1")
text = rsubn(text, "Нг()", "Ң%1")
text = rsubn(text, "нг$", "ң")
text = rsubn(text, "()я", "%1ә")
text = rsubn(text, "()Я", "%1Ә")
-- check preceeding vowel
-- for w
text = rsubn(text, "()(" .. consonant .. ")у", "%1%2ыу")
text = rsubn(text, "()(" .. consonant .. ")у", "%1%2ұу")
text = rsubn(text, "()(" .. consonant .. ")у", "%1%2іу")
text = rsubn(text, "()(" .. consonant .. ")у", "%1%2үу")
-- for j
text = rsubn(text, "()(" .. consonant .. "?)и", "%1%2ыи")
text = rsubn(text, "()(" .. consonant .. "?)и", "%1%2іи")
-- if none, check following vowel
-- for w
text = rsubn(text, "()У(" .. consonant .. "?)()", "%1ЫУ%2%3")
text = rsubn(text, "()у(" .. consonant .. "?)()", "%1ыу%2%3")
text = rsubn(text, "()У(" .. consonant .. "?)()", "%1ҰУ%2%3")
text = rsubn(text, "()у(" .. consonant .. "?)()", "%1ұу%2%3")
text = rsubn(text, "()У(" .. consonant .. "?)()", "%1ІУ%2%3")
text = rsubn(text, "()у(" .. consonant .. "?)()", "%1іу%2%3")
text = rsubn(text, "()У(" .. consonant .. "?)()", "%1ҮУ%2%3")
text = rsubn(text, "()у(" .. consonant .. "?)()", "%1үу%2%3")
-- for j
text = rsubn(text, "()и(" .. consonant .. "?)()", "%1ыи%2%3")
text = rsubn(text, "()и(" .. consonant .. "?)()", "%1іи%2%3")
text = rsubn(text, "()И(" .. consonant .. "?)()", "%1ЫИ%2%3")
text = rsubn(text, "()И(" .. consonant .. "?)()", "%1ІИ%2%3")
text = rsubn(text, "^И(" .. consonant .. "?)()", "ЫИ%1%2")
text = rsubn(text, "^И(" .. consonant .. "?)()", "ІИ%1%2")
-- final touches
text = rsubn(text, "()", "%1")
text = rsubn(text, '.', oldyan)
text = rsubn(text, '.', tt)
return text
end
-- Pinyin
function export.pinyin(text, lang, sc)
if type(text) == "table" then
options = {}
text, script = text.args, text.args
end
if not sc then
sc = require("Module:languages").getByCode("kk"):findBestScript(text):getCode()
end
if sc ~= "Cyrl" then
return nil
end
text = rsubn(text, "()я", "%1ә")
text = rsubn(text, "()Я", "%1Ә")
text = rsubn(text, "()", "%1")
text = rsubn(text, "()", "%1ұу")
text = rsubn(text, "()", "%1ұУ")
text = rsubn(text, "^()", "ұу%1")
text = rsubn(text, "^()", "ұУ%1")
text = rsubn(text, '.', pinyin)
text = rsubn(text, '.', tt)
return text
end
return export