Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

LyX /

I18nLabels

Categories: i18n
<< | Page list | >>

About internationalized labels

Introduction

Most 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.
This page will give an overview about the necessary preamble commands to translate labels in dependence of the used document classes.

Method of translation

Environments

Labels are often part of a LaTeX-environment. Environments appear in LaTeX as

\begin{environment name}
\end{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.
E.g. to translate the label "Example" to German "Beispiel", define a new environment:

\theoremstyle{plain}
\newtheorem{exa}{Beispiel}

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.
We can now redefine the existing environment "example":

\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}}

Floats

Labels of floats can easily be changed with the command

\floatname{name of float}{label}

Labels

To 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}
\addto\captionsfrench{\renewcommand{\figurename}{Image}}

Preamble commands for special LaTeX-classes

In 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-float

Example file: lang-algorithm.lyx

\floatname{algorithm}{Algorithme}

AMS-documentclasses

Example 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.

  • Theorem:
    \theoremstyle{plain}
    \newtheorem{theo}{Théorème}
    \renewenvironment{thm}{\begin{theo}}{\end{theo}}
  • Corollary:
    \theoremstyle{plain}
    \newtheorem{coro}{Corollaire}
    \renewenvironment{cor}{\begin{coro}}{\end{coro}}
  • Lemma:
    \theoremstyle{plain}
    \newtheorem{lemm}{Lemme}
    \renewenvironment{lem}{\begin{lemm}}{\end{lemm}}
  • Proposition:
    \theoremstyle{plain}
    \newtheorem{propo}{Proposition}
    \renewenvironment{prop}{\begin{propo}}{\end{propo}}
  • Conjecture:
    \theoremstyle{plain}
    \newtheorem{conje}{Conjecture}
    \renewenvironment{conjecture}{\begin{conje}}{\end{conje}}
  • Criterion:
    \theoremstyle{plain}
    \newtheorem{crit}{Critère}
    \renewenvironment{criterion}{\begin{crit}}{\end{crit}}
  • Algorithm:
    \newtheorem{algo}{Algorithme}
    \renewenvironment{algorithm}{\begin{algo}}{\end{algo}}
  • Fact:
    \theoremstyle{plain}
    \newtheorem{facte}{Fait}
    \renewenvironment{fact}{\begin{facte}}{\end{facte}}
  • Axiom:
    \theoremstyle{plain}
    \newtheorem{axi}{Axiome}
    \renewenvironment{ax}{\begin{axi}}{\end{axi}}
  • Definition:
    \theoremstyle{definition}
    \newtheorem{defi}{Définition}
    \renewenvironment{defn}{\begin{defi}}{\end{defi}}
  • Example:
    \theoremstyle{definition}
    \newtheorem{exa}{Exemple}
    \renewenvironment{example}{\begin{exa}}{\end{exa}}
  • Problem:
    \theoremstyle{definition}
    \newtheorem{prob}{Problème}
    \renewenvironment{problem}{\begin{prob}}{\end{prob}}
  • Condition:
    \theoremstyle{plain}
    \newtheorem{condi}{Condition}
    \renewenvironment{condition}{\begin{condi}}{\end{condi}}
  • Exercise:
    \theoremstyle{definition}
    \newtheorem{exer}{Exercice}
    \renewenvironment{xca}{\begin{exer}}{\end{exer}}
  • Remark:
    \theoremstyle{remark}
    \newtheorem{rema}{Remarque}
    \renewenvironment{rem}{\begin{rema}}{\end{rema}}
  • Claim:
    \theoremstyle{remark}
    \newtheorem{claime}{Assertion}
    \renewenvironment{claim}{\begin{claime}}{\end{claime}}
  • Note:
    \newtheorem{nota}{Renseignement}
    \renewenvironment{note}{\begin{nota}}{\end{nota}}
  • Notation:
    \newtheorem{notat}{Notation}
    \renewenvironment{notation}{\begin{notat}}{\end{notat}}
  • Summary:
    \newtheorem{suma}{Résumé}
    \renewenvironment{summary}{\begin{suma}}{\end{suma}}
  • Acknowledgement:
    \newtheorem{ackno}{Action de grâce}
    \renewenvironment{acknowledgement}{\begin{ackno}}{\end{ackno}}
  • Case:
    \newtheorem{casa}{Cas}
    \renewenvironment{casa}{\begin{casa}}{\end{casa}}
  • Conclusion:
    \newtheorem{conc}{Conclusion}
    \renewenvironment{conclusion}{\begin{conc}}{\end{conc}}
  • Proof:
    \newtheorem{demo}{Démonstration}
    \renewenvironment{proof}{\begin{demo}}{\end{demo}}

Beamer-presentations

First approach

Example file: lang-beamer.lyx

  • Definition:
    \newtheorem{defi}{Définition}
    \renewenvironment{definition}{\begin{defi}}{\end{defi}}
  • Definitions:
    \newtheorem{defis}{Définitions}
    \renewenvironment{definitions}{\begin{defis}}{\end{defis}}
  • Fact:
    \newtheorem{facte}{Fait}
    \renewenvironment{fact}{\begin{facte}}{\end{facte}}
  • Corollary:
    \newtheorem{coro}{Corollaire}
    \renewenvironment{corollary}{\begin{coro}}{\end{coro}}
  • Theorem:
    \newtheorem{theo}{Théorème}
    \renewenvironment{theorem}{\begin{theo}}{\end{theo}}
  • Example:
    \newtheorem{exa}{Exemple}
    \renewenvironment{example}{\begin{exa}}{\end{exa}}

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);

  • nothing else needed.
  • but currently, only German language supported, French coming soon.

Alternative method by using a macro

Based 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:
\translatethm{example}{Beispiel}
or also with a different style it could be:
\translatethm[remark]{example}{Beispiel}

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 newtheorem by newtheorem*.

i18n

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2010-10-07 19:28 UTC