DialectoInContext.Store (dialecto_in_context v0.1.0)

Copy Markdown View Source

The dev server's in-context state, in a protected ETS table this process owns: whether marking is on (spec-0017 §1.3) and the saved drafts the overlay sent (§1.2). Every gettext lookup reads it, so reads go straight to ETS; writes are serialized through the process.

Marking lasts marking_ttl_ms/0 after the last set_marking(true) — the overlay heartbeats while the editor is open, so a closed tab or a crashed overlay can't leave markers on for good.

Summary

Types

A saved draft: one text, or one text per plural form.

Functions

Returns a specification to start this module under a supervisor.

True while marking is on.

How long marking stays on after the overlay last asked for it.

The draft for {domain, key, locale}, or nil.

Replaces every draft with edits ({domain, key, locale, override} tuples) — the overlay always sends the full set, so an empty list restores the catalogs. Unchanged drafts never disappear mid-swap.

Turns marking on (for ttl_ms, default marking_ttl_ms/0) or off.

{marking?, any_overrides?} — the lookup's fast path reads only this.

Types

override()

@type override() :: %{optional(:to) => String.t(), optional(:forms) => [String.t()]}

A saved draft: one text, or one text per plural form.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

marking?()

@spec marking?() :: boolean()

True while marking is on.

marking_ttl_ms()

@spec marking_ttl_ms() :: pos_integer()

How long marking stays on after the overlay last asked for it.

override(domain, key, locale)

@spec override(String.t(), String.t(), String.t()) :: override() | nil

The draft for {domain, key, locale}, or nil.

replace_overrides(edits)

@spec replace_overrides([{String.t(), String.t(), String.t(), override()}]) :: :ok

Replaces every draft with edits ({domain, key, locale, override} tuples) — the overlay always sends the full set, so an empty list restores the catalogs. Unchanged drafts never disappear mid-swap.

set_marking(on?, ttl_ms \\ 90000)

@spec set_marking(boolean(), non_neg_integer()) :: boolean()

Turns marking on (for ttl_ms, default marking_ttl_ms/0) or off.

state()

@spec state() :: {boolean(), boolean()}

{marking?, any_overrides?} — the lookup's fast path reads only this.