| 1 |
How to do translations for sweep - a quick overview |
|---|
| 2 |
=================================================== |
|---|
| 3 |
|
|---|
| 4 |
includes information from Mathieu Roy and Silvia Pfeiffer |
|---|
| 5 |
|
|---|
| 6 |
For more detailed information refer to: |
|---|
| 7 |
http://www.gnu.org/manual/gettext/index.html |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
(1) How to create and test a translation for a new language? |
|---|
| 11 |
------------------------------------------------------------ |
|---|
| 12 |
Grab the po/sweep.pot file and copy it to the new language, |
|---|
| 13 |
naming the file after a language code as defined by ISO 639: |
|---|
| 14 |
ll.po (e.g. fr.po), with a possible country-specific adaptation |
|---|
| 15 |
as in ll_CC.po. |
|---|
| 16 |
[For the codes, refer to |
|---|
| 17 |
http://www.gnu.org/manual/gettext/html_mono/gettext.html#SEC221] |
|---|
| 18 |
|
|---|
| 19 |
Translate the strings in that file and save it in the /po folder. |
|---|
| 20 |
|
|---|
| 21 |
Edit the "configure.in" file (in sweep-x.x.x folder), adding the |
|---|
| 22 |
new language to the "ALL_LINGUAS directive. |
|---|
| 23 |
|
|---|
| 24 |
Should look like this : |
|---|
| 25 |
ALL_LINGUAS="fr se de" |
|---|
| 26 |
AM_GNU_GETTEXT |
|---|
| 27 |
|
|---|
| 28 |
The next "configure" will include the new language, the next |
|---|
| 29 |
"make dist" will create the machine-readable translation, and the |
|---|
| 30 |
next "make install" will copy it to the system folder where |
|---|
| 31 |
gettext can find it. |
|---|
| 32 |
|
|---|
| 33 |
Testing the new translation goes via setting of environment |
|---|
| 34 |
variables (LANG is usually enough). |
|---|
| 35 |
|
|---|
| 36 |
Mathieu recommends: |
|---|
| 37 |
[user@host /]$ export LANG="fr_FR"&&LC_ALL="fr"&&LINGUAS="fr" |
|---|
| 38 |
(configures this terminal until you close it) |
|---|
| 39 |
[user@host /]$ sweep |
|---|
| 40 |
(should work in french) |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
(2) How to keep the code and its translations up to date? |
|---|
| 45 |
--------------------------------------------------------- |
|---|
| 46 |
|
|---|
| 47 |
When coding, keep marking displayed text with _("blah") where function |
|---|
| 48 |
calls are possible or N_("blah") for statically defined strings. Where |
|---|
| 49 |
the string is actually used in the program, you need to put another |
|---|
| 50 |
_(variable) around it! A proposed guideline from gnu.org is to use |
|---|
| 51 |
format strings instead of string concatenation and to keep sentences |
|---|
| 52 |
within one string. |
|---|
| 53 |
|
|---|
| 54 |
CAUTION: Be aware that when you mark a string with N_("blah"), this |
|---|
| 55 |
only marks it for translation. |
|---|
| 56 |
|
|---|
| 57 |
When creating new code files (.[ch]) with translatable strings in |
|---|
| 58 |
them, they need to be added manually to the po/POTFILES.in file. |
|---|
| 59 |
The next "configure" will then automatically take care of creating |
|---|
| 60 |
the po/POTFILES file and the "make" thereafter will create the |
|---|
| 61 |
updated po/sweep.pot file. For merging those updated strings into |
|---|
| 62 |
existing translations, a "make dist" is required. |
|---|
| 63 |
|
|---|
| 64 |
When a translator updates his/her translation file, copy it back to |
|---|
| 65 |
the /po directory. It will be compiled into machine-readable form with |
|---|
| 66 |
the next "make dist" and installed with the next "make install". |
|---|