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::{parse_icu, parse_po};
let po = parse_po("msgid \"Hello\"\nmsgstr \"Hallo\"\n")?;
let icu = parse_icu("Hello {name}")?;
assert_eq!(po.items[0].msgid, "Hello");
assert_eq!(icu.nodes.len(), 2);use ferrocat::{
CompileSelectedCatalogArtifactOptions, CompiledCatalogIdIndex, CompiledKeyStrategy,
ParseCatalogOptions, compile_catalog_artifact_selected, parse_catalog,
};
let source = parse_catalog(ParseCatalogOptions {
content: "msgid \"Hello\"\nmsgstr \"Hello\"\n",
source_locale: "en",
locale: Some("en"),
..ParseCatalogOptions::default()
})?
.into_normalized_view()?;
let requested = parse_catalog(ParseCatalogOptions {
content: "msgid \"Hello\"\nmsgstr \"Hallo\"\n",
source_locale: "en",
locale: Some("de"),
..ParseCatalogOptions::default()
})?
.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 {
requested_locale: "de",
source_locale: "en",
compiled_ids: &compiled_ids,
..CompileSelectedCatalogArtifactOptions::default()
},
)?;
assert_eq!(compiled.messages.len(), 1);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
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
Stats - Basic counters describing an update operation.
- Catalog
Update Result - Result returned by catalog update operations.
- Compile
Catalog Artifact Options - Options controlling high-level compiled catalog artifact generation.
- 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 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 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.
- 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.
- IcuPosition
- Byte offset plus line/column location inside the original input.
- Merge
Extracted Message - Borrowed extracted message input for the lightweight merge helper.
- MsgStr
Iter - Iterator over
MsgStrvalues. - 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.
- 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
Storage Format - Storage format used by the high-level catalog API.
- Catalog
Update Input - Input payload accepted by catalog update operations.
- 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. - IcuError
Kind - High-level classification of ICU parse failures.
- IcuNode
- AST node emitted by the ICU parser.
- IcuPlural
Kind - Distinguishes cardinal and ordinal plural forms.
- 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.
Functions§
- compile_
catalog_ artifact - Compiles one requested-locale runtime artifact from one or more normalized catalogs.
- compile_
catalog_ artifact_ selected - Compiles one requested-locale runtime artifact for a selected subset of compiled IDs.
- compiled_
key - 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. - 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. - merge_
catalog - Merges extracted messages into an existing PO catalog while preserving the existing translation payload.
- 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.
- 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.