From Mageia wiki
Jump to: navigation, search


this page is a draft.
It requires improvements. If you want to improve it, simply log in and click on the Edit tab.

Please remove this {{Draft}}template, when you're sure the page is complete and correct.


View the other draft pages, or other pages to improve and maintain.

Aim

This Howto deals with the use of Calenco and Gettext files for translation of Mageia documentation in XML.

Prerequisites

To alleviate the procedure explained below it is required to install po4a package and mount Calenco WebDAV or just put the following address into Dolphin address bar:

webdav://mageia.calenco.com:8284/workspaces/Documentation/content/en/

then enter your login and password. As soon as the folder is mounted add its bookmark to the Places pane.

Note:
Direct mounting of Calenco WebDAV using Mageia Control Center can make your system unbootable.

Step-by-step tutorial

Creating POT template

  1. Create the folder for your translation somewhere on your hard drive.
  2. Copy the needed XML files from the mounted "calenco-webdav" folder into some directory (choose "en" for certainty). For example, the list for Mageia Installer help can be found here.
  3. Copy the following text into your favorite text editor (e.g. KWrite)
    #!/bin/bash
    
      po4a-gettextize --format docbook --master-charset UTF-8 --po help.pot \
       --msgid-bugs-address "doc-discuss@ml.mageia.org" --copyright-holder "Mageia" \
       --package-name "Mageia Installer Help" --package-version "3.0" \
       $(
    for doc in en/*.xml; do
      echo --master $doc
    done
      )
  4. Save it as makepot.sh in the root folder of your translation (the folder which already contains en subdirectory) and make it executable (see the "File Properties" item in the context menu of this file in file browser).
  5. Execute this script (e.g. call the console panel with pressing F4 in Dolphin and enter ./makepot.sh).

Translating the file

Use your favorite PO-editor to translate the file. It can be helpful to use translation memory facilities of the editor.

You can install the following common PO-editors:

  • Lokalize (KDE default editor)
  • Virtaal (GTK+-based editor with good integration into translation services)
  • GTranslator (GNOME default editor)
  • poEdit (GTK+-based basic editor, may break your files with its translation memory facilities)
  • OmegaT (multi-platform Java-based editor)

Generating the translated XML files

Use the following script (makedoc.sh) to convert your translation into XML

#!/bin/bash -e
LANG=$1

for doci in en/*.xml; do
  docfilename=${doci#*/}
  doc=${docfilename%.*}
  if [[ $LANG == "" ]]; then
    for i in *.po
    do
       ILANG=${i%.*}
       echo "Producing XML "$doc" for locale "$ILANG
       po4a-translate -k 0 --format docbook --master-charset utf-8 --localized-charset utf-8 \
         --master en/${doc}.xml \
         --po $ILANG.po --localized $ILANG/${doc}.xml
       perl -i -p -e "s/version=\"5\.0\"/version=\"5\.0\" xml:lang=\"$ILANG\"/;" $ILANG/${doc}.xml
       perl -i -p -e "s/xml\:lang=\"$ILANG\"\ xml\:lang=\"$ILANG\"/xml\:lang=\"$ILANG\"/;" $ILANG/${doc}.xml
    done
  else
    echo "Producing XML of "$doc" for locale "$LANG
    po4a-translate -k 0 --format docbook --master-charset utf-8 --localized-charset utf-8 \
      --master en/${doc}.xml \
      --po $LANG.po --localized $LANG/${doc}.xml
    perl -i -p -e "s/version=\"5\.0\"/version=\"5\.0\" xml:lang=\"$LANG\"/;" $LANG/${doc}.xml
    perl -i -p -e "s/xml\:lang=\"$LANG\"\ xml\:lang=\"$LANG\"/xml\:lang=\"$LANG\"/;" $LANG/${doc}.xml
  fi
done
Note:
Use ./makedoc.sh your_locale to update your locale only

Now, you can commit your translations (one by one) using File → Upload item in Calenco web interface or using direct copying to your language WebDAV folder using Dolphin or any other file manager.

Updating the translation

Should you need to update your translation use the following steps.

  1. Sort the files in calenco-webdav folder by date and copy the newest versions into your en subdirectory.
  2. Use makepot.sh to generate the POt template.
  3. Use the following script (update.sh) to update translation
    #!/bin/bash
    POFILE=$1
    
    if [[ $POFILE == "" ]]; then
      for i in *.po
      do
        echo -n $i": "
        msgmerge --backup=none --update $i help.pot && \
        msgfmt -o /dev/null --statistics --check $i
      done
    else
      echo -n $1".po: "
      msgmerge --update $1.po help.pot && \
      msgfmt -o /dev/null --statistics --check $1.po
    fi
    
    Note:
    Use ./update.sh your_locale to update your locale only

Conclusion

The advantage of this approach is that you do not have to compare XML files and do something with markup. The only thing you should concentrate on is the messages. ;)