# Book in two (or three) languages in LaTeX

I am writing a book in two languages: a Russian version and an English version. Is it possible to do this in the same file?

Something like \tltext{Hello world!}{Здравствуй, мир!}, and mark at the start of the preamble which variant is needed.

The idea is that if I needed to change something, I wouldn't have to do it in both files.

-

## migrated from stackoverflow.comJun 5 '11 at 22:17

This question came from our site for professional and enthusiast programmers.

This appears to be a near duplicate of the following question: Whether it's possible to keep translation together with original text?. If the answers there help you, we can close this question. –  Alan Munn Jun 5 '11 at 22:29
Sorry. I didn't find it. –  newuser Jun 6 '11 at 7:13

babel provides \iflanguage, but its usage for large parts of text is cumbersome.

\documentclass{book}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}

\newif\ifenglish
\newcommand{\chooselanguage}[1]{%
\selectlanguage{#1}%
\iflanguage{english}{\englishtrue}{\englishfalse}}

\begin{document}
\chooselanguage{english}
%\chooselanguage{russian}

\ifenglish
Hello world!
\else
Здраствуй мир!
\fi

\ifenglish
Thank you
\else
Спасибо
\fi

\end{document}


In other words, you write each paragraph (or part of text in general) putting between \ifenglish and \else the English version, and between \else and \fi the Russian text.

You choose the language by commenting or uncommenting the lines after \begin{document}.

-

This might just work, simply comment out the version that you don't want. You might eventually want to choose a shorter name than \tltext for the command because you're going to be typing it many, many times if you're writing a book.

\documentclass{article}

\newcommand{\tltext}[2]{#1}% use English version
%\newcommand{\tltext}[2]{#2}% use Russian version

\begin{document}
\tltext{Hello world!}{Здраствуй мир!}
\end{document}

-