I'm currently adding a feature to my own class file: automatic translation of the footer according the main language that has been defined in my document.
\DeclareTranslationFallback{pageOfPages}
{\pagename~\thepage~of~\pageref{lastPage}}
\DeclareTranslation{English}{pageOfPages}
{\pagename~\thepage~of~\pageref{lastPage}}
\DeclareTranslation{Dutch}{pageOfPages}
{\dutchpagename~\thepage~op~\pageref{lastPage}}
\DeclareTranslation{French}{page-of-pages}
{\frenchpagename~\thepage~de~\pageref{lastPage}}
As you can see, the translations are handled by the translations package and the language management by babel. I'm using XeTeX, but my class aims at being rendering engine agnostic.
I'm trying to get the translated content of \pagename
. \pagename
contains the text used to represent the page which is "page" by default. By default, English is used. If we want the translated version, if babel is used, the latter prefixes the command by the language name e.g.: \frenchpagename
for French (see here for details). While this is true for French, the situation cannot be verified with \englishpagename
nor with \dutchpagename
. I checked the frenchb
babel config and could not find a specific \frenchpagename
command. It's seems the latter is defined in babel internals not in language specific files.
So my question, how am I supposed to get the \pagename
version for Dutch or any other language? I even tried to access babel internals (makeatletter, etc.) with no success.
Minimum working example:
\documentclass{report}
\usepackage[french]{babel}
\usepackage{translations}
\DeclareTranslationFallback{pageOfPages}
{\frenchpagename~\thepage~of~\pageref{lastPage}}
\DeclareTranslation{English}{pageOfPages}
{\frenchpagename~\thepage~of~\pageref{lastPage}}
\DeclareTranslation{Dutch}{pageOfPages}
{\dutchpagename~\thepage~op~\pageref{lastPage}}
\DeclareTranslation{French}{page-of-pages}
{\frenchpagename~\thepage~de~\pageref{lastPage}}
\begin{document}
\GetTranslation{pageOfPages}
\label{lastPage}
\end{document}
Change french to english for example.
EDIT: The main problem arises when I specify [base]
in babel options without specifying a main language, LaTeX complains in that case he cannot find the \pagename
statement. The idea is to check if a main language has been defined in babel first, otherwise we need to define it to properly fallback to English.
Thanks for your help.
\pagename
for each language. For example it translates to Pagina for Dutch on my system.tlmgr install babel-dutch
. I got "pagina" too.