doc/book/fr/12-internationalization.fr.txt
author Stephanie Marcu
Tue, 19 Jan 2010 12:19:14 +0100
changeset 4262 83d245d33436
parent 1898 39b37f90a8a4
permissions -rw-r--r--
we should access to __regid__ instead of id since in that case bw compat fail: access to id throuhg a class returns the property object instead of calling the property's method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     2
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     3
.. _internationalization:
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     4
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     5
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     6
Internationalization
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     7
====================
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     8
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
     9
The internationalization 
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    10
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    11
Le système d'internationalisation de l'interface web d'erudi est basé sur le
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    12
système `GNU gettext`_.
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    13
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    14
.. _`GNU gettext`: http://www.gnu.org/software/gettext/
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    15
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    16
Messages à internationaliser
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    17
----------------------------
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    18
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    19
Marquage des messages à internaliser
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    20
````````````````````````````````````
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    21
Les chaines de caractères à internationaliser sont marqués par l'appel à la
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    22
fonction `_` *OU* par la méthode équivalent de la requête dans le code python ou
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    23
dans les expressions python de template TAL. 
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    24
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    25
Dans les templates erudi-tal, il est également possible d'insérer une chaine à
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    26
traduire via les balises `i18n:content` et  `i18n:replace`.
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    27
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    28
De plus des messages correspondant aux entités/relations utilisés par le schéma
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    29
de l'application seront automatiquement ajoutés.
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    30
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    31
Renvoi d'un message internationalisé lors de la construction d'une page
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    32
```````````````````````````````````````````````````````````````````````
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    33
La fonction *built-in* `_` ne doit servir qu'**à marquer les messages à
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    34
traduire**, non pas à récupérer une traduction. Il faut pour cela utiliser la
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    35
méthode `_` de l'objet requête, sans quoi vous récupérerez l'identifiant de
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    36
message au lieu de sa traduction dans la langue propre à la requête.1
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    37
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    38
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    39
Gestion des catalogues de traduction
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    40
------------------------------------
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    41
Une fois l'application rendu internationalisable coté code, reste à gérer les
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    42
catalogues de traductions. erudi-ctl intègre pour cela les commandes suivantes : 
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    43
1898
39b37f90a8a4 [cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 80
diff changeset
    44
* `i18ncubicweb`, met à jour les catalogues de messages *de la librairie
80
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    45
  erudi*. Sauf si vous développez sur le framework (et non votre propre
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    46
  application), vous ne devriez pas avoir à utiliser cette commande
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    47
1898
39b37f90a8a4 [cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 80
diff changeset
    48
* `i18ncube`, met à jour les catalogues de messages *du composant* (ou de tous
80
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    49
  les composants). A la suite de cette commande, vous devez mettre à jour les
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    50
  fichiers de traduction *.po* dans le sous-répertoire "i18n" de votre
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    51
  template. Évidemment les traductions précédentes toujours utilisées ont été
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    52
  conservées.
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    53
1898
39b37f90a8a4 [cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 80
diff changeset
    54
* `i18ninstance`, recompile les catalogues de messages *d'une instance* (ou de
80
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    55
  toutes les instances) après mise à jour des catalogues de son composant. Cela
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    56
  est effectué automatiquement lors d'une création ou d'une mise à jour. Les
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    57
  catalogues de messages compilés se trouvent dans le répertoire
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    58
  "i18n/<lang>/LC_MESSAGES/erudi.mo" de l'application où `lang` est
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    59
  l'identifiant de la langue ('en' ou 'fr' par exemple).
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    60
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    61
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    62
Le cas classique
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    63
````````````````
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    64
Vous avez ajouté et/ou modifié des messages d'un composant utilisé par votre
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    65
application (en ajoutant une nouvelle vue ou en ayant modifié le schéma par
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    66
exemple) :
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    67
1898
39b37f90a8a4 [cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 80
diff changeset
    68
1. `cubicweb-ctl i18ncube <composant>`
80
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    69
2. éditer les fichiers <composant>/xxx.po dans pour y rajouter les traductions
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    70
   manquantes (`msgstr` vide) 
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    71
3. `hg ci -m "updated i18n catalogs"`
1898
39b37f90a8a4 [cw-ctl] rename i18n commands (see #342889)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 80
diff changeset
    72
4. `cubicweb-ctl i18ninstance <monapplication>`
80
cb0c7936babf french version
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
diff changeset
    73