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
|
This is no-op function, only used to mark translatable strings, to extract all strings run |
Classes
|
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:
objectSpecial fallback class for gettext which returns None for missing translations.
Methods
gettext
ugettext
-
class
ged2doc.i18n._TemplateDateVisitor[source]¶ Bases:
ged4py.date.DateValueVisitorVisitor class that builds template strings and keywords from dates.
Methods
visitAbout(date)Visit an instance of
DateValueAbouttype.visitAfter(date)Visit an instance of
DateValueAftertype.visitBefore(date)Visit an instance of
DateValueBeforetype.visitCalculated(date)Visit an instance of
DateValueCalculatedtype.visitEstimated(date)Visit an instance of
DateValueEstimatedtype.visitFrom(date)Visit an instance of
DateValueFromtype.visitInterpreted(date)Visit an instance of
DateValueInterpretedtype.visitPeriod(date)Visit an instance of
DateValuePeriodtype.visitPhrase(date)Visit an instance of
DateValuePhrasetype.visitRange(date)Visit an instance of
DateValueRangetype.visitSimple(date)Visit an instance of
DateValueSimpletype.visitTo(date)Visit an instance of
DateValueTotype.-
visitSimple(date)[source]¶ Visit an instance of
DateValueSimpletype.- Parameters
- date
DateValueSimple Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitPeriod(date)[source]¶ Visit an instance of
DateValuePeriodtype.- Parameters
- date
DateValuePeriod Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitFrom(date)[source]¶ Visit an instance of
DateValueFromtype.- Parameters
- date
DateValueFrom Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitTo(date)[source]¶ Visit an instance of
DateValueTotype.- Parameters
- date
DateValueTo Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitRange(date)[source]¶ Visit an instance of
DateValueRangetype.- Parameters
- date
DateValueRange Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitBefore(date)[source]¶ Visit an instance of
DateValueBeforetype.- Parameters
- date
DateValueBefore Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitAfter(date)[source]¶ Visit an instance of
DateValueAftertype.- Parameters
- date
DateValueAfter Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitAbout(date)[source]¶ Visit an instance of
DateValueAbouttype.- Parameters
- date
DateValueAbout Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitCalculated(date)[source]¶ Visit an instance of
DateValueCalculatedtype.- Parameters
- date
DateValueCalculated Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitEstimated(date)[source]¶ Visit an instance of
DateValueEstimatedtype.- Parameters
- date
DateValueEstimated Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitInterpreted(date)[source]¶ Visit an instance of
DateValueInterpretedtype.- Parameters
- date
DateValueInterpreted Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
visitPhrase(date)[source]¶ Visit an instance of
DateValuePhrasetype.- Parameters
- date
DateValuePhrase Date value instance.
- date
- Returns
- value
object Implementation of this method can return anything, value will be returned from
DateValue.accept()method.
- value
-
_abc_impl= <_abc_data object>¶
-
-
class
ged2doc.i18n.I18N(lang, datefmt=None, domain='ged2doc')[source]¶ Bases:
objectClass with methods responsible for various aspects of translations.
- Parameters
- lang
str Output language such as “en”, “ru”.
- datefmt
str, optional Printable date format.
- domain
str, optional gettextdomain (message file name).
- lang
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
- text
str Text to translate.
- gender
str, optional One of ‘F’, ‘M’, ‘U’, or
None.
- text
- Returns
- text
str Translated text.
- text
-
tr_date(date)[source]¶ Produce language-specific date representation.
- Parameters
- date
ged4py.date.DateValue
- date
- Returns
- text_date
str String representation of a date.
- text_date