Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Functions | Variables
babel.messages.checkers Namespace Reference

Functions

None num_plurals (Catalog|None catalog, Message message)
 
None python_format (Catalog|None catalog, Message message)
 
None _validate_format (str format, str alternative)
 
list[Callable[[Catalog|None, Message], object]] _find_checkers ()
 

Variables

list _string_format_compatibilities
 
list checkers = _find_checkers()
 

Detailed Description

    babel.messages.checkers
    ~~~~~~~~~~~~~~~~~~~~~~~

    Various routines that help with validation of translations.

    :since: version 0.9

    :copyright: (c) 2013-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.

Function Documentation

◆ _validate_format()

None babel.messages.checkers._validate_format ( str  format,
str  alternative 
)
protected
Test format string `alternative` against `format`.  `format` can be the
msgid of a message and `alternative` one of the `msgstr`\\s.  The two
arguments are not interchangeable as `alternative` may contain less
placeholders if `format` uses named placeholders.

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.

:param format: The original format string
:param alternative: The alternative format string that should be checked
                    against format
:raises TranslationError: on formatting errors

◆ num_plurals()

None babel.messages.checkers.num_plurals ( Catalog | None  catalog,
Message  message 
)
Verify the number of plurals in the translation.

◆ python_format()

None babel.messages.checkers.python_format ( Catalog | None  catalog,
Message  message 
)
Verify the format string placeholders in the translation.

Variable Documentation

◆ _string_format_compatibilities

list babel.messages.checkers._string_format_compatibilities
protected
Initial value:
1= [
2 {'i', 'd', 'u'},
3 {'x', 'X'},
4 {'f', 'F', 'g', 'G'},
5]