Package pology

Package pology

The Pology Python library is a package for custom processing of PO files in field environments. It provides the foundation for Pology end-user tools.

Core Pology objects -- abstractions of PO catalog and its entries -- are designed to allow quick writing of robust scripts. By default, the correctness of processed objects is strictly enforced, but such that the user may easily switch it off for better performance. Modifications to PO files on disk are always explicit, and Pology tries to change as few lines as possible to be friendly to version control systems.

Pology provides utility various modules for typical processing needs of different kinds of data in PO files. These include word-splitting, markup handling, wrapping, comment parsing, summary reporting, validation, etc.

Pology also contains language-specific and project-specific modules, for functionality that is tightly linked to particular languages and translation projects.


Authors:
Chusslove Illich (Часлав Илић) <caslav.ilic@gmx.net>, Sébastien Renard <sebastien.renard@digitalfox.org>, Nicolas Ternisien <nicolas.ternisien@gmail.com>, Goran Rakic (Горан Ракић) <grakic@devbase.net>, Nick Shaforostoff (Николай Шафоростов) <shaforostoff@kde.ru>

License: GPLv3

Submodules

Classes
  PologyError
Base exception class for errors in Pology.
  TextTrans
Class for intermediate handling of translated user-visible text.
Functions
ColorString
_(_ctxt_, _text_, **kwargs)
Get translation of the text into user's language.
string
datadir()
Get data directory of Pology installation.
string
localedir()
Get locale directory of Pology installation.
ColorString
n_(_ctxt_, _stext_, _ptext_, **kwargs)
Get translation of the singular/plural text into user's language.
TextTrans
t_(_ctxt_, _text_, **kwargs)
Get deferred translation of the text into user's language.
TextTrans
tn_(_ctxt_, _stext_, _ptext_, **kwargs)
Get deferred translation of the singular/plural text into user's language.
string
version()
Get Pology version string.
(int, int, int, string)
version_info()
Get Pology version information.
Variables
  __package__ = 'pology'
Function Details

_(_ctxt_, _text_, **kwargs)

 

Get translation of the text into user's language.

If there are any formatting directives in the text, they should be named; the arguments which substitute them are given as keyword values following the text.

Parameters:
  • _ctxt_ (string) - the context in which the text is used
  • _text_ (string) - the text to translate
Returns: ColorString
translated text if available, otherwise original

datadir()

 

Get data directory of Pology installation.

Returns: string
absolute directory path

localedir()

 

Get locale directory of Pology installation.

Returns: string
absolute directory path

n_(_ctxt_, _stext_, _ptext_, **kwargs)

 

Get translation of the singular/plural text into user's language.

If there are any formatting directives in the text, they should be named; the arguments which substitute them are given as keyword values following the text.

The plural deciding number is given by the num keyword argument. If no such key exists, or its value is not an integer, an error is raised.

Parameters:
  • _ctxt_ (string) - the context in which the text is used
  • _stext_ (string) - the text to translate for the singular case
  • _ptext_ (string) - the text to translate for the plural case
Returns: ColorString
translated text if available, otherwise original

t_(_ctxt_, _text_, **kwargs)

 

Get deferred translation of the text into user's language.

Like _(), but returns deferred translation object instead of translated text as string. In this way some or all arguments for named formatting directives can be supplied at a later point, using with_args method, and then the translated string obtained by to_string method.

Returns: TextTrans
deferred translation

tn_(_ctxt_, _stext_, _ptext_, **kwargs)

 

Get deferred translation of the singular/plural text into user's language.

Like n_(), but returns deferred translation object instead of translated text as string. In this way some or all arguments for named formatting directives can be supplied at a later point, using with_args method, and then the translated string obtained by to_string method.

Returns: TextTrans
deferred translation

version()

 

Get Pology version string.

Returns: string
version string

version_info()

 

Get Pology version information.

Pology version information consists of three version numbers (major, minor, bugfix) and an arbitrary suffix (may be empty).

Returns: (int, int, int, string)
version tuple (major, minor, bugfix, suffix)