Managing multi-language LaTeX documents

I’d like to maintain one of my presentation in German as well as in English without having to deal with multiple documents. As I use babel anyway, I of course want to use the language defined for it.

I asked in TSX and egreg came up with the perfect solution, Heiko Oberdiek’s iflang package.

\documentclass[ngerman]{scrartcl}
\usepackage{babel,iflang}
\newcommand{\tr}[2]{\IfLanguageName{ngerman}{#1}{#2}}
 
\begin{document}
 
\tr{Deutscher Text}{English text}
 
\end{document}

This solution works well, in the case of five or ten languages I’d probably use a template engine.

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website