THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
Define the contract for the translation service.
The translator resolves lines for the active locale, falls back to the configured fallback locale, applies parameter replacement, and selects pluralized segments.
| Method | available |
Return every locale with at least one translation source. |
| Method | choice |
Retrieve a pluralized translation line based on count. |
| Method | flush |
Discard every cached translation map. |
| Method | forget |
Discard the cached translations for a single locale. |
| Method | get |
Retrieve the translation line registered under key. |
| Method | get |
Return the active locale. |
| Method | has |
Determine whether a translation exists for key. |
| Method | missing |
Register a handler invoked when a translation key is missing. |
| Method | reload |
Discard cached translations so they are re-read from disk. |
| Method | set |
Change the active locale at runtime. |
| Class Variable | __slots__ |
Undocumented |
str, count: int, locale: str | None = None, **replace: object) -> str:
(source)
¶
orionis.localization.TranslatorRetrieve a pluralized translation line based on count.
Segments are separated by | and may declare explicit conditions such as {0}, {1} or ranges [2,*]. When no explicit condition matches, the first segment is used for a count of one and the second segment otherwise. The :count placeholder is always available in the selected segment.
| Parameters | |
key:str | Translation key containing the pluralized segments. |
count:int | Quantity used to select the proper segment. The value is used as received: explicit conditions compare it against their numeric bounds and the positional rule tests count == 1. No coercion or validation is applied. |
locale:str | None, optional | Locale to translate into, or None for the active locale. |
**replace:object | Placeholder values substituted into the selected segment. |
| Returns | |
str | Pluralized and interpolated translation line. |
| Raises | |
InvalidLocaleException | If an explicit locale is malformed. |
orionis.localization.TranslatorDiscard every cached translation map.
| Returns | |
None | Undocumented |
str, locale: str | None = None, **replace: object) -> str:
(source)
¶
orionis.localization.TranslatorRetrieve the translation line registered under key.
The lookup order is the requested locale first, then the fallback locale, and finally the key itself when no translation exists. Placeholders in the :name form are substituted with the values provided in replace.
| Parameters | |
key:str | Translation key, either a literal source text or a dot-notated grouped key such as validation.required. |
locale:str | None, optional | Locale to translate into, or None for the active locale. |
**replace:object | Placeholder values substituted into the resolved line. |
| Returns | |
str | Translated line, or the key itself when missing. |
| Raises | |
InvalidLocaleException | If an explicit locale is malformed. |
orionis.localization.TranslatorReturn the active locale.
| Returns | |
str | Locale code currently in use. |
str, locale: str | None = None, *, fallback: bool = True) -> bool:
(source)
¶
orionis.localization.TranslatorDetermine whether a translation exists for key.
| Parameters | |
key:str | Translation key to check. |
locale:str | None, optional | Locale to inspect, or None for the active locale. |
fallback:bool, optional | Whether the fallback locale is also inspected. |
| Returns | |
bool | True when a translation line is registered for the key. |
| Raises | |
InvalidLocaleException | If an explicit locale is malformed. |
orionis.localization.TranslatorRegister a handler invoked when a translation key is missing.
The handler receives the key and the locale, and may return a replacement line. When it returns None the key itself is used as the translation.
| Parameters | |
handler:MissingKeyHandler | None | Callable invoked on missing keys, or None to remove the current handler. |
| Returns | |
None | Undocumented |
orionis.localization.TranslatorDiscard cached translations so they are re-read from disk.
| Parameters | |
locale:str | None, optional | Locale to reload, or None to reload every locale. |
| Returns | |
None | Undocumented |
| Raises | |
InvalidLocaleException | If an explicit locale is malformed. |