5

I am working on a short story written in french, and containing a number of short dialogs in english. A friend suggested it might be a courtesy to potential readers to tranlslate the english content into french by footnotes. I would like however to easily offer both versions, by changing a global parameter as shown in the MWE: with and without footnotes. I wonder if the approach taken is optimal. Moreover, I am trying to come up with yet a third version that would be entirely in french, i.e. by replacing the english text by the content of the footnote, but also with a change of font from \emph to normal. I use the \emph font to distinguish the text in english from the core document in french.

Is there a practical way to do this, or is this overkill?

\documentclass[a5paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
\usepackage[english, french]{babel}

\def\lang {e} %variable used for conditional translated footnotes

\begin{document}
\selectlanguage{english}

\begin{enumerate}

\item \emph{--- The manager needs to see you before you leave}
\ifthenelse{\equal{\lang}{}} {}{\footnote{\selectlanguage{french}   Monsieur, le patron veut vous voir avant votre départ !}}!

\selectlanguage{french}
Je tournai la tête et levai les yeux vers le visage de la serveuse. 

\item \emph{--- The manager needs to see you before you leave}
\ifthenelse{\equal{\lang}{e}} {}{\footnote{\selectlanguage{french}Monsieur, le patron veut vous voir avant votre départ !}}!
\selectlanguage{french}
Je tournai la tête et levai les yeux vers le visage de la serveuse. 
\end{enumerate}
\end{document} 
2

To answer your last question quickly: It is not overkill, but it is not comfortable and thereby a little impractical. In the following example (that contains also your attempt) I defined a macro - optimizing your approach, as requested - called \englphrase that works like \englphrase[french translation]{english text}. It will add a footnote with the french translation only if you give one in the optional argument.

\documentclass[a5paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
\usepackage[english, french]{babel}

\def\lang{e} %variable used for conditional translated footnotes

\let\markforphrase\emph
\newcommand{\englphrase}[2][]{%
\selectlanguage{english}
\markforphrase{#2}%
\if\relax\detokenize{#1}\relax\else\footnote{\selectlanguage{french} #1}\fi
\selectlanguage{french}
}

\begin{document}
\selectlanguage{english}

\begin{enumerate}

\item \emph{--- The manager needs to see you before your leave!}
\ifthenelse{\equal{\lang}{}} {}{\footnote{\selectlanguage{french}   Monsieur, le patron veut vous voir avant votre départ !}}

\selectlanguage{french}
Je tournai la tête et levai les yeux vers le visage de la serveuse.

\item \emph{--- The manager needs to see you before your leave!}
\ifthenelse{\equal{\lang}{e}} {}{\footnote{\selectlanguage{french}Monsieur, le patron veut vous voir avant votre départ !}}
\selectlanguage{french}
Je tournai la tête et levai les yeux vers le visage de la serveuse.
\end{enumerate}

%A demonstration of the optimized approach
\medskip\hrule\medskip
\parindent=0in

---\englphrase[Monsieur, le patron veut vous voir avant votre départ!]{The manager needs to see you before your leave!}

Je tournai la tête et levai les yeux vers le visage de la serveuse.

---\englphrase{The manager needs to see you before your leave!}

Je tournai la tête et levai les yeux vers le visage de la serveuse.
\end{document}

Edit: I missed and important point. You also need something like \transltnoff to switch off translations globally in order to provide both an english and a french version of your book easily. Try:

\newif\iftransltn
\transltntrue
\let\transltnoff=\transltnfalse %this is just to make the macro sound intuitive
\let\markforphrase=\emph
\newcommand{\englphrase}[2][]{%
\foreignlanguage{english}{\markforphrase{#2}}% thanks egreg :-)
\iftransltn%
  \if\relax\detokenize{#1}\relax\else
    \footnote{#1}
  \fi%
\fi%
}

%\transltnoff
  • 2
    I'd use \foreignlanguage{french}{<French line>} rather than \selectlanguage{french}<French line>; you're resetting languages too often. – egreg Oct 28 '13 at 21:33
  • I could not make your suggestion work. However this has led me to a simple solution: \def\lang {f} %variable use for conditional text e=english, f=french, ef=english with footnotes \newcommand{\CondText}[2]{% \ifthenelse{\equal{\lang}{ef}} {\emph{#1}\footnote{\selectlanguage{french} #2}} {} \ifthenelse{\equal{\lang}{f}} {\selectlanguage{french} #2}{} \ifthenelse{\equal{\lang}{e}} {\emph{#1}} {} }% \CondText{--- The manager needs to see you before you leave !}{Monsieur, le patron veut vous voir avant votre départ !} – Yves Nov 2 '13 at 17:40
  • @Yves, Did you really compile the complete example above? What are the exact error messages? (Maybe add them as an edit to your question.) However, your comment shows also a good approach because you now wrapped your idea into a macro, which also optimizes what you have done til yet. What do you think about adding this as an answer? – Ruben Nov 2 '13 at 22:52
  • @Ruben. Your solution compiles fine and does the job. What I meant is that I could not make use of the \transltnoff addition. This may well be because I am a beginner and misused the additional code. Also statements like \if\relax\detokenize are really not understandable by me. However It was your idea to make a macro (that also brings a better sepearation between form and contents) that really helped me. I still have a minor concern. I am told by a friend familiar with typography, that a call for a note should in fact occur before the punctuation signs at the end of the sentences, and – Yves Nov 3 '13 at 8:39
  • @Ruben. (cont) not after, as in the examples above. However it seems that trying do do this would destroy some of the previous logic, and I am going to let it this way. – Yves Nov 3 '13 at 8:39
1

I have finally come up with the following solution:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}% 
\usepackage{ifthen}
\usepackage[english, french]{babel}

\def\lang {ef} %variable used for conditional text e=english, f=french, ef=english with translated footnotes

\newcommand{\CondText}[2]{%
\ifthenelse{\equal{\lang}{e}} {{\selectlanguage{english}\emph{#1}}} {}
\ifthenelse{\equal{\lang}{ef}} {{\selectlanguage{english}\emph{#1}}
\footnote{\selectlanguage{french} #2}} {}
\ifthenelse{\equal{\lang}{f}} {{\selectlanguage{french} #2}}{}
}%

\begin{document}
\CondText {--- Sir, the manager needs to see you before you go !} {--- Monsieur, le patron veut vous voir avant votre départ !}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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