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.

  • 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 '22 at 06: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? – Ulrike Fischer Nov 20 '22 at 08:04
  • 1
    @Ulrike IIRC bookmarks were the original reason for needing and wanting an alternative to translator – cgnieder Nov 20 '22 at 08: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. – David Carlisle Nov 20 '22 at 09:12

1 Answers1

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

Ulrike Fischer
  • 327,261
  • Thx. The log says that \translate is simply removed from the \section{…} line. –  Nov 20 '22 at 19:05