J.
Rundholz

# Translation

This chapter should give any one (in particular people who are not developers) a first overview on how they can translate &app; into another language. The information given here is not only valid for &app; but as serves for the translation of any KDE project.

## Basics

First of all you need to get the required files. There are two types of files which might be of interest to you. Files ending in `.pot` and files ending in `.po`.

Files ending in `.pot` are the source for the translation. They only contain the English texts you need to translate and are generated for each release of the project. The one for &app; is named `kmymoney.pot`. The po file contains the English and the translated text, e.g. German. There might be two cases: The first case you can't find a po file for your language or the second there is already a po file for your language available. In the latter case you can already start &app; in your language, but may be the translation is not complete or you simply want to improve the translation.

Now you need to get these files from the project's &cvs; repository. You don't need to worry what exactly &cvs; does, for a translater it is more or less only a file system from where you can download the files you need. For &app; you can either go to the &cvs; page and call the &cvs; web front end or follow this link. I would recommend to download the pot and po file of the latest stable version (at the moment 0.8), not any older files and not the one which is under development at the moment. In order to test your translation later you should run the same version on your box.

For the actual translation I recommend the program kbabel. Other people use emacs, as usual it is just a personal choice. All examples given here are based on kbabel.

### How to get your po file

As explained earlier the actual translation is done by modifying the po file. The next step is to create a po file to start the translation.

#### No po file for my language available

That's the most simple case: Rename `kmymoney.pot` to `lang.po` where lang is your language code e.g. de for German.

#### po file for my language available

In case you already have a language file it is advisable that you check how the English text entries in that file differ from the English texts in the pot file. Maybe for some reason the pot file is further developed than the po file. In this case even though you would translate the whole po file you would still see some English texts in &app;. If you know that this is not the case, i.e. your po file has all the latest English text inside, you can use this one for translation. The minimum check you should perform is to compare the number of messages. Just load the po and the pot file into kbabel and you see how many messages you have in each file.

In case that both files differ you should merge them (since you don't want to lose someone else's work). Merging can be done using kbabel very easily .

- Copy `kmymoney.pot` to `lang-new.po` and open this file with kbabel.

- In kbabel choose Tools Rough translation from the menu. A dialog pops up. Choose the following options:

  - What to translate::Untranslated Entries

  - Options::Mark changed entries as fuzzy

  - Dictionaries::Use::PO Compendium

  Don't select anything else.

- Now press the "configure" button. In the next dialog enter the path to your already existing po file. Furthermore set the options:

  - Options::Case sensitive

  - A text matches if::Equal to searched text

  Don't select anything else.

The original po file could have entries marked as "fuzzy", that means that the translation might be not very good or even horribly wrong. After you did this merger process you lose this information. It might be a good idea to translate all fuzzy strings in the old, unmerged po file before you do this explained merging process.

## Translating

Now you can take the new po file and start the translation with kbabel or any other tool. It might be a good idea to create a glossary of terms whenever you use a technical term. Such a glossary is available for the German translation, check it out to see how it should look like. You might want to check the gnucash project if they have already a glossary for your language. This would be a starting point for you, but please extend it.

## Test your work

Last but not least you need to check your translation, especially if the translated text fits into the context. Also you shouldn't be surprised how many typos and mistakes you make while translating the text. Check it carefully! Now a few steps you should perform to test your translation (after you used a spellchecker etc.).

First you can run the command

      thb:~> msgcat --width=77 -o lang-output.po lang-input.po

as root. This command just restricts the length of each line to 77 characters. This is only necessary if you want to read the raw po file in some text editor. Some people who do proof reading prefer this instead of endless lines. The number of characters depends of some personal taste. I prefer about 50 characters per line, then a diff file can be displayed without vertical scrolling.

Now run as root the command

      thb:~> msgfmt -vvv lang.po kmymoney.mo

The mo file is the language file you need for your program. You just need to replace the original mo file of &app; with this one (perform a backup of the original file before). The location of your mo file depends on your distro, for SuSE it is `/opt/kde3/share/local/lang/LC_MESSAGES` and for Debian `/usr/share/local/lang/LC_MESSAGES`. For lang you can use any string, like de or even de_test if you want to run it with a test language. Be aware that &app; uses some text strings from KDE and since they are probably not available with de_test you still might see some English text. If you can't find the file on your harddrive try either

      thb:~> find / -name kmymoney.mo

as root or if you used an `rpm` file for the installation you can run

      thb:~> rpm -q kmymoney --filesbypkg

In order to run &app; either start it as usual (if your default KDE language is the language you want to test) or call it via

      thb:~> KDE_LANG=de kmymoney

from a konsole or xterm.

## Merging an old po file with an updated pot file

There are cases when the pot file is regenerated before you can send your updated po file. If you just commit your file after that, it will show up as old in the translation stats, because it references an outdated pot file.

To fix this, you have to merge the po file with the updated pot file.

First, get the latest pot file. And in the po folder, run this command.

      thb:~/kmymoney/po> make -f ../admin/Makefile.common package-merge POFILES="de.po" PACKAGE=kmymoney

You can merge multiple po files at the same time. Just list them in the POFILES option.

      thb:~/kmymoney/po> make -f ../admin/Makefile.common package-merge POFILES="de.po es.po" PACKAGE=kmymoney