Skip to content

Types

Represents a language and its weight from the Accept-Language header.

Parameters:

Name Type Description Default
language str

The language code (e.g., "en-US", "fr").

required
weight float

The weight (priority) of the language, default is 1.0.

1.0
Source code in fastapi_l10n/types.py
@dataclass(frozen=True)
class LanguagePreference:
    """
    Represents a language and its weight from the `Accept-Language` header.

    :param language: The language code (e.g., "en-US", "fr").
    :param weight: The weight (priority) of the language, default is 1.0.
    """

    language: str
    weight: float = 1.0