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
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
parse_locale
¶
parse_locale(locale: str) -> 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. |
Source code in src/jinjarope/localization.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|