ORIONIS API REFERENCE

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 documentation

class ITranslationLoader(ABC): (source)

Known subclasses: orionis.localization.TranslationLoader

View In Hierarchy

Define the contract for translation file loaders.

A loader reads translation sources from disk and produces a flat translation map per locale. It knows nothing about caching, locale resolution, or template engines: its single responsibility is loading translations.

Method availableLocales Discover every locale with at least one translation source.
Method load Load every translation available for locale.
Class Variable __slots__ Undocumented
@abstractmethod
def availableLocales(self) -> tuple[str, ...]: (source)

Discover every locale with at least one translation source.

Returns
tuple[str, ...]Sorted locale codes discovered from root JSON files and grouped directories inside the language path.
@abstractmethod
def load(self, locale: str) -> TranslationMap: (source)

Load every translation available for locale.

Merges the grouped files located under {path}/{locale}/*.json (flattened with dot notation, e.g. validation.required) with the root JSON file {path}/{locale}.json whose keys are the literal source texts. Root JSON entries take precedence over grouped entries on key collision.

Parameters
locale:strLocale code whose translation sources must be read.
Returns
TranslationMapFlat mapping of translation key to translated text. An empty mapping is returned when no source exists.
Raises
TranslationSyntaxExceptionIf a translation file is not UTF-8 encoded, contains invalid JSON, or its root element is not an object.