Expand description
Performance-first PO parsing and serialization.
The crate exposes both owned and borrowed parsers for gettext PO files, a byte-oriented UTF-8 parser entry point, plus helpers for serialization and higher-level catalog update workflows.
§Feature flags
The default feature set is full, which currently enables the catalog
workflow layer.
catalogexposes high-level catalog parsing, updates, combining, audits, machine-translation metadata, plural handling, FCL storage, and runtime artifact compilation. It also enables the catalog-layer dependencies used for hashing, atomic file updates, serde JSON output, ICU diagnostics, and CLDR plural data.serdeenables serde implementations for low-level PO document types and is also enabled bycatalogfor catalog-layer JSON/report shapes.compile,mt, andpluralsare reserved subsystem aliases. Today they implycatalog; they do not reduce or split the catalog API surface.
Use default-features = false for the low-level PO parser, borrowed parser,
serializer, string helpers, and lightweight merge_catalog helper without
catalog-layer dependencies. Enabling compile, mt, or plurals currently
has the same dependency effect as enabling catalog.
§Examples
use ferrocat_po::{PoFile, SerializeOptions, parse_po, stringify_po};
let input = "msgid \"Hello\"\nmsgstr \"Hallo\"\n";
let file = parse_po(input)?;
assert_eq!(file.items[0].msgid, "Hello");
let output = stringify_po(&file, &SerializeOptions::default());
assert!(output.contains("msgid \"Hello\""));use ferrocat_po::parse_po_bytes;
let input = b"msgid \"Hello\"\nmsgstr \"Hallo\"\n";
let file = parse_po_bytes(input)?;
assert_eq!(file.items[0].msgstr[0], "Hallo");use ferrocat_po::{
CompileCatalogArtifactOptions, CompileSelectedCatalogArtifactOptions,
CompiledCatalogIdIndex, ParseCatalogOptions, compile_catalog_artifact_selected,
parse_catalog,
};
let source = parse_catalog(
ParseCatalogOptions::new("msgid \"Hello\"\nmsgstr \"Hello\"\n", "en").with_locale("en"),
)?
.into_normalized_view()?;
let requested = parse_catalog(
ParseCatalogOptions::new("msgid \"Hello\"\nmsgstr \"Hallo\"\n", "en").with_locale("de"),
)?
.into_normalized_view()?;
let index = CompiledCatalogIdIndex::new(&[&requested, &source], ferrocat_po::CompiledKeyStrategy::FerrocatV1)?;
let compiled_ids = index.iter().map(|(id, _)| id).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_po::{CatalogAuditOptions, ParseCatalogOptions, audit_catalogs, parse_catalog};
let source = parse_catalog(
ParseCatalogOptions::new("msgid \"Hello {name}\"\nmsgstr \"Hello {name}\"\n", "en")
.with_locale("en"),
)?
.into_normalized_view()?;
let target = parse_catalog(
ParseCatalogOptions::new("msgid \"Hello {name}\"\nmsgstr \"Hallo\"\n", "en")
.with_locale("de"),
)?
.into_normalized_view()?;
let report = audit_catalogs(&[&source, &target], &CatalogAuditOptions::new("en"))?;
assert!(report.has_errors());Modules§
- diagnostic_
codes - Stable machine-readable diagnostic codes emitted by
ferrocat-po.
Structs§
- AiProvenance
catalog - AI provenance for a machine-managed value.
- 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 catalog - Enables or disables individual catalog audit checks.
- Catalog
Audit Diagnostic catalog - One machine-readable catalog audit diagnostic.
- Catalog
Audit IcuOptions catalog - ICU-specific options used by catalog audit checks.
- Catalog
Audit Message Ref catalog - Catalog message reference attached to audit diagnostics.
- Catalog
Audit Options catalog - Options controlling catalog audit checks.
- Catalog
Audit Report catalog - Report returned by
audit_catalogs. - Catalog
Audit Summary catalog - Summary counters for a catalog audit report.
- Catalog
Combine Input catalog - One catalog input passed to
super::combine_catalogs. - Catalog
Combine Result catalog - Result returned by catalog combine operations.
- Catalog
Combine Stats catalog - Basic counters describing a catalog combine operation.
- Catalog
Coverage Message catalog - One classified message row in a coverage report.
- Catalog
Coverage Options catalog - Options controlling catalog coverage reports.
- Catalog
Coverage Report catalog - Structured catalog coverage report.
- Catalog
File Combine Result catalog - Result returned by catalog file combine operations.
- Catalog
Locale Coverage catalog - Coverage counters for one target locale.
- Catalog
Locale Review catalog - Review details for one target locale.
- Catalog
Machine Translation Message catalog - One machine-translation metadata classification.
- Catalog
Machine Translation Review catalog - Machine-translation metadata summary for one locale.
- Catalog
Message catalog - Public message representation returned by
super::parse_catalog. - Catalog
Message Key catalog - Stable lookup key for catalog messages.
- Catalog
Origin catalog - Source origin metadata for an extracted message.
- Catalog
Review Options catalog - Options controlling catalog review reports.
- Catalog
Review Report catalog - Read-only catalog review report comparing two normalized catalog states.
- Catalog
Review Summary catalog - Aggregate counters for a catalog review report.
- Catalog
Source Change catalog - One source identity change.
- Catalog
Source Change Report catalog - Source identity add/remove summary.
- Catalog
Stats catalog - Basic counters describing an update operation.
- Catalog
Translation Change catalog - One target translation change.
- Catalog
Translation Change Report catalog - Translation change summary for one locale.
- Catalog
Update Result catalog - Result returned by catalog update operations.
- Combine
Catalog Files Options catalog - Options for combining catalog files on disk.
- Combine
Catalog Options catalog - Options for combining multiple catalogs into one deterministic catalog.
- Compile
Catalog Artifact IcuOptions catalog - ICU-specific options used while compiling catalog artifacts.
- Compile
Catalog Artifact Options catalog - Options controlling high-level compiled catalog artifact generation.
- Compile
Catalog Artifact Report Options catalog - Options controlling compiled artifact generation with a sibling provenance report.
- Compile
Catalog Options catalog - Options controlling runtime catalog compilation.
- Compile
Selected Catalog Artifact Options catalog - Options controlling selected-subset compiled catalog artifact generation.
- Compiled
Catalog catalog - Runtime-oriented lookup structure compiled from a normalized catalog.
- Compiled
Catalog Artifact catalog - Host-neutral compiled runtime artifact for one requested locale.
- Compiled
Catalog Artifact Report catalog - Result returned by
super::compile_catalog_artifact_report. - Compiled
Catalog Diagnostic catalog - Diagnostic emitted by
super::compile_catalog_artifact. - Compiled
Catalog IdDescription catalog - Metadata describing one compiled runtime ID for a specific catalog set.
- Compiled
Catalog IdIndex catalog - Stable compiled runtime ID index built from one or more normalized catalogs.
- Compiled
Catalog Missing Message catalog - Missing-message record emitted by
super::compile_catalog_artifact. - Compiled
Catalog Provenance Report catalog - Provenance metadata for one compiled requested-locale artifact.
- Compiled
Catalog Pseudolocalization Options catalog - Options controlling compiled catalog artifact pseudolocalization.
- Compiled
Catalog Resolution catalog - Provenance row for one compiled runtime message identity.
- Compiled
Catalog Unavailable Id catalog - Known compiled runtime ID that was not present in the provided catalog set.
- Compiled
Message catalog - A compiled runtime message keyed by a derived lookup key.
- Describe
Compiled IdsReport catalog - Report returned by
CompiledCatalogIdIndex::describe_compiled_ids. - Diagnostic
catalog - Non-fatal issue collected while parsing or updating catalogs.
- Diagnostic
Code - Stable machine-readable diagnostic code.
- Extracted
Plural Message catalog - Structured plural message input used by catalog update operations.
- Extracted
Singular Message catalog - Structured singular message input used by catalog update operations.
- Header
- A single header entry from the PO header block.
- IcuPseudolocalization
Options catalog - Options controlling ICU-aware pseudolocalization.
- Machine
Metadata catalog - Metadata for a catalog value that was set or managed by a machine.
- Merge
Message Input - Borrowed message input for the lightweight PO merge helper.
- MsgStr
Iter - Iterator over
MsgStrvalues. - Normalized
Parsed Catalog catalog - Parsed catalog with fast key-based lookup helpers.
- Obsolete
Info catalog - Obsolete-entry payload. Presence on
CatalogMessage::obsoletemarks the entry obsolete;sincerecords when it became obsolete so hosts can age-cleanup withObsoleteStrategy::DropObsoleteBefore. - Parse
Catalog Options catalog - Options for parsing a catalog into the higher-level message model.
- Parse
Error - Error returned when parsing or unescaping PO content fails.
- Parse
Position - One-based line/column context plus the byte offset for a parse error.
- Parsed
Catalog catalog - Parsed catalog plus diagnostics and normalized headers.
- Plural
Source catalog - Source-side plural forms for structured catalog messages.
- PoFile
- An owned PO document.
- PoItem
- A single gettext message entry.
- PoVec
- Inline-capable vector for the small per-item collections (references, flags, comments, metadata) that hold a single element in the overwhelmingly common case, avoiding a heap allocation for the backing buffer.
- PoVec
Into Iter - Owning iterator returned by
PoVec::into_iter. - Render
Options catalog - Shared rendering options for catalog serialization.
- Serialize
Options - Options controlling PO serialization.
- Source
Extracted Message catalog - Source-first extractor input that lets
ferrocatinfer plural structure. - Update
Catalog File Options catalog - Options for updating a catalog file on disk.
- Update
Catalog Options catalog - Options for in-memory catalog updates.
Enums§
- ApiError
catalog - Error returned by catalog parsing and update APIs.
- Borrowed
MsgStr - Borrowed translation payload for a PO item.
- Catalog
Combine Selection catalog - Selection rule used after definitions from all inputs have been counted.
- Catalog
Conflict Strategy catalog - Strategy used when multiple catalogs define conflicting translations for one identity.
- Catalog
File Format catalog - File format used by disk-based catalog combine operations.
- Catalog
Machine Translation Status catalog - Machine-translation metadata freshness status.
- Catalog
Message Status catalog - Canonical catalog message status used by coverage and review reports.
- Catalog
Mode catalog - Valid high-level catalog mode combinations.
- Catalog
Review Translation catalog - Owned translation value used in review reports.
- Catalog
Semantics catalog - High-level semantics used by the catalog API.
- Catalog
Source Change Kind catalog - Kind of source identity change.
- Catalog
Storage Format catalog - Storage format used by the high-level catalog API.
- Catalog
Update Input catalog - Input payload accepted by catalog update operations.
- Compile
Catalog Artifact Report Selection catalog - Message selection for
super::compile_catalog_artifact_report. - Compiled
Catalog Resolution Kind catalog - How one compiled runtime message resolved for a requested-locale artifact.
- Compiled
Catalog Translation Kind catalog - High-level translation kind associated with a compiled runtime ID.
- Compiled
KeyStrategy catalog - Built-in key strategy used when compiling runtime catalogs.
- Compiled
Translation catalog - Translation value stored in a compiled runtime catalog.
- Diagnostic
Severity catalog - Severity level attached to a
Diagnostic. - Effective
Translation catalog - Owned translation value materialized from a parsed catalog.
- Effective
Translation Ref catalog - Borrowed view over a message translation.
- Extracted
Message catalog - Structured extractor input accepted by
super::update_catalogandsuper::update_catalog_file. - IcuSyntax
Policy catalog - ICU parser behavior used by catalog audit and runtime artifact validation.
- MsgStr
- Message translation payload for a PO item.
- Obsolete
Strategy catalog - Strategy used for messages that disappear from the extracted input.
- OrderBy
catalog - Sort order used when writing output catalogs.
- Placeholder
Comment Mode catalog - Controls whether placeholder hints are emitted as extracted comments.
- Plural
Encoding catalog - Encoding used for plural messages in PO files.
- Translation
Shape catalog - Public translation shape returned from parsed catalogs.
Constants§
- COMPILED_
CATALOG_ ARTIFACT_ SCHEMA_ VERSION catalog - JSON schema version emitted by
CompiledCatalogArtifactserialization.
Functions§
- audit_
catalogs catalog - Audits a normalized catalog set for catalog QA and authoring issues.
- combine_
catalog_ files catalog - Combines catalog files and atomically replaces the requested output path.
- combine_
catalogs catalog - Combines multiple catalogs into one deterministic catalog.
- compile_
catalog_ artifact catalog - Compiles one requested-locale runtime artifact from one or more normalized catalogs.
- compile_
catalog_ artifact_ report catalog - Compiles one requested-locale runtime artifact with a sibling provenance report.
- compile_
catalog_ artifact_ selected catalog - Compiles one requested-locale runtime artifact for a selected subset of compiled IDs.
- compiled_
key catalog - Derives the default stable runtime lookup key for
msgidandmsgctxt. - escape_
string - Escapes a PO string literal payload.
- 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. - machine_
translation_ hash catalog - Computes the integrity-lock hash for a translation value.
- measure_
catalog_ coverage catalog - Builds a read-only completeness and coverage report for normalized catalogs.
- merge_
catalog - Merges extracted messages into an existing PO catalog while preserving the existing translation payload.
- parse_
catalog catalog - Parses catalog content into the higher-level representation used by
ferrocat’s catalog APIs. - parse_
po - Parses PO content into the owned
PoFilerepresentation. - parse_
po_ borrowed - Parses PO content into a borrowed representation.
- parse_
po_ bytes - Parses UTF-8 PO bytes into the owned
PoFilerepresentation. - pseudolocalize_
compiled_ catalog_ artifact catalog - Pseudolocalizes the final runtime messages in a compiled catalog artifact.
- review_
catalogs catalog - Compares previous and current normalized catalog states for translator review.
- stringify_
po - Serializes a
PoFileback into gettext PO text. - unescape_
string - Unescapes a PO string literal payload.
- update_
catalog catalog - Merges extracted messages into an existing catalog and returns updated catalog content.
- update_
catalog_ file catalog - Updates a catalog on disk and only writes the file when the rendered output changes.
Type Aliases§
- IcuFormatter
Support Policy catalog - Callback used to validate runtime support for ICU formatters.