[717] | 1 | .. _service_translation: |
---|
[679] | 2 | |
---|
[717] | 3 | Translation Support |
---|
| 4 | =================== |
---|
[679] | 5 | |
---|
[717] | 6 | ZOO-Kernel support translating internal messages it emits but it can |
---|
| 7 | also translate both the metadata informations stored in the ZCFG file |
---|
| 8 | and the messages emitted by the ZOO-Service itself. This document show |
---|
| 9 | how to create the files required to handle such a translation process |
---|
| 10 | for the ZOO-Services. |
---|
[679] | 11 | |
---|
| 12 | |
---|
| 13 | ZCFG translation |
---|
| 14 | -------------------------- |
---|
| 15 | |
---|
[717] | 16 | First of all, use the following commands from your Services Provider |
---|
| 17 | directory in order to extract all the messages to translate from the |
---|
| 18 | ZCFG files : |
---|
[679] | 19 | |
---|
| 20 | :: |
---|
| 21 | |
---|
| 22 | #!/bin/bash |
---|
[717] | 23 | mkdir -p locale/{po,.cache} |
---|
[679] | 24 | for j in cgi-env/*zcfg ; |
---|
| 25 | do |
---|
| 26 | for i in Title Abstract; |
---|
| 27 | do |
---|
[696] | 28 | grep $i $j | sed "s:$i = :_ss(\":g;s:$:\"):g" ; |
---|
[679] | 29 | done; |
---|
| 30 | done > locale/.cache/my_service_string_to_translate.c |
---|
| 31 | |
---|
| 32 | |
---|
[722] | 33 | Then generate the ``messages.po`` file based on the Services Provider |
---|
[717] | 34 | source code (located in ``service.c`` in this example) using the |
---|
| 35 | following command: |
---|
[679] | 36 | |
---|
| 37 | :: |
---|
| 38 | |
---|
| 39 | #!/bin/bash |
---|
[696] | 40 | xgettext service.c locale/.cache/my_service_string_to_translate.c -o message.po -p locale/po/ -k_ss |
---|
[679] | 41 | |
---|
[722] | 42 | Once ``messages.po`` is created, use the following command to create |
---|
| 43 | the ``.po`` file for the targeted language to translate into. We will |
---|
| 44 | use the French language here as an example: |
---|
[679] | 45 | |
---|
| 46 | :: |
---|
| 47 | |
---|
| 48 | #!/bin/bash |
---|
| 49 | cd locale/po/ |
---|
| 50 | msginit -i messages.po -o zoo_fr_FR.po -l fr |
---|
| 51 | |
---|
[717] | 52 | Edit the ``zoo_fr_FR.po`` file with your favorite text editor or using |
---|
| 53 | one of the following tools: |
---|
[679] | 54 | |
---|
[696] | 55 | * `poedit <http://www.poedit.net/>`__ |
---|
| 56 | * `virtaal <http://translate.sourceforge.net/wiki/virtaal/index>`__ |
---|
| 57 | * `transifex <https://www.transifex.net/>`__ |
---|
[679] | 58 | |
---|
[717] | 59 | Once the ``zoo_fr_FR.po`` file is completed, you can generate and |
---|
| 60 | install the corresponding ``.mo`` file using the following command: |
---|
[679] | 61 | |
---|
| 62 | :: |
---|
| 63 | |
---|
| 64 | #!/bin/bash |
---|
| 65 | msgfmt locale/po/zoo_fr_FR.po -o /usr/share/locale/fr/LC_MESSAGES/zoo-services.mo |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | In order to test the Services Provider ZCFG and internal messages |
---|
| 69 | translation, please add the language argument to you request. As an |
---|
| 70 | example, such a request: |
---|
| 71 | |
---|
[696] | 72 | http://youserver/cgi-bin/zoo_loader.cgi?request=GetCapabilities&service=WPS |
---|
[679] | 73 | |
---|
| 74 | would become the following: |
---|
| 75 | |
---|
[696] | 76 | http://youserver/cgi-bin/zoo_loader.cgi?request=GetCapabilities&service=WPS&language=fr-FR |
---|
[679] | 77 | |
---|
| 78 | The following command may also be useful in order to pull all the translations already available for a specific language. |
---|
| 79 | |
---|
| 80 | :: |
---|
| 81 | |
---|
| 82 | #!sh |
---|
| 83 | msgcat -o compilation.po $(find ../../ -name fr_FR.utf8.po) |
---|
| 84 | msgfmt compilation.po -o /usr/share/locale/fr/LC_MESSAGES/zoo-services.mo |
---|