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§
- Annotated
Localized String - A lazy localized value paired with application-owned placeholder metadata.
- Bundle
- Validated runtime artifact for one locale.
- Bundle
Entry - One message family in a bundle.
- Bundle
Row - One translated expansion row.
- Bundle
Term - Runtime facets and forms for one stable term ID.
- Bundle
Term Surface - One localized surface of a numbered term form.
- Diagnostic
- Structured event emitted when normal resolution performs recovery.
- Expansion
Descriptor - Canonical data hashed to produce a row ID.
- Identity
Descriptor - Locale-independent fields used to derive a message’s stable identity.
- Localized
String - Immutable source-authored localized value awaiting explicit resolution.
- Localizer
- Resolves immutable localized values through source configuration or a bundle pair.
- Number
Format - Pinned locale data used by Trox’s deterministic decimal formatter.
- Numeric
Branch - One branch of a cardinal or ordinal numeric selector.
- Pattern
Value - A fully owned pattern under construction.
- Plural
Rules - CLDR cardinal and ordinal conditions keyed by resulting category.
- Resolve
Outcome - Rendered text plus whether the whole message used its source fallback.
- Resolved
Localized Parts Outcome - Structured resolution plus whether the complete message used source fallback.
- RonTx
- The checked payload of RON’s
Tx(text: ..., ...)authoring variant. - Select
Arm - One source-authored branch of a semantic selector.
- Source
Catalog - The validated message identities and term schemas authorized by a source bundle.
- Source
Locale - Human-authored configuration for bundle-free source-language resolution.
- Source
Message - Immutable, catalog-authorized source message awaiting argument binding.
- Source
Message Ref - Canonical, argument-free reference to a source-catalog message contract.
- Term
Argument - Reference to a term, optionally specifying a form and count.
- TermId
- Validated, stable identifier for an application term.
- Trox
Integer - Non-negative safe integer accepted by selectors and numbered terms.
- Trox
Number - Finite floating-point scalar accepted by the Trox wire model.
- Trox
Value Error - 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.
- Argument
Kind - Coarse placeholder category used to compare source and translated rows.
- Argument
Schema - Source-authored contract for one visible placeholder binding.
- Bundle
Term Form - A scalar or cardinally inflected term form.
- Deserialize
Error - An error produced while decoding or validating Trox wire data.
- Diagnostic
Code - Stable machine-readable categories emitted by runtime recovery.
- Isolation
Policy - Controls bidirectional isolation around interpolated placeholder surfaces.
- Numeric
Branch Key - Identity-bearing key for a numeric selector branch.
- Pattern
- Locale-independent source pattern for a message.
- Plural
Category - CLDR plural category used by cardinal and ordinal patterns.
- Resolve
Error - An error produced by strict localization resolution.
- Resolved
Localized Part - One display-ready run produced from a localized message.
- RonPlaceholder
- Declared runtime value category for a placeholder in a RON
Txtemplate. - Select
Identity Branch - Identity-bearing branch of a stable semantic selector.
- Selector
Key - Runtime key used to select a semantic branch.
- Selector
Record - Runtime selector input paired with its path in the identity pattern.
- Serialize
Error - An error produced while encoding a Trox value or bundle.
- Text
Direction - Base direction of a locale’s surrounding text.
Constants§
- CLDR_
VERSION - The CLDR release pinned into Trox’s source and bundle runtimes.
Traits§
- Trox
Selector - 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
countednumbered-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
fewcategory branch for a numeric selector. - identity_
ids - Derives the canonical short entry ID and full source signature for an identity.
- indefinite
- Creates an
indefinitescalar-form term argument. - ls
- Asserts that runtime text is appropriate to display without translation.
- many
- Creates a
manycategory branch for a numeric selector. - meaning
- Assigns a stable semantic meaning to a complete message pattern.
- one
- Creates a
onecategory 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
othercategory 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
twocategory 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
zerocategory branch for a numeric selector.