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:
object
Special fallback class for gettext which returns None for missing translations.
Methods
gettext
ugettext
-
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
- 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
DateValuePeriod
type.- 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
DateValueFrom
type.- 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
DateValueTo
type.- 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
DateValueRange
type.- 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
DateValueBefore
type.- 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
DateValueAfter
type.- 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
DateValueAbout
type.- 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
DateValueCalculated
type.- 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
DateValueEstimated
type.- 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
DateValueInterpreted
type.- 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
DateValuePhrase
type.- 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:
object
Class 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 gettext
domain (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