Skip to main content

Crate ferrocat

Crate ferrocat 

Source
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);
use ferrocat::{CatalogAuditOptions, ParseCatalogOptions, audit_catalogs, parse_catalog};

let source = parse_catalog(ParseCatalogOptions {
    content: "msgid \"Checkout\"\nmsgstr \"Checkout\"\n",
    source_locale: "en",
    locale: Some("en"),
    ..ParseCatalogOptions::default()
})?
.into_normalized_view()?;
let target = parse_catalog(ParseCatalogOptions {
    content: "",
    source_locale: "en",
    locale: Some("de"),
    ..ParseCatalogOptions::default()
})?
.into_normalized_view()?;
let report = audit_catalogs(&[&source, &target], &CatalogAuditOptions::new("en"))?;

assert!(report.has_errors());

Structs§

BorrowedHeader
Borrowed header entry from the PO header block.
BorrowedPoFile
Borrowed PO document that reuses slices from the original input whenever possible.
BorrowedPoItem
Borrowed gettext message entry.
CatalogAuditChecks
Enables or disables individual catalog audit checks.
CatalogAuditDiagnostic
One machine-readable catalog audit diagnostic.
CatalogAuditMessageRef
Catalog message reference attached to audit diagnostics.
CatalogAuditOptions
Options controlling catalog audit checks.
CatalogAuditReport
Report returned by audit_catalogs.
CatalogAuditSummary
Summary counters for a catalog audit report.
CatalogCombineInput
One catalog input passed to super::combine_catalogs.
CatalogCombineResult
Result returned by catalog combine operations.
CatalogCombineStats
Basic counters describing a catalog combine operation.
CatalogMessage
Public message representation returned by super::parse_catalog.
CatalogMessageExtra
Extra translator-facing metadata preserved on a catalog message.
CatalogMessageKey
Stable lookup key for catalog messages.
CatalogOrigin
File and line information for an extracted message origin.
CatalogStats
Basic counters describing an update operation.
CatalogUpdateResult
Result returned by catalog update operations.
CombineCatalogOptions
Options for combining multiple catalogs into one deterministic catalog.
CompileCatalogArtifactOptions
Options controlling high-level compiled catalog artifact generation.
CompileCatalogOptions
Options controlling runtime catalog compilation.
CompileSelectedCatalogArtifactOptions
Options controlling selected-subset compiled catalog artifact generation.
CompiledCatalog
Runtime-oriented lookup structure compiled from a normalized catalog.
CompiledCatalogArtifact
Host-neutral compiled runtime artifact for one requested locale.
CompiledCatalogDiagnostic
Diagnostic emitted by super::compile_catalog_artifact.
CompiledCatalogIdDescription
Metadata describing one compiled runtime ID for a specific catalog set.
CompiledCatalogIdIndex
Stable compiled runtime ID index built from one or more normalized catalogs.
CompiledCatalogMissingMessage
Missing-message record emitted by super::compile_catalog_artifact.
CompiledCatalogUnavailableId
Known compiled runtime ID that was not present in the provided catalog set.
CompiledMessage
A compiled runtime message keyed by a derived lookup key.
DescribeCompiledIdsReport
Report returned by CompiledCatalogIdIndex::describe_compiled_ids.
Diagnostic
Non-fatal issue collected while parsing or updating catalogs.
ExtractedPluralMessage
Structured plural message input used by catalog update operations.
ExtractedSingularMessage
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.
IcuCompatibilityOptions
Options controlling ICU source/translation compatibility checks.
IcuCompatibilityReport
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.
IcuParseError
Error returned when parsing ICU messages fails.
IcuParserOptions
Options controlling ICU parsing behavior.
IcuPluralSummary
One cardinal or ordinal plural expression discovered in an ICU message.
IcuPosition
Byte offset plus line/column location inside the original input.
IcuSelectSummary
One select expression discovered in an ICU message.
IcuTagSummary
One rich-text tag discovered in an ICU message.
MergeExtractedMessage
Borrowed extracted message input for the lightweight merge helper.
MessageArgumentFormatMetadata
Formatter metadata attached to an argument.
MessageArgumentMetadata
Normalized semantic metadata for one message argument.
MessageMetadata
Normalized semantic metadata for one source message.
MessageMetadataDiagnostic
One diagnostic emitted while validating semantic message metadata.
MessageMetadataInput
Authoring input for semantic message metadata.
MessageMetadataValidationReport
Report returned by validate_message_metadata.
MessageOriginMetadata
Extraction origin attached to semantic message metadata.
MessageSelectorMetadata
Selector metadata attached to a selecting argument.
MsgStrIter
Iterator over MsgStr values.
NormalizedParsedCatalog
Parsed catalog with fast key-based lookup helpers.
ParseCatalogOptions
Options for parsing a catalog into the higher-level message model.
ParseError
Error returned when parsing or unescaping PO content fails.
ParsedCatalog
Parsed catalog plus diagnostics and normalized headers.
PluralSource
Source-side plural forms for structured catalog messages.
PoFile
An owned PO document.
PoItem
A single gettext message entry.
SerializeOptions
Options controlling PO serialization.
SourceExtractedMessage
Source-first extractor input that lets ferrocat infer plural structure.
UpdateCatalogFileOptions
Options for updating a catalog file on disk.
UpdateCatalogOptions
Options for in-memory catalog updates.

