Expand description
Public Rust entry point for the ferrocat workspace.
This crate re-exports the primary API surface from the lower-level
ferrocat-po and ferrocat-icu crates so application code can depend on a
single package.
§Examples
use ferrocat::{icu, po};
let po = po::parse_po("msgid \"Hello\"\nmsgstr \"Hallo\"\n")?;
let icu = icu::parse_icu("Hello {name}")?;
assert_eq!(po.items[0].msgid, "Hello");
assert_eq!(icu.nodes.len(), 2);use ferrocat::catalog::{
CompileSelectedCatalogArtifactOptions, CompiledCatalogIdIndex, CompiledKeyStrategy,
ParseCatalogOptions, compile_catalog_artifact_selected, parse_catalog,
};
let source = parse_catalog(ParseCatalogOptions {
locale: Some("en"),
..ParseCatalogOptions::new("msgid \"Hello\"\nmsgstr \"Hello\"\n", "en")
})?
.into_normalized_view()?;
let requested = parse_catalog(ParseCatalogOptions {
locale: Some("de"),
..ParseCatalogOptions::new("msgid \"Hello\"\nmsgstr \"Hallo\"\n", "en")
})?
.into_normalized_view()?;
let index = CompiledCatalogIdIndex::new(&[&requested, &source], CompiledKeyStrategy::FerrocatV1)?;
let compiled_ids = index.iter().map(|(id, _)| id.to_owned()).collect::<Vec<_>>();
let compiled = compile_catalog_artifact_selected(
&[&requested, &source],
&index,
&CompileSelectedCatalogArtifactOptions::new("de", "en", &compiled_ids),
)?;
assert_eq!(compiled.messages.len(), 1);use ferrocat::catalog::{
CatalogAuditOptions, ParseCatalogOptions, audit_catalogs, parse_catalog,
};
let source = parse_catalog(ParseCatalogOptions {
locale: Some("en"),
..ParseCatalogOptions::new("msgid \"Checkout\"\nmsgstr \"Checkout\"\n", "en")
})?
.into_normalized_view()?;
let target = parse_catalog(ParseCatalogOptions {
locale: Some("de"),
..ParseCatalogOptions::new("", "en")
})?
.into_normalized_view()?;
let report = audit_catalogs(&[&source, &target], &CatalogAuditOptions::new("en"))?;
assert!(report.has_errors());use std::io::Cursor;
use ferrocat::catalog::NdjsonCatalogReader;
let input = concat!(
"---\n",
"format: ferrocat.ndjson.v1\n",
"source_locale: en\n",
"---\n",
"{\"id\":\"Checkout\",\"str\":\"Zur Kasse\"}\n",
);
let messages = NdjsonCatalogReader::new(Cursor::new(input.as_bytes()), "en")?
.collect::<Result<Vec<_>, _>>()?;
assert_eq!(messages[0].msgid, "Checkout");Modules§
- catalog
- High-level catalog maintenance, audit, and runtime artifact APIs.
- icu
- ICU MessageFormat parsing, analysis, compatibility, and metadata APIs.
- po
- Low-level PO parsing, serialization, and text merge APIs.
Structs§
- Borrowed
Header - Borrowed header entry from the PO header block.
- Borrowed
PoFile - Borrowed PO document that reuses slices from the original input whenever possible.
- Borrowed
PoItem - Borrowed gettext message entry.
- Catalog
Audit Checks - Enables or disables individual catalog audit checks.
- Catalog
Audit Diagnostic - One machine-readable catalog audit diagnostic.
- Catalog
Audit Message Ref - Catalog message reference attached to audit diagnostics.
- Catalog
Audit Options - Options controlling catalog audit checks.
- Catalog
Audit Report - Report returned by
audit_catalogs. - Catalog
Audit Summary - Summary counters for a catalog audit report.
- Catalog
Combine Input - One catalog input passed to
super::combine_catalogs. - Catalog
Combine Result - Result returned by catalog combine operations.
- Catalog
Combine Stats - Basic counters describing a catalog combine operation.
- Catalog
Coverage Message - One classified message row in a coverage report.
- Catalog
Coverage Options - Options controlling catalog coverage reports.
- Catalog
Coverage Report - Structured catalog coverage report.
- Catalog
File Combine Result - Result returned by catalog file combine operations.
- Catalog
Locale Coverage - Coverage counters for one target locale.
- Catalog
Locale Review - Review details for one target locale.
- Catalog
Machine Translation Message - One machine-translation metadata classification.
- Catalog
Machine Translation Review - Machine-translation metadata summary for one locale.
- Catalog
Message - Public message representation returned by
super::parse_catalog. - Catalog
Message Extra - Extra translator-facing metadata preserved on a catalog message.
- Catalog
Message Key - Stable lookup key for catalog messages.
- Catalog
Origin - File and line information for an extracted message origin.
- Catalog
Review Options - Options controlling catalog review reports.
- Catalog
Review Report - Read-only catalog review report comparing two normalized catalog states.
- Catalog
Review Summary - Aggregate counters for a catalog review report.
- Catalog
Source Change - One source identity change.
- Catalog
Source Change Report - Source identity add/remove summary.
- Catalog
Stats - Basic counters describing an update operation.
- Catalog
Translation Change - One target translation change.
- Catalog
Translation Change Report - Translation change summary for one locale.
- Catalog
Update Result - Result returned by catalog update operations.
- Combine
Catalog Files Options - Options for combining catalog files on disk.
- Combine
Catalog Options - Options for combining multiple catalogs into one deterministic catalog.
- Compile
Catalog Artifact IcuOptions - ICU-specific options used while compiling catalog artifacts.
- Compile
Catalog Artifact Options - Options controlling high-level compiled catalog artifact generation.
- Compile
Catalog Artifact Report Options - Options controlling compiled artifact generation with a sibling provenance report.
- Compile
Catalog Options - Options controlling runtime catalog compilation.
- Compile
Selected Catalog Artifact Options - Options controlling selected-subset compiled catalog artifact generation.
- Compiled
Catalog - Runtime-oriented lookup structure compiled from a normalized catalog.
- Compiled
Catalog Artifact - Host-neutral compiled runtime artifact for one requested locale.
- Compiled
Catalog Artifact Report - Result returned by
super::compile_catalog_artifact_report. - Compiled
Catalog Diagnostic - Diagnostic emitted by
super::compile_catalog_artifact. - Compiled
Catalog IdDescription - Metadata describing one compiled runtime ID for a specific catalog set.
- Compiled
Catalog IdIndex - Stable compiled runtime ID index built from one or more normalized catalogs.
- Compiled
Catalog Missing Message - Missing-message record emitted by
super::compile_catalog_artifact. - Compiled
Catalog Provenance Report - Provenance metadata for one compiled requested-locale artifact.
- Compiled
Catalog Resolution - Provenance row for one compiled runtime message identity.
- Compiled
Catalog Unavailable Id - Known compiled runtime ID that was not present in the provided catalog set.
- Compiled
Message - A compiled runtime message keyed by a derived lookup key.
- Describe
Compiled IdsReport - Report returned by
CompiledCatalogIdIndex::describe_compiled_ids. - Diagnostic
- Non-fatal issue collected while parsing or updating catalogs.
- Extracted
Plural Message - Structured plural message input used by catalog update operations.
- Extracted
Singular Message - Structured singular message input used by catalog update operations.
- Header
- A single header entry from the PO header block.
- IcuAnalysis
- Structural summary of a parsed ICU message.
- IcuArgument
- One data argument reference discovered in an ICU message.
- IcuCompatibility
Options - Options controlling ICU source/translation compatibility checks.
- IcuCompatibility
Report - Report returned by
compare_icu_messages. - IcuDiagnostic
- One diagnostic emitted by an ICU compatibility check.
- IcuFormatter
- One formatter reference discovered in an ICU message.
- IcuMessage
- Parsed ICU message.
- IcuOption
- A selector branch inside a plural or select expression.
- IcuParse
Error - Error returned when parsing ICU messages fails.
- IcuParser
Options - Options controlling ICU parsing behavior.
- IcuPlural
Summary - One cardinal or ordinal plural expression discovered in an ICU message.
- IcuPosition
- Byte offset plus line/column location inside the original input.
- IcuPseudolocalization
Options - Options controlling ICU-aware pseudolocalization.
- IcuSelect
Summary - One select expression discovered in an ICU message.
- IcuTag
Summary - One rich-text tag discovered in an ICU message.
- Machine
Translation Metadata - Machine-translation metadata attached to one translated catalog entry.
- Merge
Extracted Message - Borrowed extracted message input for the lightweight merge helper.
- Message
Argument Format Metadata - Formatter metadata attached to an argument.
- Message
Argument Metadata - Normalized semantic metadata for one message argument.
- Message
Metadata - Normalized semantic metadata for one source message.
- Message
Metadata Diagnostic - One diagnostic emitted while validating semantic message metadata.
- Message
Metadata Input - Authoring input for semantic message metadata.
- Message
Metadata Validation Report - Report returned by
validate_message_metadata. - Message
Origin Metadata - Extraction origin attached to semantic message metadata.
- Message
Selector Metadata - Selector metadata attached to a selecting argument.
- MsgStr
Iter - Iterator over
MsgStrvalues. - Ndjson
Catalog Reader - Streaming reader for Ferrocat NDJSON catalog records.
- Ndjson
Catalog Reader Options - Options for constructing an
NdjsonCatalogReader. - Ndjson
Catalog Writer - Streaming writer for Ferrocat NDJSON catalog records.
- Ndjson
Catalog Writer Options - Options for constructing an
NdjsonCatalogWriter. - Normalized
Parsed Catalog - Parsed catalog with fast key-based lookup helpers.
- Parse
Catalog Options - Options for parsing a catalog into the higher-level message model.
- Parse
Error - Error returned when parsing or unescaping PO content fails.
- Parsed
Catalog - Parsed catalog plus diagnostics and normalized headers.
- Plural
Source - Source-side plural forms for structured catalog messages.
- PoFile
- An owned PO document.
- PoItem
- A single gettext message entry.
- Render
Options - Shared rendering options for catalog serialization.
- Serialize
Options - Options controlling PO serialization.
- Source
Extracted Message - Source-first extractor input that lets
ferrocatinfer plural structure. - Update
Catalog File Options - Options for updating a catalog file on disk.
- Update
Catalog Options - Options for in-memory catalog updates.
Enums§
- ApiError
- Error returned by catalog parsing and update APIs.
- Borrowed
MsgStr - Borrowed translation payload for a PO item.
- Catalog
Combine Selection - Selection rule used after definitions from all inputs have been counted.
- Catalog
Conflict Strategy - Strategy used when multiple catalogs define conflicting translations for one identity.
- Catalog
File Format - File format used by disk-based catalog combine operations.
- Catalog
Machine Translation Status - Machine-translation metadata freshness status.
- Catalog
Message Status - Canonical catalog message status used by coverage and review reports.
- Catalog
Mode - Valid high-level catalog mode combinations.
- Catalog
Review Translation - Owned translation value used in review reports.
- Catalog
Semantics - High-level semantics used by the catalog API.
- Catalog
Source Change Kind - Kind of source identity change.
- Catalog
Storage Format - Storage format used by the high-level catalog API.
- Catalog
Update Input - Input payload accepted by catalog update operations.
- Compile
Catalog Artifact Report Selection - Message selection for
super::compile_catalog_artifact_report. - Compiled
Catalog Resolution Kind - How one compiled runtime message resolved for a requested-locale artifact.
- Compiled
Catalog Translation Kind - High-level translation kind associated with a compiled runtime ID.
- Compiled
KeyStrategy - Built-in key strategy used when compiling runtime catalogs.
- Compiled
Translation - Translation value stored in a compiled runtime catalog.
- Diagnostic
Severity - Severity level attached to a
Diagnostic. - Effective
Translation - Owned translation value materialized from a parsed catalog.
- Effective
Translation Ref - Borrowed view over a message translation.
- Extracted
Message - Structured extractor input accepted by
super::update_catalogandsuper::update_catalog_file. - IcuArgument
Kind - Broad role of an ICU argument in a parsed message.
- IcuDiagnostic
Severity - Severity level attached to ICU authoring diagnostics.
- IcuError
Kind - High-level classification of ICU parse failures.
- IcuFormatter
Support - Consumer-defined support decision for an ICU formatter.
- IcuNode
- AST node emitted by the ICU parser.
- IcuPlural
Kind - Distinguishes cardinal and ordinal plural forms.
- IcuStyle
Kind - Classification of an optional formatter style segment.
- IcuSyntax
Policy - ICU parser behavior used by catalog audit and runtime artifact validation.
- Message
Argument Kind - Broad argument kind used by semantic message metadata.
- Message
Argument Metadata Input - Progressive authoring input for one argument.
- Message
Format Style Kind - Classification of a message formatter style.
- Message
Selector Kind - Selector kind used by semantic message metadata.
- MsgStr
- Message translation payload for a PO item.
- Obsolete
Strategy - Strategy used for messages that disappear from the extracted input.
- OrderBy
- Sort order used when writing output catalogs.
- Placeholder
Comment Mode - Controls whether placeholder hints are emitted as extracted comments.
- Plural
Encoding - Encoding used for plural messages in PO files.
- Translation
Shape - Public translation shape returned from parsed catalogs.
Constants§
- COMPILED_
CATALOG_ ARTIFACT_ SCHEMA_ VERSION - JSON schema version emitted by
CompiledCatalogArtifactserialization.
Functions§
- analyze_
icu - Produces a structural summary of a parsed ICU message.
- audit_
catalogs - Audits a normalized catalog set for catalog QA and authoring issues.
- catalog_
coverage - Builds a read-only completeness and coverage report for normalized catalogs.
- catalog_
review - Compares previous and current normalized catalog states for translator review.
- combine_
catalog_ files - Combines catalog files and atomically replaces the requested output path.
- combine_
catalogs - Combines multiple catalogs into one deterministic catalog.
- compare_
icu_ messages - Compares source and translation ICU messages for authoring compatibility.
- compile_
catalog_ artifact - Compiles one requested-locale runtime artifact from one or more normalized catalogs.
- compile_
catalog_ artifact_ report - Compiles one requested-locale runtime artifact with a sibling provenance report.
- compile_
catalog_ artifact_ selected - Compiles one requested-locale runtime artifact for a selected subset of compiled IDs.
- compile_
catalog_ artifact_ selected_ with_ icu_ options - Compiles a selected subset of compiled IDs with explicit ICU syntax options.
- compile_
catalog_ artifact_ with_ icu_ options - Compiles one requested-locale runtime artifact with explicit ICU syntax options.
- compiled_
key - Derives the default stable runtime lookup key for
msgidandmsgctxt. - derive_
message_ metadata_ from_ icu - Derives normalized semantic metadata from an ICU MessageFormat v1
msgid. - escape_
string - Escapes a PO string literal payload.
- extract_
argument_ names - Extracts data argument names in first-seen order, excluding rich-text tags.
- extract_
quoted - Extracts and unescapes the first quoted PO string from
line. - extract_
quoted_ cow - Extracts and unescapes the first quoted PO string from
line, borrowing from the input when no escapes are present. - extract_
tag_ names - Extracts rich-text tag names in first-seen order.
- extract_
variables - Extracts variable names in first-seen order.
- has_
plural - Returns
truewhen the message contains a cardinal plural expression. - has_
select - Returns
truewhen the message contains a select expression. - has_
select_ ordinal - Returns
truewhen the message contains an ordinal plural expression. - has_
selectordinal - Returns
truewhen the message contains an ordinal plural expression. - has_tag
- Returns
truewhen the message contains rich-text style tags. - machine_
translation_ hash - Computes the machine-translation change-detection hash for a translation.
- merge_
catalog - Merges extracted messages into an existing PO catalog while preserving the existing translation payload.
- normalize_
message_ metadata - Normalizes progressive semantic message metadata into canonical object form.
- parse_
catalog - Parses catalog content into the higher-level representation used by
ferrocat’s catalog APIs. - parse_
icu - Parses ICU
MessageFormatinput with the default parser options. - parse_
icu_ with_ options - Parses ICU
MessageFormatinput with explicit parser options. - parse_
po - Parses PO content into the owned
PoFilerepresentation. - parse_
po_ borrowed - Parses PO content into a borrowed representation.
- pseudolocalize_
compiled_ catalog_ artifact - Pseudolocalizes the final runtime messages in a compiled catalog artifact.
- pseudolocalize_
compiled_ catalog_ artifact_ with_ syntax_ policy - Pseudolocalizes a compiled catalog artifact with the provided ICU syntax policy.
- pseudolocalize_
icu - Pseudolocalizes an ICU message string while preserving ICU syntax.
- pseudolocalize_
icu_ message - Pseudolocalizes a parsed ICU message AST.
- stringify_
icu - Renders a parsed ICU message AST back to ICU
MessageFormattext. - stringify_
po - Serializes a
PoFileback into gettext PO text. - unescape_
string - Unescapes a PO string literal payload.
- update_
catalog - Merges extracted messages into an existing catalog and returns updated catalog content.
- update_
catalog_ file - Updates a catalog on disk and only writes the file when the rendered output changes.
- validate_
icu - Validates ICU
MessageFormatinput without returning the parsed AST. - validate_
icu_ formatter_ support - Validates ICU formatter usage against a consumer-provided support policy.
- validate_
icu_ formatter_ support_ from_ analysis - Validates analyzed ICU formatter usage against a consumer support policy.
- validate_
message_ metadata - Validates progressive semantic message metadata against its
msgid.
Type Aliases§
- IcuFormatter
Support Policy - Callback used to validate runtime support for ICU formatters.