Edit Links |
LyX /
I18nLabelsCategories: i18n << | Page list | >>
About internationalized labelsIntroductionMost of the labels, like "Table of contents", are automatically translated into the document language. This is done by the LaTeX-package babel, that is always loaded by LyX in the background. But babel doesn't translate all labels, that are introduced by some document classes. These labels need to be translated manually. Method of translationEnvironmentsLabels are often part of a LaTeX-environment. Environments appear in LaTeX as \begin{environment name} To translate a label, we have to redefine the environment. This is done in the preamble with the command \renewenvironment{environment name}{begin command}{end command} For begin and end we need a new environment with the new label. \theoremstyle{plain} A theorem is a special form of an environment. exa is the name of our environment and Beispiel its label. \theoremstyle defines how the theorem will look in the output. To assure that we are using the same style as the original theorem, we must specify the style in front of the new theorem. For many environments the style is plain, some environments do not need a specified style; the below list will show you what is needed. \renewenvironment{example}{\begin{exa}}{\end{exa}} In summary we overwrote the existing environment with a new one. All that we have to know, is the name of the existing environment and the form of its definition (theorem or not). But be careful, you must not translate labels wich are not used in your document. This will cause an error. Just comment unused translations out: %\renewenvironment{example}{\begin{exa}}{\end{exa}} FloatsLabels of floats can easily be changed with the command \floatname{name of float}{label} LabelsTo change labels that are automatically translated by the LaTeX-package babel, you need to load it in the preamble together with the language options used in your document. For example when you have a document that uses the new German orthography call babel with the preamble line \usepackage[ngerman]{babel} The new label name is set by this preamble line construct: \addto\captionsngerman{\renewcommand{\indexname}{Stichwortverzeichnis}} This preamble line replaces babels German index name with "Stichwortverzeichnis". The command \captions<language> must be adjusted according to the used language. So it is for an English document the command \captionsenglish. To change another label than the index, replace the command \indexname by \<label>name. A list of the possible names can be found here: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=fixnam To change for example the name of the label "Figure" in French by "Image" you need these preamble lines: \usepackage[french]{babel} Preamble commands for special LaTeX-classesIn the following, all labels are translated into French. Every section includes a downloadable example file, so that you can easily copy the code from the preamble and replace the French names by the one you need. Algorithm-floatExample file: lang-algorithm.lyx \floatname{algorithm}{Algorithme} AMS-documentclassesExample file: lang-ams.lyx In the original definition, all environments are numbered within the section number. To have this for the redefined environments, add a \numberwithin command for every environment, e.g. \numberwithin{theo}{section} as it is done in the example file.
Beamer-presentationsFirst approachExample file: lang-beamer.lyx
Second solution (no redefinitions needed)Till Tantau created a package name translator, currently not sufficiently documented to deserve a real publication as a package. To have it working:
revision after the last stable release (3.06);
Alternative method by using a macroBased on the previous methods discussed above, I've built a macro which can be easily used to translate any environment. Here is the code: \usepackage{ifthen} % translatethm macro parameters: % #1 (optional) Style of theorem. Default to "plain". % #2: Name of the existing theorem environment (example, problem, etc.) % #3: String of the translation (e.g. Beispiel in German replacing Example, etc.) % For instance, a possible use of the command is: \translatethm{example}{Beispiel} \newcommand{\translatethm}[3][plain]{ \ifthenelse{\expandafter\isundefined\csname#2\endcsname} {} {\theoremstyle{#1} \newtheorem{#2trans}{#3} \renewenvironment{#2}{\begin{#2trans}}{\end{#2trans}}} } As described in the comments of the macro, a possible use is: Using this macro we do not have to be worried about whether the environment 'example' is or not used in the document. Note that it does not work with starred environments (unnumbered), but another similar macro can be defined changing |