Classes
I18nParsingMixin
3
▼
Mixin for parsing {% trans %}...{% endtrans %} blocks.
Host attributes and cross-mixin dependencie…
I18nParsingMixin
3
▼
Mixin for parsing {% trans %}...{% endtrans %} blocks.
Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks.
Methods
Internal Methods 3 ▼
_parse_trans
0
Trans
▼
Parse {% trans [var=expr, ...] %}...{% endtrans %}.
Syntax:
{% trans %}lit…
_parse_trans
0
Trans
▼
def _parse_trans(self) -> Trans
Parse {% trans [var=expr, ...] %}...{% endtrans %}.
Syntax:
{% trans %}literal body{% endtrans %}
{% trans name=expr %}Hello, {{ name }}!{% endtrans %}
{% trans count=expr %}One item.{% plural %}{{ count }} items.{% endtrans %}
Body restrictions:
- Only {{ name }} references allowed (simple names)
- No filters, attribute access, or method calls
- All referenced names must be declared in the {% trans %} tag
Returns
Trans
_parse_trans_body
1
tuple[list[str], list[st…
▼
Parse trans block body, returning singular parts, plural parts, and has_plural …
_parse_trans_body
1
tuple[list[str], list[st…
▼
def _parse_trans_body(self, declared_names: set[str]) -> tuple[list[str], list[str], bool]
Parse trans block body, returning singular parts, plural parts, and has_plural flag.
Parameters
| Name | Type | Description |
|---|---|---|
declared_names |
— |
Returns
tuple[list[str], list[str], bool]
_normalize_message
1
str
▼
Normalize whitespace in a message ID.
Strips leading/trailing whitespace and c…
staticmethod
_normalize_message
1
str
▼
def _normalize_message(msg: str) -> str
Normalize whitespace in a message ID.
Strips leading/trailing whitespace and collapses internal whitespace to single spaces. This ensures consistent message IDs regardless of template formatting.
Parameters
| Name | Type | Description |
|---|---|---|
msg |
— |
Returns
str