ged2doc.i18n

Python module responsible for internationalization of ged2doc.

It covers all aspects that are language- or locale-dependent. In particular it does these things:

  • translates short string messages from application language into output language

  • translates dates into printable format according to locale preferences

Note that we do not use system locale, instead we expect client to provide small set of configuration options such as output language and date format.

Functions

TR(x)

This is no-op function, only used to mark translatable strings, to extract all strings run pygettext -k TR ...

Classes

I18N(lang[, datefmt, domain])

Class with methods responsible for various aspects of translations.

ged2doc.i18n.TR(x)[source]

This is no-op function, only used to mark translatable strings, to extract all strings run pygettext -k TR ...

class ged2doc.i18n._NullFallback[source]

Bases: object

Special fallback class for gettext which returns None for missing translations.

Methods

gettext

ugettext

gettext(message)[source]
ugettext(message)[source]
class ged2doc.i18n._TemplateDateVisitor[source]

Bases: ged4py.date.DateValueVisitor

Visitor class that builds template strings and keywords from dates.

Methods

visitAbout(date)

Visit an instance of DateValueAbout type.

visitAfter(date)

Visit an instance of DateValueAfter type.

visitBefore(date)

Visit an instance of DateValueBefore type.

visitCalculated(date)

Visit an instance of DateValueCalculated type.

visitEstimated(date)

Visit an instance of DateValueEstimated type.

visitFrom(date)

Visit an instance of DateValueFrom type.

visitInterpreted(date)

Visit an instance of DateValueInterpreted type.

visitPeriod(date)

Visit an instance of DateValuePeriod type.

visitPhrase(date)

Visit an instance of DateValuePhrase type.

visitRange(date)

Visit an instance of DateValueRange type.

visitSimple(date)

Visit an instance of DateValueSimple type.

visitTo(date)

Visit an instance of DateValueTo type.

visitSimple(date)[source]

Visit an instance of DateValueSimple type.

Parameters
dateDateValueSimple

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitPeriod(date)[source]

Visit an instance of DateValuePeriod type.

Parameters
dateDateValuePeriod

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitFrom(date)[source]

Visit an instance of DateValueFrom type.

Parameters
dateDateValueFrom

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitTo(date)[source]

Visit an instance of DateValueTo type.

Parameters
dateDateValueTo

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitRange(date)[source]

Visit an instance of DateValueRange type.

Parameters
dateDateValueRange

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitBefore(date)[source]

Visit an instance of DateValueBefore type.

Parameters
dateDateValueBefore

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitAfter(date)[source]

Visit an instance of DateValueAfter type.

Parameters
dateDateValueAfter

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitAbout(date)[source]

Visit an instance of DateValueAbout type.

Parameters
dateDateValueAbout

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitCalculated(date)[source]

Visit an instance of DateValueCalculated type.

Parameters
dateDateValueCalculated

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitEstimated(date)[source]

Visit an instance of DateValueEstimated type.

Parameters
dateDateValueEstimated

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitInterpreted(date)[source]

Visit an instance of DateValueInterpreted type.

Parameters
dateDateValueInterpreted

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

visitPhrase(date)[source]

Visit an instance of DateValuePhrase type.

Parameters
dateDateValuePhrase

Date value instance.

Returns
valueobject

Implementation of this method can return anything, value will be returned from DateValue.accept() method.

_abc_impl = <_abc_data object>
class ged2doc.i18n.I18N(lang, datefmt=None, domain='ged2doc')[source]

Bases: object

Class with methods responsible for various aspects of translations.

Parameters
langstr

Output language such as “en”, “ru”.

datefmtstr, optional

Printable date format.

domainstr, optional

gettext domain (message file name).

Methods

tr(text[, gender])

Translates given text, takes into account gender.

tr_date(date)

Produce language-specific date representation.

tr(text, gender=None)[source]

Translates given text, takes into account gender.

Parameters
textstr

Text to translate.

genderstr, optional

One of ‘F’, ‘M’, ‘U’, or None.

Returns
textstr

Translated text.

tr_date(date)[source]

Produce language-specific date representation.

Parameters
dateged4py.date.DateValue
Returns
text_datestr

String representation of a date.

_tr_cal_date(date)[source]

Produce language-specific calendar date representation.

Uses date format provided in constructor, month name is translated into a destination language.

Parameters
dateged4py.date.CalendarDate
Returns
text_datestr

String representation of a date.

_monthName(month)[source]

Returns translation of a month name.

For a given GEDCOM month name return translated month name.

Parameters
monthstr

Month name in GEDCOM format.

Returns
monthstr

Name of this month in destination language.