Skip to main content

Crate trox

Crate trox 

Source
Expand description

Locale-independent message values and deterministic bundle resolution.

Trox separates authoring a message from rendering it. Authoring functions never consult global locale state: they build immutable LocalizedString values containing a stable identity and typed arguments. An explicit Localizer later resolves those values either directly in source-development mode or against validated source and target Bundles in production.

Most application code can import prelude and use tx for static text or txa with tx_args! for interpolation and selection:

use trox::prelude::*;

let message = tx("Close deck browser", "Accessible button label.");
assert!(message.entry_id().starts_with("tx1_"));

let deck_name = String::from("Night Garden");
let heading = txa(
    "Deck: {deck_name}",
    tx_args![deck_name],
    "Heading for the currently open deck.",
);
assert!(!heading.is_atomic());

let localizer = Localizer::for_source(SourceLocale::new("en-US")?)?;
assert_eq!(localizer.resolve(&message), "Close deck browser");

Serialized localized values should be decoded through a SourceCatalog or Localizer, which checks canonical encoding and source-catalog authorization. Use Localizer::resolve_checked when resolution failures must remain explicit, or Localizer::resolve for source-language recovery.

Modules§

prelude
Common types, authoring functions, and macros for application code.

Macros§

tx_args
Build an owned argument map while evaluating every expression exactly once.

Structs§

AnnotatedLocalizedString
A lazy localized value paired with application-owned placeholder metadata.
Bundle
Validated runtime artifact for one locale.
BundleEntry
One message family in a bundle.
BundleRow
One translated expansion row.
BundleTerm
Runtime facets and forms for one stable term ID.
BundleTermSurface
One localized surface of a numbered term form.
Diagnostic
Structured event emitted when normal resolution performs recovery.
ExpansionDescriptor
Canonical data hashed to produce a row ID.
IdentityDescriptor
Locale-independent fields used to derive a message’s stable identity.
LocalizedString
Immutable source-authored localized value awaiting explicit resolution.
Localizer
Resolves immutable localized values through source configuration or a bundle pair.
NumberFormat
Pinned locale data used by Trox’s deterministic decimal formatter.
NumericBranch
One branch of a cardinal or ordinal numeric selector.
PatternValue
A fully owned pattern under construction.
PluralRules
CLDR cardinal and ordinal conditions keyed by resulting category.
ResolveOutcome
Rendered text plus whether the whole message used its source fallback.
ResolvedLocalizedPartsOutcome
Structured resolution plus whether the complete message used source fallback.
RonTx
The checked payload of RON’s Tx(text: ..., ...) authoring variant.
SelectArm
One source-authored branch of a semantic selector.
SourceCatalog
The validated message identities and term schemas authorized by a source bundle.
SourceLocale
Human-authored configuration for bundle-free source-language resolution.
SourceMessage
Immutable, catalog-authorized source message awaiting argument binding.
SourceMessageRef
Canonical, argument-free reference to a source-catalog message contract.
TermArgument
Reference to a term, optionally specifying a form and count.
TermId
Validated, stable identifier for an application term.
TroxInteger
Non-negative safe integer accepted by selectors and numbered terms.
TroxNumber
Finite floating-point scalar accepted by the Trox wire model.
TroxValueError
A violation of the invariants for a Trox value.
Version
Major and minor version of a Trox wire value.

Enums§

Argument
Runtime value bound to a named placeholder.
ArgumentKind
Coarse placeholder category used to compare source and translated rows.
ArgumentSchema
Source-authored contract for one visible placeholder binding.
BundleTermForm
A scalar or cardinally inflected term form.
DeserializeError
An error produced while decoding or validating Trox wire data.
DiagnosticCode
Stable machine-readable categories emitted by runtime recovery.
IsolationPolicy
Controls bidirectional isolation around interpolated placeholder surfaces.
NumericBranchKey
Identity-bearing key for a numeric selector branch.
Pattern
Locale-independent source pattern for a message.
PluralCategory
CLDR plural category used by cardinal and ordinal patterns.
ResolveError
An error produced by strict localization resolution.
ResolvedLocalizedPart
One display-ready run produced from a localized message.
RonPlaceholder
Declared runtime value category for a placeholder in a RON Tx template.
SelectIdentityBranch
Identity-bearing branch of a stable semantic selector.
SelectorKey
Runtime key used to select a semantic branch.
SelectorRecord
Runtime selector input paired with its path in the identity pattern.
SerializeError
An error produced while encoding a Trox value or bundle.
TextDirection
Base direction of a locale’s surrounding text.

Constants§

CLDR_VERSION
The CLDR release pinned into Trox’s source and bundle runtimes.

Traits§

TroxSelector
Stable semantic selector contract. Applications explicitly map variants to stable keys. Boolean implements this trait with JSON boolean keys.

Functions§

contract_signature
Computes the v1.1 compatibility signature for an identity and argument schema.
counted
Creates a counted numbered-form term argument.
exact
Creates an exact-value branch for a numeric selector.
expansion_row_id
Derives the canonical short row ID for an expansion descriptor.
few
Creates a few category branch for a numeric selector.
identity_ids
Derives the canonical short entry ID and full source signature for an identity.
indefinite
Creates an indefinite scalar-form term argument.
ls
Asserts that runtime text is appropriate to display without translation.
many
Creates a many category branch for a numeric selector.
meaning
Assigns a stable semantic meaning to a complete message pattern.
one
Creates a one category branch for a numeric selector.
opaque
Wraps an atomic localized value as an opaque placeholder argument.
ordinal
Creates an ordinal-plural pattern selected by value.
other
Creates a other category branch for a numeric selector.
otherwise
Creates the required final fallback branch for a semantic selector.
plural
Creates a cardinal-plural pattern selected by value.
revision_id
Derives the full revision ID for a serializable bundle revision value.
select
Creates a semantic selector pattern selected by a stable application key.
term
Starts building an argument that references term_id.
two
Creates a two category branch for a numeric selector.
tx
Creates a source-authored localized value without placeholder arguments.
tx_owned
Creates an atomic localized value from adapter-owned text after validation.
txa
Creates a source-authored localized value with named placeholder arguments.
when
Creates a conditional branch for a semantic selector.
zero
Creates a zero category branch for a numeric selector.