PyDrocsid.translations
¶
Translations
¶
Container of multiple translation namespaces
Source code in PyDrocsid/translations.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
__getattr__ ¶
__getattr__(item: str) -> Any
Return a translation namespace
Source code in PyDrocsid/translations.py
170 171 172 173 |
|
register_namespace ¶
register_namespace(name: str, path: Path, prio: int = 0) -> None
Register a new source for a translation namespace.
Source code in PyDrocsid/translations.py
158 159 160 161 162 163 164 165 166 167 168 |
|
_FormatString
¶
Bases: str
String which can be called directly for formatting
Source code in PyDrocsid/translations.py
31 32 33 34 |
|
_Namespace
¶
Translation namespace containing translations for main and fallback language
Source code in PyDrocsid/translations.py
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
__getattr__ ¶
__getattr__(item: str) -> Any
Return an item and wrap it in a _FormatString or _PluralDict
Source code in PyDrocsid/translations.py
135 136 137 138 139 140 141 142 143 144 145 146 |
|
_add_source ¶
_add_source(prio: int, source: Path) -> None
Add a new translation source.
Parameters:
-
prio
(
int
) –priority of translation source (higher priority overrides lower priority)
-
source
(
Path
) –path to the directory containing the translation files
Source code in PyDrocsid/translations.py
97 98 99 100 101 102 103 104 105 106 |
|
_get_language ¶
_get_language(lang: str) -> dict[str, Any]
Return (and load if necessary) the translation dictionary of a given language.
Source code in PyDrocsid/translations.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
_get_translation ¶
_get_translation(key: str) -> Any
Return an item from the translation dictionary.
Source code in PyDrocsid/translations.py
125 126 127 128 129 130 131 132 133 |
|
_PluralDict
¶
Dictionary for pluralization containing multiple _FormatStrings
Source code in PyDrocsid/translations.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
__call__ ¶
__call__(*args: Any, **kwargs: Any) -> str
Choose and format the pluralized string.
Source code in PyDrocsid/translations.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
__getattr__ ¶
__getattr__(item: str) -> Any
Return a nested item and wrap it in a _FormatString or _PluralDict
Source code in PyDrocsid/translations.py
70 71 72 73 74 75 76 77 78 79 80 81 |
|
__getattribute__ ¶
__getattribute__(item: str) -> Any
Use getattr for non-protected attributes.
Source code in PyDrocsid/translations.py
63 64 65 66 67 68 |
|
load_translations ¶
load_translations(path: Path, prio: int = 0) -> None
Recursively load all translations in a given directory and register the appropriate namespaces.
Source code in PyDrocsid/translations.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
merge ¶
merge(base: dict[Any, Any], src: dict[Any, Any]) -> None
Merge two dictionaries recursively by copying/merging the key-value pairs from src into base.
Parameters:
-
base
(
dict[Any, Any]
) –the base dictionary
-
src
(
dict[Any, Any]
) –the source dictionary to read from
Source code in PyDrocsid/translations.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|