8

I could not really find anything matching, maysome someone got an idea or a starting point:

I want to maintain a collection of documents written in Kile, Using LaTeX converted by xetex into pdf format. These documents have to be updated from time to time. I required each document to be available in two or three languages.

I do not want to maintain separate source files/collections for the different languages, since this will certainly lead to documents running out of sync. Instead I imagine something like this:

- each token of natural language ("phrase") will be enclosed in a macro
- the macro fetches the translation of the phrase from a local service
- this service could be a script reading translations from a file

Since there are applications suitable to maintain such phrase collections this appears to be a natural approach to me. However, I fail to find a good starting point..

migrated from stackoverflow.com Jul 20 '12 at 16:54

This question came from our site for professional and enthusiast programmers.

6

Ok, I managed to put together my own solution by trying around and considering examples I found elsewhere. This is what I currently use, near the start of my project. It works fine so far:

%%%%%%%%%%%%%%%
% this is a document holding multiple languages
% switch between ENGLISH and GERMAN by commenting one of the following lines:
\usepackage[ngerman,english]{babel} % makes ENGLISH content
%\usepackage[english,ngerman]{babel} % makes GERMAN content
% this is the macro to define phrases in two languages:
\newcommand{\babel}[2]{\ifnum\pdfstrcmp{\languagename}{english}=0 {#2}\else{#1}\fi}
\newcommand{\babelDE}[1]{\ifnum\pdfstrcmp{\languagename}{ngerman}=0 {#1}\fi}
\newcommand{\babelEN}[1]{\ifnum\pdfstrcmp{\languagename}{english}=0 {#1}\fi}
% example:   \babel{Deutscher Text}{english text}
% example:   \babelDE{deutscher Text}
% example:   \babelEN{english text}
%%%%%%%%%%%%%%%
  • any updates on how it ended? – Bastiaan Quast Oct 3 '17 at 11:35
  • This worked out quite nicely for me, used for French. – Valerio Schiavoni Jun 25 '18 at 16:59
3

Using the iflang package it is possible to write a slightly cleaner command equivalent to the one in the previous answer:

\usepackage[ngerman,english]{babel}
%\usepackage[english,ngerman]{babel}

\usepackage{iflang}

\newcommand{\babel}[2]{\IfLanguageName{english}{#1}{#2}}
  • Interesting, thanks. I will take a look into it, though I currently do not have any documents maintained in LaTeX. Guess that will get interesting again for my next application ;-) – arkascha Nov 19 '18 at 6:44
0

I had a similar problem and @KJO suggested the catchfilebetweentags package as described in https://tex.stackexchange.com/a/4952/170109. It worked for me.

  • Could you please add more context to your answer? Otherwise this is only a link-only answer and will be deleted. – user156344 Apr 14 at 14:47
  • I think there is no need of a context. I answered to @arkasha's question. I think anyone can go to the link. If not please delete my answer. – nino_user183677 Apr 14 at 16:07
  • Then you can post that answer here. – user156344 Apr 14 at 16:08

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.