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_languagefact; never reads storage.
- 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.
- active_profile_output_language_from_storage()[source]¶
Read the active profile’s
preferences.output_languagefact from storage.Performs a pure read of workflow state — no mutation, no bucket events — and returns
Nonewhen 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.
- resolve_active_profile_output_language_hint()[source]¶
Return the active bucket’s last-known output-language hint, if present.
- resolve_profile_output_language_hint(bucket_id)[source]¶
Return a named bucket’s last-known output-language hint, if present.
- register_language_resolver()[source]¶
Register
resolve_active_profile_output_language()withcore.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:
- 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 returnedNoneand 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
logoutclears 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:
- Parameters:
bucket_id (str)
language (OutputLanguage | None)