The translation module is accessible via the pylons.i18n module.
Provides gettext translation functions via an app's pylons.translator and get/set_lang for changing the language translated to.
Mark a string for translation without translating it. Returns value.
Used for global strings, e.g.:
1 2 3 4 5 6 7 8 9 10 11 | foo = N_('Hello') class Bar: def __init__(self): self.local_foo = _(foo) h.set_lang('fr') assert Bar().local_foo == 'Bonjour' h.set_lang('es') assert Bar().local_foo == 'Hola' assert foo == 'Hello' |
Mark a string for translation. Returns the localized unicode string of value.
Mark a string to be localized as follows:
1 | _('This should be in lots of languages') |
Add a fallback language from which words not matched in other languages will be translated to.
Mark a string for translation. Returns the localized string of value.
Mark a string to be localized as follows:
1 | gettext('This should be in lots of languages') |
Mark a string for translation without translating it. Returns value.
Used for global strings, e.g.:
1 2 3 4 5 6 7 8 9 10 11 | foo = N_('Hello') class Bar: def __init__(self): self.local_foo = _(foo) h.set_lang('fr') assert Bar().local_foo == 'Bonjour' h.set_lang('es') assert Bar().local_foo == 'Hola' assert foo == 'Hello' |
Lazy-evaluated version of the gettext function
Mark a string for translation. Returns the localized string of value.
Mark a string to be localized as follows:
1 gettext('This should be in lots of languages')
Lazy-evaluated version of the ngettext function
pluralized value.
This does a plural-forms lookup of a message id. singular is used as the message id for purposes of lookup in the catalog, while n is used to determine which plural form to use. The returned message is a string.
Mark a string to be localized as follows:
1 2 | ngettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n} |
Lazy-evaluated version of the ugettext function
value.
Mark a string to be localized as follows:
1 | _('This should be in lots of languages') |
Lazy-evaluated version of the ungettext function
the pluralized value.
This does a plural-forms lookup of a message id. singular is used as the message id for purposes of lookup in the catalog, while n is used to determine which plural form to use. The returned message is a Unicode string.
Mark a string to be localized as follows:
1 2 | ungettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n} |
Mark a string for translation. Returns the localized string of the pluralized value.
This does a plural-forms lookup of a message id. singular is used as the message id for purposes of lookup in the catalog, while n is used to determine which plural form to use. The returned message is a string.
Mark a string to be localized as follows:
1 2 | ngettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n} |
Mark a string for translation. Returns the localized unicode string of value.
Mark a string to be localized as follows:
1 | _('This should be in lots of languages') |
Mark a string for translation. Returns the localized unicode string of the pluralized value.
This does a plural-forms lookup of a message id. singular is used as the message id for purposes of lookup in the catalog, while n is used to determine which plural form to use. The returned message is a Unicode string.
Mark a string to be localized as follows:
1 2 | ungettext('There is %(num)d file here', 'There are %(num)d files here', n) % {'num': n} |
Exception raised when a problem occurs with changing languages
This class contains 2 members.
See the source for more information.