Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to typeset German weekday names in uppercase using the translator package but I can't get it working:

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{translator}
\usedictionary{translator-months-dictionary}

\begin{document}

\translate{Monday}
\uppercase{\translate{Monday}}
\expandafter\uppercase\expandafter{\translate{Monday}}
\MakeUppercase{\translate{Monday}}
\expandafter\MakeUppercase\expandafter{\translate{Monday}}

\end{document}

The result is

Montag MONDAY MONDAY MONDAY MONDAY

How to get MONTAG?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

This works:

   \translatelet\foo{Monday}\MakeUppercase{\foo}

or for the pgf example

{\def\translate#1{\translatelet\foo{#1}\MakeUppercase{\foo}}%
\pgfcalendarweekdayname{0}}
share|improve this answer
    
Even though egreg's explanation is better you got the answer for my problem, I wrapped your code in a \newcommand{\weekdaynameUC}[1]{...#1->##1...} which perfectly fits my needs. Thanks @David, and thanks @egreg as well for the good explanation. –  buergi Nov 28 '12 at 17:47
    
@cgnieder thanks for the reminder, now I did so –  buergi Nov 28 '12 at 18:29

With \uppercase{\translate{Monday}} you're simply doing

\translate{MONDAY}

which results in "MONDAY" because the string isn't know. The same happens with the other tries, because \translate doesn't expand in a unique step (and is not fully expandable either).

Here's a way out: the command \translate{xyz} actually calls

\translatelet\trans@temp{xyz}\trans@temp

that is it stores the translated string into \trans@temp and then uses the string. So we can use the same mechanism and put \MakeUppercase in the proper place. I'll define \translateUC with the same syntax as \translate:

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{translator}
\usedictionary{translator-months-dictionary}

\makeatletter
\newcommand{\translateUC}[2][]{%
  \translatelet[#1]\trans@temp{#2}%
  \MakeUppercase{\trans@temp}}
\makeatother

\begin{document}

\translate{Monday}

\translateUC{Monday}

\end{document}

enter image description here

share|improve this answer
    
Perhaps my MWE was a little bit to simple, actually I'd like to make \pgfcalendarweekdayname{0} uppercase. However from the answers I can't figure out how to do this, I thought it just has something to do with the correct order of expansion. –  buergi Nov 28 '12 at 16:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.