Localization/Concepts/Auto Assists

Automatic Translation Assists
On Localization   Concepts
Prerequisites   The PO Format
Related Articles   Building KDE's l10n Module
External Reading   n/a

Daily jobs done by Scripty

Language coordinators would have a lot of routine work to do unless there was a daily job running on the KDE l10n server and doing simple cleanups in SVN. It is called Scripty and consists of a the following scripts:

  • update_translations
  • check_po_files

These two scripts and its dependencies are located in the "scripts/" directory in each of the three currently maintained localization branches:

  1. branches/stable/l10n-kde4,
  2. trunk/l10n-kde4 and
  3. trunk/l10n-kf5.

There is an Umbrello diagram which describes usage of scripts in the "scripts/" directory in SVN. It was initially drawn for KDE4 and is not up to date as of KF5.0, but still may help a lot if you want to get familiar with Scripty.

Daily script: update_translations


Daily script: check_po_files

The script check_po_files does the following operations on translation catalogs:

  1. Adjusts headers of .po files to make them uniform (using the other script - scripts/change-header.pl). See below "Adjustment of .po headers".
  2. Check .po headers with msgfmt
  3. Makes sure there are no translation templates (.pot) in language directories
  4. Runs simple checks for translations in desktop_*.po

Adjustment of .po headers

How header adjustment worked in l10n-kde4:

  1. If the language directory contains the file messages/kdelibs/kdelibs4.po, then Scripty copies the plural formula and a couple of other fields in the header (merges the header) from that kdelibs4.po file to all other translation catalogs for the same language.
  2. Profit! For example, if you are a translator and your .po editor does not add all the necessary fields to the header or gets the plural formula wrong, then Scripty will fix those problems. It is very useful for those localization teams that use unofficial (tweaked) plural formulas for KDE (Serbian, Ukrainian, Russian - any else?)

How header adjustment works in l10n-kf5:

  1. If the language directory contains the file messages/frameworks/kcoreaddons5_qt.po, then it merges the header from there to all *_qt.po files - to those catalogs that will be used with Qt localization system and the tr() call.
  2. If the language directory contains the file messages/frameworks/ki18n5.po, then it merges the header from there to all other *.po files - to those catalogs that will be used with KI18n localization system and the i18n*() calls.

The above mentioned language teams using tweaked plural formulas will have different plural formulas in *_qt.po and other .po files, but still the plural formulas will be consistent inside each of these two sets of .po files.

The adjustment described above is done in the script check_po_files with a few runs of the helper script change-header.pl.

Matching translation files and source code

Scripty needs access to the source code of projects for multiple activities:

  1. Populate catalog templates (.pot files) from the source code,
  2. Merge translations from desktop_*.po files back to .desktop files residing in the source code repository,
  3. Merge translations back to .appdata.xml files residing in the source code repository.

The logic dedicated to decide in what source code repository/branch to look, is contained in the file scripts/get_paths.

Let's see how it works. Consider an application maintaining two development branches - master and stable, e.g. Konversation. By means of trunk/l10n-kde4/scripts/get_paths Scripty will be directed to the "master" branch in the Konversation Git repository to collect the translatable messages for the translations in branch "trunk". Then, for the "stable" branch of translations Scripty will look in a specific branch in the Konversation Git repo, defined in branches/stable/l10n-kde4/scripts/get_paths under function get_branch { ... }. For the time I'm writing this, the stable branch for Konversation is "1.5".

This page was last edited on 5 August 2014, at 22:58. Content is available under Creative Commons License SA 4.0 unless otherwise noted.