Was wondering this myself and found a working solution with GNU gettext. A tool called po4a works with Tex/LaTeX files.
- po4a-gettextize, convert an original file (and its translation) to a PO file
- po4a-normalize, normalize a documentation file by parsing it in po4a, and writing it back
- po4a-translate, convert a PO file back to documentation format
- po4a-updatepo, update the translation (in PO format) of documentation
So and example would look like this
po4a-gettextize -f latex -m main.tex -p xx.po -M UTF-8
The master file (-m) main.tex is the source file and we get an output (-p) of xx.po, and UTF-8 (-M) as the file encoding for non-english language support.
Where the latex format (-f) tells po4a to use latex environments and commands, if the tex format where to be used all environments and commands would need to be added manually.
So we can do everything we need to support several language versions for on or more documents.
To further on use the rest of the commands look at the man page for po4a
New environments and commands
If we would like to use custom commands or make new environments we need to declare them in the .tex document as the following according to the man page.
% Tells po4a that we have a non standard environment called tightemize % po4a: environment tightemize % tightemize is a custom list environment where we want each \item to be a separate translation object % po4a: separator tightemize "\\\\item" %rest of document \documentclass{arcticle} etc.... \begin(document) \begin{tightemize} \item Item 1 \item Item 2 \item Item 3 \end{tightemize}
Its also possible to change the LaTeX.pm module file, located in /usr/share/perl5/vendor_perl/Locale/Po4a as such
% Original environment $env_separators{'itemize'} = "\\\\item"; % Here we can just copy the environment we want our new one to work as $env_separators{'tightemize'} = "\\\\item"; % and adding it to the foreach abow foreach (qw(abstract align align* cases center description displaymath document enumerate tightemize etc...
Edit PO files
To edit the files there exists many programs online or native ones, look at the Arch list.
parcolumns,paracol,parallelorparrunor other related packagestranslatorpackage which comes withbeamerprovides some tools for automatic translations.