localization
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| NoBabelExtension jinjarope.localization |
🛈 DocStrings¶
install_translations
¶
install_translations(
env: Environment, locale: str | Locale, dirs: Sequence[str | PathLike[str]]
) -> None
Install translations for the given locale in the Jinja environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
Environment
|
The Jinja2 environment to install translations into. |
required |
locale
|
str | Locale
|
The target locale. |
required |
dirs
|
Sequence[str | PathLike[str]]
|
Sequence of directory paths to search for translations. Directories listed first |
required |
Source code in src/jinjarope/localization.py
parse_locale
¶
Parse a locale string into a Locale object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locale
|
str
|
The locale string to parse (e.g., 'en_US'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Locale |
Locale
|
The parsed Babel Locale object. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the locale string is invalid. |