Enums§

ApiError
Error returned by catalog parsing and update APIs.
BorrowedMsgStr
Borrowed translation payload for a PO item.
CatalogCombineSelection
Selection rule used after definitions from all inputs have been counted.
CatalogConflictStrategy
Strategy used when multiple catalogs define conflicting translations for one identity.
CatalogStorageFormat
Storage format used by the high-level catalog API.
CatalogUpdateInput
Input payload accepted by catalog update operations.
CompiledCatalogTranslationKind
High-level translation kind associated with a compiled runtime ID.
CompiledKeyStrategy
Built-in key strategy used when compiling runtime catalogs.
CompiledTranslation
Translation value stored in a compiled runtime catalog.
DiagnosticSeverity
Severity level attached to a Diagnostic.
EffectiveTranslation
Owned translation value materialized from a parsed catalog.
EffectiveTranslationRef
Borrowed view over a message translation.
ExtractedMessage
Structured extractor input accepted by super::update_catalog and super::update_catalog_file.
IcuArgumentKind
Broad role of an ICU argument in a parsed message.
IcuDiagnosticSeverity
Severity level attached to ICU authoring diagnostics.
IcuErrorKind
High-level classification of ICU parse failures.
IcuNode
AST node emitted by the ICU parser.
IcuPluralKind
Distinguishes cardinal and ordinal plural forms.
IcuStyleKind
Classification of an optional formatter style segment.
MessageArgumentKind
Broad argument kind used by semantic message metadata.
MessageArgumentMetadataInput
Progressive authoring input for one argument.
MessageFormatStyleKind
Classification of a message formatter style.
MessageSelectorKind
Selector kind used by semantic message metadata.
MsgStr
Message translation payload for a PO item.
ObsoleteStrategy
Strategy used for messages that disappear from the extracted input.
OrderBy
Sort order used when writing output catalogs.
PlaceholderCommentMode
Controls whether placeholder hints are emitted as extracted comments.
PluralEncoding
Encoding used for plural messages in PO files.
TranslationShape
Public translation shape returned from parsed catalogs.

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.
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_selected
Compiles one requested-locale runtime artifact for a selected subset of compiled IDs.
compiled_key
Derives the default stable runtime lookup key for msgid and msgctxt.
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 true when the message contains a cardinal plural expression.
has_select
Returns true when the message contains a select expression.
has_select_ordinal
Returns true when the message contains an ordinal plural expression.
has_selectordinal
Returns true when the message contains an ordinal plural expression.
has_tag
Returns true when the message contains rich-text style tags.
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 MessageFormat input with the default parser options.
parse_icu_with_options
Parses ICU MessageFormat input with explicit parser options.
parse_po
Parses PO content into the owned PoFile representation.
parse_po_borrowed
Parses PO content into a borrowed representation.
stringify_po
Serializes a PoFile back 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 MessageFormat input without returning the parsed AST.
validate_message_metadata
Validates progressive semantic message metadata against its msgid.