2

The following post consists of three parts. In the first part an experiment is conducted, establishing the fact that a translation via translator works only when certain prerequisites are met. In the second part a beamer presentation is created that generates a translation automatically. In the third part it is demonstrated that the prerequisites for the translation evidenced in the second part, those prerequisites established in the first part, were not met. The question is then raised how this paradox can be reconciled. An addendum sheds light on the key to the mystery, but doesn't explain the "how"s and the "why"s.


Part I: An Experiment

The following experiment shows that in order for the translator package's translate command to translate a key to a non-English language in the absence of an explicit command option, one of the following two conditions must be met:

  1. The translator package must be loaded with the non-English language as an option.
  2. The translator command \languagealias must be called for the non-English language.

The experiment is established in three stages. The first stage demonstrates what happens when neither of the two conditions stated above is satisfied. The second stage shows what happens when the first of the two conditions is met. The third stage shows what happens when the second of the conditions is met.

In the first stage of the experiment, the following LaTeX code is compiled with, say, lualatex. The code first creates a German dictionary called Test-German.dict. The dictionary contains a single key-translation pair: the key phrase is to be translated as A German phrase. Then an article is created, whose main language is set, via babel, to be German. The translator package is the loaded with no options. Then the translator package is informed to load the dictionary Test-German.dict at the beginning of the document. The document then begins, and contains a single command instructing the translator package to translate the key phrase.

\begin{filecontents*}[overwrite]{Test-German.dict}
\providetranslation{phrase}{A phrase in German}
\end{filecontents*}

\documentclass{article}
\usepackage[german]{babel}
\usepackage{translator}

\usedictionary{Test}
\uselanguage{German}
\begin{document}

\translate{phrase}

\end{document}

The PDF file generated from the compilation of the above code shows the single word "phrase". Conclusion: the \translate command did not use the dictionary to translate the key.

In the second stage of the experiment the above code is modified by passing german as an option to the package translator: \usepackage[german]{translator}, and the code is recompiled. The resulting PDF file now shows: "A phrase in German". Conclusion: the \translate command used the dictionary to translate the key.

In the third stage of the experiment the original code listed above is modified by inserting the command \languagealias{german}{German} as the last command of the preamble, and the code is recompiled. The resulting PDF file is the same as in the second stage, and consequently the same conclusion can be drawn as in the second case.

The experiment is now complete. To reiterate the conclusion of this three-stage experiment: in order for the translator package's translate command to translate a key to a non-English language in the absence of an explicit command option, one of the following two conditions must be met:

  1. The translator package must be loaded with an option for the non-English language.
  2. The translator command \languagealias must be called for the non-English language.

Part II: A Beamer Presentation

Consider now the following LaTeX code. The code creates a German beamer presentation. German is set as the presentation's language in two ways: by passing it as a class option, and then by passing it as an option to the babel package. The body of the presentation then begins. The presentation consists of a single frame, which contains a theorem environment.

\documentclass[german]{beamer}
\usepackage[german]{babel}
\begin{document}
\begin{frame}
\begin{theorem}
A theorem.
\end{theorem}
\end{frame}
\end{document}

The PDF file generated by compiling this code with lualatex consists of a single slide that shows two lines of text: the first is "Satz" (the German word for "Theorem"), and just below it "A theorem." Clearly the title of the theorem environment was automatically translated to German.

Based on the results of the experiment described in the beginning of this post, I conclude that the beamer package either loads the translator package with the german option, or else executes the command \languagealias{german}{German}, or else passes to=German as an option to the \translate command.


Part III: A Search for the Prerequisites in Beamer's Source Code

However, a search through the beamer source code bears out none of these alternatives: The translator package is loaded in this file with no options, the string "languagealias" occurs nowhere in the beamer source code, and the command \translate is never passed any options.


So how was the translation of the word "Theorem" to the German counterpart "Satz" carried out?


Addendum

After finishing writing this post I conducted another little experiment that shed light on the issue. When the code in the first stage of the experiment is modified by passing german as a class option to the article document class, the translation is carried out. So this is the key to the mystery. But I would like to understand the mechanism behind it. I think this is not documented in the translator manual.

0

1 Answer 1

3

I guess what happens is that behind the scenes class options are automatically appended to the option list of all the packages loaded in the preamble. Therefore, in particular, if german is passed as a class option to either the article or the beamer document class, the \usepackage{translator} command is automatically replaced by \usepackage[german]{translator}, and therefore the first of the two prerequisites described in the original post is met, and the mystery is solved.

1
  • 3
    Yes, your guess is correct. All the global options (the ones passed to the class) are available to the packages; this is why for example draft can percolate down to, say, graphicx. This is standard behavior since day 1...
    – Rmano
    Commented Dec 10, 2022 at 8:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .