cadrumo.core.i18n._lazy_catalogue module

On-demand lazy-loading locale catalogue with smart dot-notation shard resolution.

Provides LazyLocaleCatalogue, an immutable Mapping that loads only the requested YAML shard files on demand, memoizing parsed values in memory.

load_yaml_handle(handle)[source]

Load YAML content with libyaml’s safe loader.

Return type:

object

Parameters:

handle (IO[str])

class LazyLocaleCatalogue(locale, *, shard_dir=None)[source]

Bases: Mapping[str, str | None]

An on-demand, lazy-loading locale catalogue mapping.

Resolves translation keys on demand by mapping dot-notation keys to specific domain/Modelo YAML shards. When a key is requested, only the owning shard file is read and parsed into the in-memory cache.

Parameters:
  • locale (str)

  • shard_dir (Path | None)

to_dict()[source]

Return a complete flattened dictionary of all translation keys.

Return type:

dict[str, str | None]