[Tex/LaTex] How to change the language of datetime

datetimelanguagesxetex

Сondition to change language of the month on titlepage doesn't work.

How to write condition to activate russian or english date depending on the choice?

XeLaTeX is used.

My code doesn't work. MWE:

\documentclass[10pt, oneside, a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{polyglossia}

\setotherlanguage{russian}
\foreignlanguage{russian}

\usepackage{datetime}

\ifthenelse{\umruslang>0}
{ %rus
\newcommand{\rus}[1]{\foreignlanguage{russian}{#1}}
\newdateformat{docdatef}{\rus{\monthname\ \THEYEAR}}
}
{%eng
\newdateformat{docdatef}{\monthname\ \THEYEAR}
}

Best Answer

The language definition file dt-russian.def (provided by datetime) uses commands like \cyrya in the month names, which aren't provided with XeLaTeX. However, datetime has been replaced by datetime2 and the corresponding datetime2-russian module (which needs to be installed separately) provides UTF-8 support.

MWE:

\documentclass{article}

\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{russian}

\setmainfont{Liberation Serif}
\newfontfamily\cyrillicfont{Liberation Serif}

\usepackage[en-GB,russian]{datetime2}

\DTMlangsetup[en-GB,russian]{showdayofmonth=false}

\begin{document}
\today

\selectlanguage{russian}

\today

\end{document}

January 2018 января 2018 г.

Related Question