I'm working on a document in LaTeX and I would like to have multiple language versions. I could just copy everything and translate, but this would lead to multiple versions that I would have to update individually every single time.
What I want is that I specify which language I want to compile (or perhaps it always compiles all the languages, so every time I run it saves for instance an english, dutch and german version). And then it only prints that language. I was thinking of something along the lines of:
\languageversion{english} %this could be changed for language specification
\begin{document}
...
\dutch{some dutch text here}
\english{some english text here}
\german{some german text here}
So when I select english, only the english part would be printed. This way, if I would change the layout I don't have to do this for multiple versions, but only in one.
Is this possible?
Best Answer
Here's a way, but I don't think this can really be useful for long texts.
This will use the active language (according to
babel
rules). The\declarelanguage
has an optional argument: a string that matches thebabel
language name. Using this it's immaterial what name you use; for example you could sayand use
\EN{English text}
for inserting the English text. Take your pick; for German it's necessary.Note: there's a strange
babel
feature: the language string maintained by\languagename
has its first character of category code 12, that's the reason for the mysterious\edef\@tempa{\string#1}
, which make your given string agree withbabel
's opinion on the matter.