josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.41k stars 142 forks source link

Translation only works correctly if the language is specified as a class option #839

Open user227621 opened 1 year ago

user227621 commented 1 year ago

If a language is specified as a package option for babel, some words are correctly translated while others are not:

\documentclass{beamer}
\usepackage[ngerman]{babel}

\begin{document}

\section{Erster Abschnitt}

\begin{frame}
\sectionpage
\end{frame}

\begin{frame}
\begin{theorem}
Text
\end{theorem}

\begin{proof}
Text
\end{proof}

\begin{example}
Text
\end{example}
\end{frame}

\begin{frame}
\begin{figure}
\framebox(80,50){}
\caption{Eine Abbildung}
\end{figure}
\end{frame}

\end{document}

beamer-translate2

(The correctly translated words are probably handled by babel's translation mechanism, while the other words are handled by the translator package.)

However, if a language is specified as a class option for beamer, all translations are applied correctly:

\documentclass[ngerman]{beamer}
\usepackage{babel}

\begin{document}

\section{Erster Abschnitt}

\begin{frame}
\sectionpage
\end{frame}

\begin{frame}
\begin{theorem}
Text
\end{theorem}

\begin{proof}
Text
\end{proof}

\begin{example}
Text
\end{example}
\end{frame}

\begin{frame}
\begin{figure}
\framebox(80,50){}
\caption{Eine Abbildung}
\end{figure}
\end{frame}

\end{document}

beamer-translate

From a user's point of view, this is surprising because the beamer user guide does not mention that you have to specify the language as a class option to get correct translations. With other classes you don't have to do this either.

Apparently the translator package does not check whether a language is set e. g. by the babel package, but needs a language option itself. Is this a bug or is this by design? If this is not a bug, I would suggest adding an explanation in the beamer user guide on how to specify a language correctly to get all translations.

On the other hand, the translator user guide states

The translator package is loaded "in stages":

  1. First, some package or the document author requests the translator package is loaded.
  2. The translator package allows options like ngerman to be given. These op- tions cause the necessary aliases and the correct translator languages to be requested.
  3. During the preamble, packages and the document author request creating dictionary kinds and certain languages to be used. There requests are stored for loading later.
  4. At the beginning of the document the requested dictionary-language pairs are loaded.

This sounds as if translator could in principle apply its translations even if the language is only specified as a babel option by looking at the language at the beginning of the document.

samcarter commented 1 year ago

@user227621 You don't necessarily need to specify the language as class option, you could also pass it to the translator package:

\PassOptionsToPackage{ngerman}{translator}
\documentclass{beamer}
\usepackage[ngerman]{babel}
....
user227621 commented 1 year ago

@samcarter That also works, but is not intuitive either. If the beamer class does not support enabling translations by specifying a language option for the babel package (this is how it works with most other classes), I think there should be an explanation in the beamer user guide on how to specify a language correctly to get all translations.