cadrumo.application.user_profile.language_resolver module

Resolve the active profile’s preferred output language for core.i18n.

The core layer remains independent of application modules. It resolves the active profile’s preferences.output_language preference through a registered callback. Each executable host explicitly calls register_language_resolver() when it composes profile persistence. That function registers resolve_active_profile_output_language() with cadrumo.core.i18n.render.register_profile_language_resolver().

Rendering never reads storage. The profile’s language is read once into a process-wide snapshot by refresh_active_profile_output_language() – when the host composes, and whenever a session is bound, closed, or the preference is written – and the registered callback only returns that snapshot. A frontend event loop that renders text therefore never waits on the encrypted profile.

resolve_active_profile_output_language()[source]

Return the snapshotted preferences.output_language fact; never reads storage.

Return type:

str | None

refresh_active_profile_output_language()[source]

Re-read the active profile’s language into the snapshot and invalidate rendering.

Called where storage is already being touched: host composition, session binding and closing, and the preference write. Never raises; an unreadable profile leaves no profile language, so rendering falls back to settings.

Return type:

str | None

active_profile_output_language_from_storage()[source]

Read the active profile’s preferences.output_language fact from storage.

Performs a pure read of workflow state — no mutation, no bucket events — and returns None when there is no active profile or no language fact, so the caller falls back to the settings default. When no bucket session is currently bound, reads the bucket-local non-secret language hint instead of the encrypted profile envelope.

Return type:

str | None

resolve_active_profile_output_language_hint()[source]

Return the active bucket’s last-known output-language hint, if present.

Return type:

str | None

resolve_profile_output_language_hint(bucket_id)[source]

Return a named bucket’s last-known output-language hint, if present.

Return type:

str | None

Parameters:

bucket_id (str)

register_language_resolver()[source]

Register resolve_active_profile_output_language() with core.i18n.

Executable hosts invoke this alongside custody and login-session composition, keeping registration explicit and greppable rather than hiding it in a package-import side effect.

Return type:

None

mirror_profile_output_language_hint(bucket_id, language)[source]

Mirror a profile’s language preference into its non-secret bucket hint.

The hint answers one question the encrypted preference cannot: which language to speak for a SELECTED profile that is not unlocked. resolve_active_profile_output_language() falls back to it when no bucket session is bound, and the reader fails soft on absence – so while nothing wrote the hint, that fallback always returned None and every locked surface silently took the settings default, however deliberately the operator had chosen a language during setup.

It is keyed by bucket, so it serves a locked selection and NOT a logged-out one: once logout clears the pointer there is no bucket to resolve the hint against, and the settings default is the only answer available. That is a property of the selection model, not a gap in the mirror.

Clearing the preference clears the hint, so the two cannot disagree about an absence. Failure is swallowed for the same reason the read is: this mirrors a convenience, and a hint that could not be written must not fail the fact write that owns the real value.

Return type:

None

Parameters: