% babel-kazakh-manual.tex
% Documentation for the babel-kazakh package
% Copyright (C) 2026 Berik I. Tuleuov
%
% This file is part of the babel-kazakh package.
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, version 1.3c or any later version.

\documentclass[11pt,a4paper]{article}

\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1,T2A]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{lmodern}
\else
  \usepackage{fontspec}
  \setmainfont{DejaVu Serif}
  \setsansfont{DejaVu Sans}
  \setmonofont{DejaVu Sans Mono}
\fi
\usepackage[english]{babel}
\usepackage{microtype}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{enumitem}
\usepackage{fancyvrb}
\usepackage{metalogo}
\usepackage{hyperref}

\definecolor{KazakhBlue}{HTML}{175A8C}
\definecolor{CodeBackground}{HTML}{F4F6F8}
\definecolor{RuleGray}{HTML}{C8CDD2}

\hypersetup{
  colorlinks=true,
  linkcolor=KazakhBlue,
  urlcolor=KazakhBlue,
  citecolor=KazakhBlue,
  pdftitle={The babel-kazakh package},
  pdfauthor={Berik I. Tuleuov}
}

\setlist{nosep,leftmargin=2em}
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\renewcommand{\arraystretch}{1.18}

\newcommand*{\pkg}[1]{\textsf{#1}}
\newcommand*{\file}[1]{\nolinkurl{#1}}
\newcommand*{\code}[1]{\texttt{#1}}
\newcommand*{\Kazakh}{Kazakh}

\DefineVerbatimEnvironment{codeblock}{Verbatim}{
  fontsize=\small,
  frame=single,
  framesep=3mm,
  rulecolor=\color{RuleGray},
  formatcom=\color{black}
}

\title{%
  \vspace{-12mm}
  {\color{KazakhBlue}\bfseries The \pkg{babel-kazakh} package}\par
  \vspace{2mm}
  \large Kazakh language support for pdf\LaTeX, \XeLaTeX, and \LuaLaTeX
}
\author{Berik I. Tuleuov\\[2mm]
  \small Astana, Kazakhstan\\
  \small \href{mailto:berik_t@yahoo.com}{berik\_t@yahoo.com}}
\date{Documentation revised November 21, 2026}

\begin{document}

\maketitle

\begin{abstract}
The \pkg{babel-kazakh} package provides Kazakh language support for
\LaTeX.  It supports the traditional \pkg{Babel} interface with
pdf\LaTeX, \XeLaTeX, and \LuaLaTeX, and it also provides a
\pkg{Polyglossia} language definition for the Unicode engines.  The
package supplies Kazakh captions, date strings, typographical conventions,
and preliminary \pkg{BibLaTeX} localization.  Kazakh locale data for the
modern \pkg{Babel} interface is maintained in the main \pkg{Babel}
distribution.
\end{abstract}

\tableofcontents

\section{Background and scope}

Work on the package followed the development of a Kazakh hyphenation
dictionary in February 2026.  The goal of \pkg{babel-kazakh} is to make
Kazakh documents usable with all three major \LaTeX{} engines while keeping
the language conventions consistent between \pkg{Babel},
\pkg{Polyglossia}, and \pkg{BibLaTeX}.

The current support covers:

\begin{itemize}
  \item Kazakh captions and Gregorian date names;
  \item the number--name order required for parts, chapters, appendices,
        figures, and tables;
  \item language switching in multilingual documents;
  \item Kazakh hyphenation when the corresponding patterns are installed;
  \item preliminary bibliography strings for \pkg{BibLaTeX}.
\end{itemize}

\section{Package components}

The runtime files supplied by \pkg{babel-kazakh} are listed below.

\begin{center}
\begin{tabularx}{\textwidth}{@{}>{\ttfamily\raggedright\arraybackslash}p{.38\textwidth}X@{}}
\toprule
\normalfont File & Purpose \\
\midrule
kazakh.ldf & Traditional \pkg{Babel} language definition. \\
kazakh.sty & Compatibility interface for Kazakh support. \\
gloss-kazakh.ldf & Kazakh language definition for \pkg{Polyglossia}. \\
gloss-kk.ldf & BCP~47 alias used by \pkg{Polyglossia}. \\
kazakh.lbx & Kazakh localization strings for \pkg{BibLaTeX}. \\
\bottomrule
\end{tabularx}
\end{center}

The file \file{babel-kk.ini} is \emph{not} distributed by this package.
Starting with \pkg{Babel} 26.16 (November 10, 2026), the Kazakh locale file
is part of the main \pkg{Babel} distribution and is installed as

\begin{center}
\file{tex/generic/babel/locale/kk/babel-kk.ini}.
\end{center}

Corrections to that locale should therefore be reported to the main
\pkg{Babel} project at
\url{https://github.com/latex3/babel/issues}.

\section{Engine and package support}

\begin{center}
\begin{tabular}{@{}llll@{}}
\toprule
Engine & \pkg{Babel} & \pkg{Polyglossia} & Bibliography test \\
\midrule
pdf\LaTeX & yes & no & \pkg{BibLaTeX}+\pkg{Biber} \\
\XeLaTeX  & yes & yes & \pkg{BibLaTeX}+\pkg{Biber} \\
\LuaLaTeX & yes & yes & \pkg{BibLaTeX}+\pkg{Biber} \\
\bottomrule
\end{tabular}
\end{center}

For pdf\LaTeX, use UTF-8 input and the T2A font encoding.  For the two
Unicode engines, select OpenType fonts containing the Kazakh Cyrillic
characters.  Every main, sans-serif, or monospaced family used in Kazakh
text must provide the required Cyrillic glyphs.

The package and the supplied tests were developed and tested with TeX Live
2025 under Linux.  Under Windows, \XeLaTeX{} and \LuaLaTeX{} can use either
fonts installed in Windows or suitable fonts installed with the TeX
distribution.  The test drivers name the DejaVu Serif, DejaVu Sans, and
DejaVu Sans Mono families explicitly.  If they are unavailable, install the
DejaVu fonts or replace all three names with Windows fonts that contain the
Kazakh Cyrillic characters.  The main, sans-serif, and monospaced selections
must all provide Cyrillic coverage; this is checked particularly strictly by
\pkg{Polyglossia}.  The pdf\LaTeX{} test does not use Windows OpenType fonts:
it relies on the T2A-encoded fonts installed by the TeX distribution.

\section{Quick start with Babel}

\subsection{pdf\LaTeX}

The traditional interface uses \file{kazakh.ldf}:

\begin{codeblock}
\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[kazakh]{babel}

\begin{document}
Қазақ тіліндегі мәтін.
\end{document}
\end{codeblock}

Compile the document with:

\begin{codeblock}
pdflatex document.tex
\end{codeblock}

\subsection{XeLaTeX and LuaLaTeX}

The modern locale interface is recommended for Unicode engines:

\begin{codeblock}
\documentclass{article}
\usepackage[english]{babel}
\usepackage{fontspec}
\setmainfont{DejaVu Serif}
\babelprovide[import,main]{kazakh}

\begin{document}
Қазақ тіліндегі мәтін.

\foreignlanguage{english}{An English sentence.}
\end{document}
\end{codeblock}

Compile with either:

\begin{codeblock}
xelatex document.tex
\end{codeblock}

or:

\begin{codeblock}
lualatex document.tex
\end{codeblock}

\section{Quick start with Polyglossia}

\pkg{Polyglossia} requires \XeLaTeX{} or \LuaLaTeX.  The test driver uses
fonts from the DejaVu family because all three selected families contain
Cyrillic glyphs.

\begin{codeblock}
\documentclass{article}
\usepackage{fontspec}
\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
\usepackage{polyglossia}
\setmainlanguage{kazakh}
\setotherlanguage{english}

\begin{document}
Қазақ тіліндегі мәтін.

\foreignlanguage{english}{An English sentence.}
\end{document}
\end{codeblock}

If a selected font lacks the Cyrillic script, \pkg{Polyglossia} reports an
error.  Set every font family actually used by the document to a font with
Kazakh Cyrillic coverage.

\section{Kazakh numbering and captions}

Kazakh places the number before the common noun in the names tested by the
package.  The common noun begins with a lowercase letter:

\begin{center}
\setlength{\tabcolsep}{18pt}
\begin{tabular}{@{}ll@{}}
\toprule
Document element & Expected form \\
\midrule
Part    & \textbf{1 бөлім} \\
Chapter & \textbf{3 тарау} \\
Appendix & \textbf{A қосымша} \\
Figure  & \textbf{7 сурет} \\
Table   & \textbf{10 кесте} \\
\bottomrule
\end{tabular}
\end{center}

The same ordering is used by the Unicode locale data, the LICR data needed
by pdf\LaTeX, the traditional \file{kazakh.ldf} implementation, and the
\pkg{Polyglossia} definition.

The shared test body contains numbered parts, chapters, sections, an
appendix, two tables, and two figures.  For example:

\begin{codeblock}
\part{Қазақ тілін қолдау құралдарын тексеру}

\ifcsname chapter\endcsname
  \chapter{Тараулар мен қосымшаларды тексеру}
\fi

\begin{table}[htbp]
  \centering
  \caption{Қарапайым сандық кесте}
  ...
\end{table}

\begin{figure}[htbp]
  \centering
  ...
  \caption{Сынық сызықтың шартты графигі}
\end{figure}
\end{codeblock}

Changing the class in either test driver from \code{article} to
\code{report} or \code{book} activates the chapter tests.  The \code{book}
class also makes it possible to inspect the Kazakh order in running heads.

\section{Bibliography support}

The package contains \file{kazakh.lbx}, which provides Kazakh localization
for \pkg{BibLaTeX}.  This localization is still under development.  The
test database \file{refs.bib} contains Kazakh and English sources, including
books, a dissertation, and an online resource.

A parent document loads the database as follows:

\begin{codeblock}
\usepackage[backend=biber]{biblatex}
\addbibresource{refs.bib}
\end{codeblock}

Entries written in Kazakh use \code{langid = \{kazakh\}}.  One example from
the supplied database is:

\begin{codeblock}
@book{kz_orph,
  author    = {Сыздық, Р. and Уәлиұлы, Н. and
               Күдеринова, Қ. and Фазылжанова, А. and others},
  title     = {Қазақ тілінің орфографиялық сөздігі: 53 000 сөз},
  location  = {Алматы},
  publisher = {Арыс},
  date      = {2005},
  pagetotal = {616},
  langid    = {kazakh}
}
\end{codeblock}

The complete compilation sequence is:

\begin{codeblock}
<engine> test-file.tex
biber test-file
<engine> test-file.tex
<engine> test-file.tex
\end{codeblock}

Here \code{<engine>} is \code{pdflatex}, \code{xelatex}, or
\code{lualatex}, as permitted by the selected language package.

\section{Hyphenation tests}

The \pkg{Babel} and \pkg{Polyglossia} drivers use the same list of Kazakh
words.  Two complementary mechanisms are employed:

\begin{itemize}
  \item \verb|\showhyphens| writes the possible break points to the log;
  \item the \pkg{testhyphens} environment prints the same kind of test
        material in the document, arranged in three columns.
\end{itemize}

The tests explicitly set

\begin{codeblock}
\lefthyphenmin=2
\righthyphenmin=2
\end{codeblock}

and include native words, derived forms, loanwords, and difficult vowel
sequences.  Examples include \textit{құмырсқа}, \textit{күңгірттеу},
\textit{жаңғыртты}, \textit{балуан}, \textit{тәрбие}, and
\textit{офтальмология}.

\section{The supplied test suite}

There are exactly two standalone, compilable test drivers.  Both include
the same headless body and use the same bibliography database.

\begin{center}
\begin{tabularx}{\textwidth}{@{}>{\footnotesize\raggedright\arraybackslash}p{.38\textwidth}X@{}}
\toprule
\normalfont File & Role \\
\midrule
\path{kazakh-unversal-bib-test.tex} & Universal \pkg{Babel} driver.  It selects
pdf\LaTeX{} settings automatically and uses the modern locale interface
under \XeLaTeX{} or \LuaLaTeX. \\
\path{kazakh-polyglossia-bib-test.tex} & \pkg{Polyglossia} driver for \XeLaTeX{}
and \LuaLaTeX.  Under pdf\LaTeX{} it produces an explanatory page instead
of attempting to load \pkg{Polyglossia}. \\
\bottomrule
\end{tabularx}
\end{center}

The supporting files are:

\begin{description}[style=nextline]
  \item[\file{kazakh-test-body.tex}]
    A headless fragment containing structural tests, formulas, cross
    references, tables, figures created with the standard \LaTeX{}
    \code{picture} environment, an appendix, citations, and the bibliography
    command.
  \item[\file{variables.sty}]
    A local helper belonging to the test suite.  It reports the engine,
    language package and version, document class, and class options in the
    generated test document.  It is not a runtime component of
    \pkg{babel-kazakh}; keep it in the same directory as the two test drivers.
  \item[\file{refs.bib}]
    Bibliographic data used by both drivers.
\end{description}

Both drivers begin with alternative \code{\string\documentclass} lines for
the standard \file{article}, \file{book}, and \file{report} classes.  To test
another class, comment out the currently active line and uncomment the
required one, leaving exactly one \code{\string\documentclass} command
active.  The shared body adapts to the selected class: chapter tests are
performed only when the class provides chapters.  The diagnostics generated
by \file{variables.sty} record the selected class and its options.

\subsection{Compiling the Babel driver}

For pdf\LaTeX:

\begin{codeblock}
pdflatex kazakh-unversal-bib-test.tex
biber kazakh-unversal-bib-test
pdflatex kazakh-unversal-bib-test.tex
pdflatex kazakh-unversal-bib-test.tex
\end{codeblock}

For a Unicode engine, replace \code{pdflatex} by \code{xelatex} or
\code{lualatex}.

\subsection{Compiling the Polyglossia driver}

With \XeLaTeX:

\begin{codeblock}
xelatex kazakh-polyglossia-bib-test.tex
biber kazakh-polyglossia-bib-test
xelatex kazakh-polyglossia-bib-test.tex
xelatex kazakh-polyglossia-bib-test.tex
\end{codeblock}

The same sequence works with \LuaLaTeX{} after replacing \code{xelatex}
by \code{lualatex}.

\section{What the shared body verifies}

The file \file{kazakh-test-body.tex} is deliberately independent of the
language package and engine.  Its checks are summarized below.

\begin{center}
\begin{tabularx}{\textwidth}{@{}p{.29\textwidth}X@{}}
\toprule
Area & Verification \\
\midrule
Document structure & Parts, chapters when available, sections,
subsections, subsubsections, and appendices. \\
Mathematics & A quadratic formula, a finite sum, equation numbering, and
cross-references. \\
Tables & Two captioned tables containing numbers and Kazakh letters. \\
Figures & Two captioned drawings made entirely in \LaTeX. \\
Bibliography & Kazakh and English citations plus a bibliography in the
table of contents. \\
Diagnostics & Engine, package, package version, class, and class options. \\
\bottomrule
\end{tabularx}
\end{center}

Because the same body is included by both drivers, differences in captions,
numbering, language switching, or bibliography strings can be compared
directly.

\section{Installation notes}

In a current TeX Live installation the package files are placed in their
normal TDS locations.  When testing a development copy in a personal tree,
run the filename-database update command required by the TeX distribution
and verify the selected files with \code{kpsewhich}.  For example:

\begin{codeblock}
kpsewhich kazakh.ldf
kpsewhich gloss-kazakh.ldf
kpsewhich gloss-kk.ldf
kpsewhich kazakh.lbx
kpsewhich babel-kk.ini
\end{codeblock}

The final command should resolve to the main \pkg{Babel} tree, not to the
\pkg{babel-kazakh} package directory.

\section{License and maintenance}

Copyright \textcopyright{} 2026 Berik I. Tuleuov.

The \pkg{babel-kazakh} package may be distributed and/or modified under the
conditions of the LaTeX Project Public License, version 1.3c or any later
version.  The work has the LPPL maintenance status \texttt{maintained}; the
Current Maintainer is Berik I. Tuleuov.

\end{document}
