2

What's the point of having two packages translations and translator with roughly the same main functionality?

Let's consider the following example:

\documentclass[USenglish,french,ngerman]{article}
\pagestyle{empty}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{translations}
\usepackage{translator}
\usepackage[x11names]{xcolor}
\newcommand{\actionColor}{blue}
\DeclareTranslation{ngerman}{blue}{blau}
\DeclareTranslation{french}{blue}{bleu}
\newtranslation[to=German]{blue}{blau}
\newtranslation[to=French]{blue}{bleu}
\begin{document}
\expandafter\GetTranslation\expandafter{\actionColor}
\translate{\actionColor}
\selectlanguage{french}
\expandafter\GetTranslation\expandafter{\actionColor}
\translate{\actionColor}%
\end{document}

As expected, the output is

blau blau bleu bleu

Am I missing anything? Alright, the author of translations said he wanted an expandable version of translator's \translate command, but in which context would this be an advantage? In my context, having to think of two additional \expandafters per call seems more a disadvantage to me.

4
  • 1
    You just asked a question earlier today whose answer required an expandable argument. I’m not sure what other kind of example you are looking for.
    – Davislor
    Nov 20, 2022 at 6:10
  • 2
    Expandable can be useful if the translation should also work in the bookmarks or when writing to a file. Apart from this: if someone wants to write another package who should forbid it? Nov 20, 2022 at 8:04
  • 1
    @Ulrike IIRC bookmarks were the original reason for needing and wanting an alternative to translator
    – cgnieder
    Nov 20, 2022 at 8:25
  • 3
    apart from any specifics about that package your question is asking why, in the 40 year history of latex, two people would write packages with similar functionality. Surely that is simply expected. Nov 20, 2022 at 9:12

1 Answer 1

2

Expandable commands work also in bookmarks. And to avoid the \expandafter you can simply define your own wrapper command (I use \ExpandArgs which is new in LaTeX, but \expandafter would work too).

\documentclass[USenglish,french,ngerman]{article}
\pagestyle{empty}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{translations}
\usepackage{translator}
\usepackage[x11names]{xcolor}
\newcommand{\actionColor}{blue}
\DeclareTranslation{ngerman}{blue}{blau}
\DeclareTranslation{french}{blue}{bleu}
\newtranslation[to=German]{blue}{blau}
\newtranslation[to=French]{blue}{bleu}
\usepackage{hyperref}
\newcommand\GetCmdTranslation[1]{\ExpandArgs{o}\GetTranslation{#1}}
\begin{document}
\section{\GetCmdTranslation{\actionColor}--\translate{\actionColor}}
\end{document}

As you can see only one of the translations finds it way into the bookmarks:

enter image description here

1
  • Thx. The log says that \translate is simply removed from the \section{…} line.
    – user282514
    Nov 20, 2022 at 19:05

You must log in to answer this question.