Translating Koha

From Koha Wiki
Jump to navigation Jump to search

[This page needs to be updated, Pootle is no longer used...]


Koha is translated into a growing number of languages. As the community keeps improving Koha and is constantly adding new features, this is a never ending task for the translators and help is always welcome.

You can find out which languages Koha is translated to, looking at our Weblate translation server.

Get started

In order to help out with translating, the first thing you need to do is create an account on Weblate - the Koha translation server.

After that you can start to make suggestions for the language directly. If you want to submit your translations directly or moderate suggestions, please introduce yourself on the koha-translate mailing list, so you can be assigned the proper permissions. It will also help to get in contact with other translators of your language.

Adding a new language

If you want to start translating Koha into a language that is not in the list, please send a message about it to the translation mailing list, and the current translation manager will help you to get started.

Have the language added in the language list for advanced search

Example: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29596

Have the language added to the translation platform

Step 1

Check that the language is supported by Weblate, https://translate.koha-community.org/admin/languages/, currently there are 94 languages.

Step 2

Select the branch (22.11, 22.05, etc) you want the language for, and then create the new translation files. In this step you must to select the language of Koha, it can be different from that of Pootle, for example Spanish is es in Pootle, es-ES in Koha

    cd /srv/kohaclone
    git pull
    git branch -D 21.11
    git checkout -b 21.11 origin/21.11.x
    cd misc/translator
    ./translate create xx-YY

Step 3

copy the new files into its own directory in Pootle's directory, and tell Weblate about them, for example (21.11 branch, xx-YY Koha language, xx-YY Pootle language):

    mkdir /srv/pootle/po/21.11/xx-YY
    cp po/xx-YY-*.po /srv/pootle/po/21.11/xx-YY/.
    source /var/www/pootle/env/bin/activate (pootle python virtualenv)
    pootle update_stores --project=21.11 --language=xx-YY -v 3
    deactivate

Step 4

Update the /srv/scripts/update-koha.sh script, adding the language. It does a lot of things, but only in the listed languages. This script is used to update strings from Koha to Weblate every month.

Translation Tools

Weblate

Weblate is a great way to translate for teams of multiple translators and is therefore the preferred way for a lot of the translators. It's also quick and easy as you don't have to install anything and can work on translations wherever and whenever you want to.

Alternative software

If you get started with a new mostly untranslated language or prefer to work locally, you can download the .po files and use a special editor to work on them.

Important: If you are working with other translators, please let them know, as their changes will most likely get lost/overwritten, when you upload the files to Weblate again. You will also have to get the permission to upload files added to your account.

Hint: Even if you translate using Weblate, the editors can be helpful in validating/testing your translations for errors. Sometimes translation mistakes can lead to a language not installing correctly, checking your translations regularly can help to prevent that.

Tips and tricks

Bookmarklet to make translation easier

A Javascript bookmarklet have been written by a member of Koha community, to make the translation of Koha easier from Weblate server.

It adds direct links to the source files (and specific lines, except for yml files) in Koha and Koha manual git repositories.

The code is available at https://github.com/msaby/koha-translate-bookmarklet . It currently works for english, french, german and italian versions of Weblate interface.

Placeholders - %s

In the strings to translate, you will often see one or multiple %s. Those are placeholders for variables or template instructions. It's important that the number of %s in the translated text matches the English version exactly. But don't get too worried by them, you can always skip those at the beginning or mark your translation as 'Needs editing' or just make a suggestion.

If you are a bit more experienced, you can get a clue about the meaning of the placeholders by looking juste above the string in Weblate, for example:

 Expiration date: %s

Juste above the source string:

 %1$s: dateexpiry | $KohaDate

It means that the %s will be replaced by the value of the dateexpiry variable, which in this case is the date a patron account expires on.

Translating system preferences

The po file for translating system preferences is a bit different to the other files. Usually all strings in the po files will display for you in alphabetic order. As a system preference description can consist of several lines and strings, it would be hard to make a good translation that way. So in order to help translators, a comment with the preference name has been added to all strings, so they can be easily searched for by the pref name and all strings for a preference can be translated sequentially. The trick is, that the comment itself is not added to the translated string. For example:

 acquisitions.pref#AcqCreateItem# Create an item when

The correct Spanish translation will be:

 Crear un ítem cuando

Searching for phrases on Weblate

When searching for a phrase in Weblate the results can be a bit unexpected as it will bring up all entries that contain at least one word of the phrase. In order to make the search more exact, you can use many criteria (phrase match, for example but also among strings with sugestions or comments, strings changed by a chosen user...)

Testing your translation

If you download the po files, you can test them for errors from the command line.

First make sure you didn't make any mistakes by validating the po files:

 msgfmt -c <your_po_file>

msgfmt comes with the gettext package.

Note: Some po file editors as listed above also offer this functionality.

If you have a test environment for Koha, you can find out how to install/update po files yourself on Installation of additional languages for OPAC and INTRANET staff client.

Updating the po files in your installation

Note This will only work in a git based development installation and not on a package installation.

This will update the po files in your installation using the current templates:

  • Run `yarn install` and install Locale::XGettext::TT2 if necessary
  • Run `gulp po:update`

Then you can either check the po files or check in Koha by installing a language with the updated files:

  • Run `cd misc/translator && ./translate install <lang>`

To create a completely new language for testing, you can use:

  • Run `gulp po:create --lang <lang>` and verify that it created all po files for that language


See: Bug 25067

See also