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.
class TranslationRepository(ITranslationRepository): (source)
Constructor: TranslationRepository(loader, max_locales, negative_ttl)
In-memory cache of translation maps keyed by locale.
Recently used locales are retained within a configurable capacity. Missing locales expire so newly created translation files can be found.
Notes
A reentrant lock protects cache and loader access across threads.
orionis.localization.TranslationRepository.get returns the cached mapping
itself, not a copy.
| Method | __init__ |
Initialize the repository with its translation loader. |
| Method | flush |
Discard every cached translation map. |
| Method | forget |
Discard the cached translations for locale. |
| Method | get |
Return the translation map for locale, loading it on demand. |
| Method | has |
Determine whether locale is already cached in memory. |
| Method | loaded |
Return the locales currently held in the cache. |
| Class Variable | __slots__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | _cache |
Cache policy or cached state used by this component. |
| Instance Variable | _expires |
Expiration deadline for the cached or protected value. |
| Instance Variable | _limit |
Maximum retained locales, including empty results. |
| Instance Variable | _loader |
Loader used to read translation sources on cache misses. |
| Instance Variable | _lock |
Lock protecting concurrent access to shared state. |
| Instance Variable | _negative |
Seconds to retain an empty result before retrying the loader. |
Self, loader: ITranslationLoader, *, max_locales: int = 256, negative_ttl: float = 30):
(source)
¶
Initialize the repository with its translation loader.
| Parameters | |
loader:orionis.localization.contracts.ITranslationLoader | Loader used to read translation sources on cache misses. |
maxint | Maximum retained locales, including empty results. |
negativefloat | Seconds to retain an empty result before retrying the loader. |
| Returns | |
None | No return value. |
| Raises | |
ValueError | If the capacity is not a positive integer or the negative-cache lifetime is nonfinite or negative. |
TypeError | If the negative-cache lifetime is not numeric. |
Return the translation map for locale, loading it on demand.
| Parameters | |
locale:str | Locale code whose translations are requested. |
| Returns | |
orionis.localization.types.TranslationMap | Cached translation map for the locale. The mapping is the cached instance, not a copy. |
| Raises | |
orionis.localization.TranslationSyntaxException | If a translation file contains invalid JSON. |