module documentation

Various routines that help with validation of translations.

Present Since
version 0.9
Unknown Field: copyright
  1. 2013-2021 by the Babel Team.
Unknown Field: license
BSD, see LICENSE for more details.
Variable checkers Undocumented
Function ​_find​_checkers Undocumented
Function ​_validate​_format No summary
Function num​_plurals Verify the number of plurals in the translation.
Function python​_format Verify the format string placeholders in the translation.
Variable ​_string​_format​_compatibilities Undocumented
checkers =

Undocumented

def _find_checkers():

Undocumented

def _validate_format(format, alternative):

Test format string alternative against format. format can be the msgid of a message and alternative one of the msgstrs. The two arguments are not interchangeable as alternative may contain less placeholders if format uses named placeholders.

The behavior of this function is undefined if the string does not use string formattings.

If the string formatting of alternative is compatible to format the function returns None, otherwise a TranslationError is raised.

Examples for compatible format strings:

>>> _validate_format('Hello %s!', 'Hallo %s!')
>>> _validate_format('Hello %i!', 'Hallo %d!')

Example for an incompatible format strings:

>>> _validate_format('Hello %(name)s!', 'Hallo %s!')
Traceback (most recent call last):
  ...
TranslationError: the format strings are of different kinds

This function is used by the python_format checker.

Parameters
formatThe original format string
alternativeThe alternative format string that should be checked against format
Raises
TranslationErroron formatting errors
def num_plurals(catalog, message):
Verify the number of plurals in the translation.
def python_format(catalog, message):
Verify the format string placeholders in the translation.
_string_format_compatibilities: list =

Undocumented