Gettext » History » Version 17

jmd, 10/08/2013 12:29 AM

1 13 moyo
h1. Gettext / Translation 
2 13 moyo
3 13 moyo
h2. For translators
4 13 moyo
5 13 moyo
Since version 0.84, GLPI use gettext as localization. We use transifex for manage translations.
6 13 moyo
The project page is here : https://www.transifex.net/projects/p/GLPI/
7 13 moyo
You could register to transifex and request to join a translation team.
8 15 moyo
To discussed about translation also register to glpi-translation mailing-list : http://www.glpi-project.org/spip.php?article57
9 13 moyo
10 13 moyo
Gettext solution permit to manage :
11 13 moyo
* variable strings : strings may contains variable informations such as name or number. Example : "ID %s" to display ID 12. When several variables are used, they are ordered for manage RTL language. For example : "%1$s adds the item %2$s"
12 13 moyo
* plural : various plural forms are used depending of the language. Gettext permit to have a clean management of them.
13 13 moyo
* context : a string may have several meanings depending of the context. Gettext permit to have 2 translations for a same string when developer used context. In transifex, you could see context information in Details / Description
14 13 moyo
* RTL : gettext will permit to have a clean management of RTL languages (arabic...). Now, the RTL management is not complete but strings with parameters may have a RTL translation. Example : "%1$s %2$s" may be translated to "%2$s %1$s" (invert informations)
15 13 moyo
16 13 moyo
h3. Localisation scheme :
17 13 moyo
18 13 moyo
* Developpers add new strings to GLPI source code using standard functions (__(), __s(), _n()...), managing plurals and context.
19 13 moyo
* New strings are extract to a gettext template file (pot file) and send to transifex. New strings are proposed to translation.
20 13 moyo
* Translations are extracted from transifex as po file and convert to binary mo file used by GLPI. 
21 13 moyo
22 13 moyo
23 16 jmd
h2. For users who want editing files
24 16 jmd
25 16 jmd
en_GB.po - this is a ASCII file (readable text). It's responsible  of the text displayed on GLPI. This is the file that will be edited.
26 16 jmd
27 16 jmd
en_GB.mo - this is a binary file (machine readable). This is the file used by GLPI and is compiled from the .po file.
28 16 jmd
29 17 jmd
h3. Step 1: Download a gettext catalogs editor
30 16 jmd
31 16 jmd
For example you could use  Poedit. It's a free cross-platform gettext catalogs (.po files) editor.
32 16 jmd
33 16 jmd
Download Poedit and install
34 16 jmd
35 17 jmd
h3. Step 2: Download your xx_XX.po file
36 16 jmd
To edit your xx_XX.po file, you must first download a copy of it to your computer.
37 16 jmd
38 17 jmd
h3. Step 3: Run Poedit
39 16 jmd
Run Poedit and then click File and open xx_XX.po.
40 16 jmd
41 16 jmd
42 17 jmd
h3. Step 4: Edit
43 16 jmd
To edit a string, within Pane 1, click on the string you wish to edit. You'll then see the string appear in Pane 2. You should not edit the string in Pane 2 . Instead, click on Pane 3 and type the text you'd like to appear instead.
44 16 jmd
45 16 jmd
You may continue to edit strings by repeating the above procedure. Once you're done editing, click File > Save.
46 16 jmd
47 16 jmd
By saving, the program will automatically create a new file called xx_XX.mo. This file will appear in the same location on your computer as xx_XX.po.
48 16 jmd
49 17 jmd
h3. Step 5: Upload to your GLPI installation
50 16 jmd
Lastly, you must now upload your updated xx_XX.mo file to the locales folder, replacing the 'old' xx_XX.mo file. You do NOT need to upload the .po file, but you may if you'd like. Only the .mo file is actually used by GLPI.
51 16 jmd
52 16 jmd
53 13 moyo
h2. For developpers
54 1 moyo
55 4 moyo
* Strings with troubles with solution:
56 4 moyo
** Transfer the verb / Transfer the noun: Do not use the verb. Or add To Transfer
57 10 remi
*** Remi : create a "button" context for all verb ?
58 11 moyo
*** MoYo : good idea when a solution for contexts will be founded
59 4 moyo
** Software singular / Software plural: use _n('Software','Software',$nb)
60 4 moyo
61 4 moyo
* String with troubles without solution (for the moment):
62 3 remi
** in search::showList() // Create title  => generated string
63 5 remi
** Very High, High, Medium, Low, Very Low => various translation in french for genre (impact, priority, urgency). Proposal, use" impact/low" as msgid, "Low" as msgstr (english), with a comment for translation team
64 8 moyo
*** Moyo : Must be done with gettext context... But Zend do not permit using them.
65 9 remi
*** Remi : Nor php
66 11 moyo
*** MoYo : but problem using PHP extension (server prerequisites = all locales installed). See internal mail.
67 12 remi
** "General" : $LANG['help'][30], $LANG['setup'][139], $LANG['setup'][703]  (genre : Général/Générale)
68 7 remi
69 7 remi
* Other TODO
70 1 moyo
** in showSystemInformations, lang is forced to en_GB, so probably no need to use gettext there.
71 8 moyo
*** MoYo : Yesssss
72 9 remi
*** Remi : done :)