Gettext » History » Version 19

trasher, 02/24/2017 08:18 AM

1 19 trasher
h1. PAGE OUTDATED
2 19 trasher
3 19 trasher
*The current page is out-of-date. Please refer to the new documentation to know about translations:
4 19 trasher
http://glpi-developer-documentation.readthedocs.io/en/latest/devapi/translations.html*
5 19 trasher
6 13 moyo
h1. Gettext / Translation 
7 13 moyo
8 13 moyo
h2. For translators
9 13 moyo
10 13 moyo
Since version 0.84, GLPI use gettext as localization. We use transifex for manage translations.
11 13 moyo
The project page is here : https://www.transifex.net/projects/p/GLPI/
12 13 moyo
You could register to transifex and request to join a translation team.
13 15 moyo
To discussed about translation also register to glpi-translation mailing-list : http://www.glpi-project.org/spip.php?article57
14 13 moyo
15 13 moyo
Gettext solution permit to manage :
16 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"
17 13 moyo
* plural : various plural forms are used depending of the language. Gettext permit to have a clean management of them.
18 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
19 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)
20 13 moyo
21 13 moyo
h3. Localisation scheme :
22 13 moyo
23 13 moyo
* Developpers add new strings to GLPI source code using standard functions (__(), __s(), _n()...), managing plurals and context.
24 13 moyo
* New strings are extract to a gettext template file (pot file) and send to transifex. New strings are proposed to translation.
25 13 moyo
* Translations are extracted from transifex as po file and convert to binary mo file used by GLPI. 
26 13 moyo
27 13 moyo
28 16 jmd
h2. For users who want editing files
29 16 jmd
30 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.
31 16 jmd
32 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.
33 16 jmd
34 17 jmd
h3. Step 1: Download a gettext catalogs editor
35 16 jmd
36 16 jmd
For example you could use  Poedit. It's a free cross-platform gettext catalogs (.po files) editor.
37 16 jmd
38 16 jmd
Download Poedit and install
39 16 jmd
40 17 jmd
h3. Step 2: Download your xx_XX.po file
41 18 jmd
42 16 jmd
To edit your xx_XX.po file, you must first download a copy of it to your computer.
43 16 jmd
44 17 jmd
h3. Step 3: Run Poedit
45 18 jmd
46 16 jmd
Run Poedit and then click File and open xx_XX.po.
47 16 jmd
48 16 jmd
49 17 jmd
h3. Step 4: Edit
50 18 jmd
51 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.
52 16 jmd
53 16 jmd
You may continue to edit strings by repeating the above procedure. Once you're done editing, click File > Save.
54 16 jmd
55 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.
56 16 jmd
57 17 jmd
h3. Step 5: Upload to your GLPI installation
58 18 jmd
59 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.
60 16 jmd
61 16 jmd
62 13 moyo
h2. For developpers
63 1 moyo
64 4 moyo
* Strings with troubles with solution:
65 4 moyo
** Transfer the verb / Transfer the noun: Do not use the verb. Or add To Transfer
66 10 remi
*** Remi : create a "button" context for all verb ?
67 11 moyo
*** MoYo : good idea when a solution for contexts will be founded
68 4 moyo
** Software singular / Software plural: use _n('Software','Software',$nb)
69 4 moyo
70 4 moyo
* String with troubles without solution (for the moment):
71 3 remi
** in search::showList() // Create title  => generated string
72 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
73 8 moyo
*** Moyo : Must be done with gettext context... But Zend do not permit using them.
74 9 remi
*** Remi : Nor php
75 11 moyo
*** MoYo : but problem using PHP extension (server prerequisites = all locales installed). See internal mail.
76 12 remi
** "General" : $LANG['help'][30], $LANG['setup'][139], $LANG['setup'][703]  (genre : Général/Générale)
77 7 remi
78 7 remi
* Other TODO
79 1 moyo
** in showSystemInformations, lang is forced to en_GB, so probably no need to use gettext there.
80 8 moyo
*** MoYo : Yesssss
81 9 remi
*** Remi : done :)