core.i18n

Module Contents

Classes

LanguageWrapper

Wrapper-class for a multi-language value.

translate

TranslationExtension

Default translation extension for jinja2 render.

Functions

initializeTranslations()

localizedStrfTime(datetimeObj: datetime.datetime, format: str) → str

Provides correct localized names for directives like %a which dont get translated on GAE properly as we can’t

core.i18n.systemTranslations
class core.i18n.LanguageWrapper(languages)

Bases: dict

Wrapper-class for a multi-language value. Its a dictionary, allowing accessing each stored language, but can also be used as a string, in which case it tries to guess the correct language.

__str__(self)

Return str(self).

resolve(self)

Causes this wrapper to evaluate to the best language available for the current request.

Returns

str|list of str

Return type

str|list of str

class core.i18n.translate(key, defaultText=None, hint=None)
__slots__ = ['key', 'defaultText', 'hint', 'translationCache']
__repr__(self)

Return repr(self).

__str__(self)

Return str(self).

translate(self, **kwargs)
class core.i18n.TranslationExtension(environment)

Bases: jinja2.ext.Extension

Default translation extension for jinja2 render. Use like {% translate “translationKey”, “defaultText”, “translationHint”, replaceValue1=”replacedText1” %} All except translationKey is optional. translationKey is the same Key supplied to _() before. defaultText will be printed if no translation is available. translationHint is a optional hint for anyone adding a now translation how/where that translation is used.

tags
parse(self, parser)

If any of the tags matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.

_translate(self, key, defaultText, hint, kwargs, trDict, caller)
core.i18n.initializeTranslations()
core.i18n.localizedDateTime
core.i18n.localizedDate
core.i18n.localizedTime
core.i18n.localizedAbbrevDayNames
core.i18n.localizedDayNames
core.i18n.localizedAbbrevMonthNames
core.i18n.localizedMonthNames
core.i18n.localizedStrfTime(datetimeObj: datetime.datetime, format: str)str

Provides correct localized names for directives like %a which dont get translated on GAE properly as we can’t set the locale (for each request). This currently replaces %a, %A, %b, %B, %c, %x and %X.

Parameters
  • datetimeObj – Datetime-instance to call strftime on

  • format – String containing the Format to apply.

Returns

Date and time formatted according to format with correct localization