2010-01-11 63 views
11

您如何準備帶有翻譯的Latex文檔...我需要1個多語言文檔。它應該是這樣的:Latex中的多語言文檔

\section{pl:Costam; en:Something} 

那麼我想呈現在波蘭語和英語......

+1

有在[' (http://www.ctan.org/pkg/translations)包和['translator'](http://www.ctan.org/pkg/beamer)包(「beamer」包的一部分) )可能或可能不會對手頭的任務有所幫助 – cgnieder 2013-07-26 12:41:18

回答

2

我有解決方案!

\newboolean{eng} 
\setboolean{eng}{false} 
\newboolean{pol} 
\setboolean{pol}{true} 
\newboolean{rus} 
\setboolean{rus}{false} 

\newcommand{\lang}[3] 
{ 
    \ifthenelse{\boolean{eng}}{#1}{}\ifthenelse{\boolean{pol}}{#2}{}\ifthenelse{\boolean{ger}}{#3}{} 
} 

用法:

\lang{English}{Polski}{Deutch} 
+3

答案a)錯過了定義'\ newboolean'和'\ ifthenelse'的信息,並且b)在'\ lang'的定義中引入了_two spurious spaces_。 – cgnieder 2013-07-26 12:37:21

1

你可以使用條件來做到這一點,例如,一個\ifdef s。使用適當的宏,閱讀這些內容不一定非常可怕。

更好的是使用本地化工具,比如XLIFF編輯器。看看the XLIFF tools page。走這條路線的巨大優勢是XLIFF直接插入標準翻譯工具,如翻譯記憶庫。

9

如果一切都提出的解決方案失敗了,你可以去一個更基本的,幾乎是侮辱啞巴方法:

\newcommand{\dumblang}[2]{{#1}} 

這定義了一個帶有兩個參數的命令( [2])並吐出第一個({#1})。

因此,例如,你可以有...

\usepackage[\dumblang{english}{italian}]{babel} 

%snip 

\section{\dumblang{Introduction}{Introduzione}} 
\dumblang{Your introduction goes here!}{Scrivi qua la tua introduzione!} 

...當你想在意大利的文檔,你可以改變\dumblang到:

\newcommand{\dumblang}[2]{{#2}}