# Chemmacros scheme translation

I'm trying to translate the word "Scheme" in the captions of chemmacros schemes. I'm writing in spanish, so I want to change "Scheme 1" to "Esquema 1", for example.

I don't know if I'm not understanding the manual or how the package and module (lang) work.

I tried a lot of things so far, but I have this and it gives error:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage{chemmacros}
\chemsetup{modules={scheme}}
\DeclareChemTranslation{spanish}{scheme}{esquema}
\DeclareChemTranslation{spanish}{Scheme}{Esquema}

\begin{document}

\begin{scheme}
\caption{Lorem ipsum}
\end{scheme}

\end{document}


! Package translations Error: Unknown language scheme'.See the translations package documentation for explanation.Type H for immediate help.... ...reChemTranslation{spanish}{scheme}{esquema}

I'm using this version: This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7000 64-bit) (preloaded format=pdflatex 2019.4.23) 3 JUN 2019 19:24

One issue is here an error in the manual.

You have to use the following definitions

\DeclareChemTranslation{scheme}{spanish}{esquema} % <===================
\DeclareChemTranslation{Scheme}{spanish}{Esquema} % <===================


to get no error message. Please see that the order of parameters has changed! First key, then language and then translation. In the manual this is simply wrong (see red arrow with flash), but the second command works as described ...

Perhaps because l3kernel has changed it seems that the definitions above do not find their way into the document. Please see the following code

\documentclass[spanish]{article} % <====================================

\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage{chemmacros}
\chemsetup{modules={scheme}}
%\chemsetup{language={spanish}}
\DeclareChemTranslation{scheme}{spanish}{esquema} % <===================
\DeclareChemTranslation{Scheme}{spanish}{Esquema} % <===================
%\DeclareChemTranslations{scheme}{spanish=esquema} % <==================
%\DeclareChemTranslations{Scheme}{spanish=Esquema} % <==================

\begin{document}

\begin{scheme}
\caption{Lorem ipsum}
\end{scheme}

\end{document}


and its result (compiled with MIKTeX version pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7050 64-bit)):

As you can see the language for scheme has not changed!

\renewcommand{\schemename}{Esquema}


after \begin{document} gives you the following result:

while adding the same line before \begin{documents} results in an error because command \schemename is only known after document has started ...

I did not investigated now the code (I did not learn using l3kernel until now) what is the reason that the new defined translation for scheme in spanish is not printed in the document.

I suggest you make a bug report for the maintainer of that package to get the manual corrected and to get an working translation ...

As @Mensch already mentioned, the manual is wrong and the language should come second. Moreover, the list of translation keys in the manual is also a bit confusing. The list mentions both scheme and scheme-name, but only scheme-name works. This can be traced in the source code of the scheme module around line 250, where schema-name is used for the predefined translation to German - but again somewhat confusingly in a \ChemCompatibilityTo{5.6} block, so it might be an old version of the syntax - but at least it works.

An issue on the Github page certainly looks like a good idea, to update the manual and/or the code to make the behavior more intuitive.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage{chemmacros}
\chemsetup{modules={scheme}}
\DeclareChemTranslation{scheme-name}{spanish}{Esquema}

\begin{document}

\begin{scheme}
\caption{Lorem ipsum}
\end{scheme}

\end{document}


Result:

A way to change it is simply putting \renewcommand{\schemename}{Esquema} after begin{document}, but I don't know why I can't change the translation.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage{chemmacros}
\chemsetup{modules={scheme}}

\begin{document}
\renewcommand{\schemename}{Esquema}

\begin{scheme}
\caption{Lorem ipsum}
\end{scheme}

\end{document}
`