# Multiple languages in beamer LaTeX

I want to create a LaTeX beamer presentation within multiple languages in the following sense: The sorce code should contain the different languages, but the language of the compiled result should depend on a specific choice of one language.

A solution has already been provided http://tex.stackexchange.com/a/31401/21166. However the \sectionlang command seems to have problems, when using beamer LaTeX with \input. There is no error displayed, but the command are ignored during compilation.

Everyting works fine in the following code example (the package multilanguage is from the link above)

\documentclass{beamer}
\usepackage[ngerman,english]{babel}
\usepackage{ifthen}
\usepackage{multilanguage}

\setdoclang{en}{english}
% \setdoclang{de}{ngerman}

\begin{document}
\frame{
\tableofcontents
}

\sectionlang{en}{Section 1}
\sectionlang{de}{Abschnitt 1}

\frame{
\lang{de}{Folie 1}
\lang{en}{Slide 1}
}

%\mode<all>
%\input{./frame.tex}
%\mode*
%\againframe<1>{slide2}

\sectionlang{en}{Section 2}
\sectionlang{de}{Abschnitt 2}

\frame{
\lang{en}{Slide 3}
\lang{de}{Folie 3}
}

\end{document}


The frame.tex file contains

\frame<0>[label=slide2]
{\frametitle{\lang{de}{Folie 2}
\lang{en}{Slide 2}}
\lang{de}{Folie 2}
\lang{en}{Slide 2}
}


However, when the \input block in uncommented, the compiled ToC does not contain Section 2 anymore.

-
Welcome to TeX.SX. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}). – Claudio Fiandrino Oct 21 '12 at 12:21
I think it would be helpful to provide a complete minimal working example (MWE) to show us what you have done untill today. – Kurt Oct 21 '12 at 13:32

Update:

I think the best way would be to build two tex files, one for each needed language. Then the TOC, hyphenation and so on are working as usual. Of course the disadvantage is that you have to change two (or more) files, depending on the number of used languages.

An alternative way could be to use package ifthenelse, define boolean variables for the used languages and include each frame in a construct like:

\setboolean{MWEenglish}{true} % sets variable MWEenglish on true
\ifthenelse{\boolean{MWEenglish}}{%
% Then frame definition here
}{%
% Else part here (two language: frame in second language)
} % end ifthenelse


Just to give you a hint how to procede please have a look on the following MWE. The package filecontents is used to write a changed package file multilanguage.sty.

I have added the line \newcommand{\frametitlelang}[2]{\lang{#1}{\frametitle{#2}}} to have a new macro \frametitlelang. This macro is used to build the frame title depending on the language.

\RequirePackage{filecontents}
% writes file multilanguage.sty
\begin{filecontents*}
\newcommand{\setdoclang}[2]
{
\main@language{#2}
\def\doclang{#2}
\def\doclangshort{#1}
}

\setdoclang{en}{english}

%
% Multilingual support commands
%
\newcommand{\langif}[3]
{
\ifthenelse{\equal{#1}{\doclang} \or \equal{#1}{\doclangshort}}
{#2}
{#3}%
}
\newcommand{\lang}[2]{\langif{#1}{#2}{}}
\newcommand{\sectionlang}[2]{\lang{#1}{\section{#2}}}
\newcommand{\subsectionlang}[2]{\lang{#1}{\subsection{#2}}}
\newcommand{\subsubsectionlang}[2]{\lang{#1}{\subsubsection{#2}}}
\newcommand{\frametitlelang}[2]{\lang{#1}{\frametitle{#2}}}       % new macro
\end{filecontents*}

\documentclass{beamer}
\usepackage[ngerman,english]{babel}
\usepackage{ifthen}
\usepackage{multilanguage}

%\setdoclang{en}{english}
\setdoclang{de}{ngerman}

\begin{document}
\frame{
\tableofcontents
}

\sectionlang{en}{Section 1}
\sectionlang{de}{Abschnitt 1}

\frame{
\lang{de}{Folie 1}
\lang{en}{Slide 1}
}

\mode<all>
%\input{./frame.tex}  %following is included frame.tex
\frame<0>[label=slide2]
{\frametitlelang{de}{Folie 2}     % new macro
\frametitlelang{en}{Slide 2}     % new macro
%   }
\lang{de}{Folie 2}
\lang{en}{Slide 2}
}
\mode*
\againframe<1>{slide2}

\sectionlang{en}{Section 2}
\sectionlang{de}{Abschnitt 2}

\frame{
\lang{en}{Slide 3}
\lang{de}{Folie 3}
}

\end{document}

-
Unfortunatelly this does not cure my problem. Of course, it may be helpfull if repeated code is abbreviated by some new macro, but stil the ToC is not correct. If, \mode<all> and \mode* are commented, everything works fine - however different beamer notes are required for handout, etc. – user21166 Oct 22 '12 at 9:37
See my update ... – Kurt Oct 22 '12 at 12:03