Localization/Concepts/Auto Assists: Difference between revisions

From KDE TechBase
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 12: Line 12:
* <tt>check_po_files</tt>
* <tt>check_po_files</tt>
These two scripts and its dependencies are located in the "scripts/" directory in each of the three currently maintained localization branches:
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,
# branches/stable/l10n-kde4,
2. trunk/l10n-kde4 and
# trunk/l10n-kde4 and
3. trunk/l10n-kf5.
# trunk/l10n-kf5.


There is an [http://websvn.kde.org/*checkout*/trunk/l10n-kf5/scripts/notes/scripty-map.xmi 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.
There is an [http://websvn.kde.org/*checkout*/trunk/l10n-kf5/scripts/notes/scripty-map.xmi 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.
Line 25: Line 25:


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


==== Adjustment of .po headers ====
==== Adjustment of .po headers ====
Line 35: Line 35:
# If the language directory contains the file <tt>messages/kdelibs/kdelibs4.po</tt>, then Scripty copies the '''plural formula''' and a couple of other fields in the header ('''merges''' the header) from that <tt>kdelibs4.po</tt> file to all other translation catalogs for the same language.
# If the language directory contains the file <tt>messages/kdelibs/kdelibs4.po</tt>, then Scripty copies the '''plural formula''' and a couple of other fields in the header ('''merges''' the header) from that <tt>kdelibs4.po</tt> file to all other translation catalogs for the same language.
# 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?)
# 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:
How header adjustment works in l10n-kf5:
Line 40: Line 41:
# If the language directory contains the file <tt>messages/frameworks/ki18n5.po</tt>, 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.
# If the language directory contains the file <tt>messages/frameworks/ki18n5.po</tt>, 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 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 <tt>check_po_files</tt> with a few runs of the helper script <tt>change-header.pl</tt>.
The adjustment described above is done in the script <tt>check_po_files</tt> with a few runs of the helper script <tt>change-header.pl</tt>.
== Matching translation files and source code ==
Scripty needs access to the source code of projects for multiple activities:
# Populate catalog templates (.pot files) from the source code,
# Merge translations from desktop_*.po files back to .desktop files residing in the source code repository,
# 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 <tt>scripts/get_paths</tt>.
Let's see how it works. Consider an application maintaining two development branches - master and stable, e.g. Konversation. By means of <tt>trunk/l10n-kde4/scripts/get_paths</tt> 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 <tt>branches/stable/l10n-kde4/scripts/get_paths</tt> under <tt>function get_branch { ... }</tt>. For the time I'm writing this, the stable branch for Konversation is "1.5".

Latest revision as of 22:58, 5 August 2014

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

TBD

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".