Skip to main content

Crate pockingbird

Crate pockingbird 

Source
Expand description

§pockingbird

Report-only library + CLI that finds duplicate translation keys across gettext .po catalogs.

§Library entry point

The one call you need is scan — point it at a directory and a Config and get back a Report:

use std::path::Path;
use pockingbird::{scan, Config};

let report = scan(Path::new("./locales"), &Config::default())?;
println!("{}", pockingbird::report::to_json(&report.groups, report.total_keys));

§Pipeline

walk → po → index → group → report
  • walk — discover .po files under the configured roots.
  • po — parse each catalog (polib) into keys and per-locale values; locale derives the locale id from the path.
  • index — build the KeyId × locale → Cell matrix; normalize and fuzzy canonicalize cells per tier.
  • group — tier-agnostic signature bucketing + leave-one-out over the canonical matrix → CandidateGroups.
  • report — render the groups as text (colored) or json.

These stages are crate-internal; scan wires them together. config holds the TOML schema and defaults that parameterize every stage.

Re-exports§

pub use config::Config;

Modules§

cli
CLI surface (clap derive): find <path> [knobs] and init [path]. Behind the cli feature. Exit code is always 0 (the tool reports, it does not gate). This is the thin shell around the crate::scan facade: it resolves config, renders progress to stderr, and writes the report to stdout — the pipeline run itself is the testable core.
config
TOML configuration schema (Config/Scan/Locales/Match/Normalize/ Output) plus defaults. Parameterizes every pipeline stage.
report
Render candidate groups as text (colored) or json, with identical structure.

Structs§

CandidateGroup
A reported duplicate-candidate group over one tier.
KeyId
Identity of a translatable key. domain is part of the identity, so messages.po:X and django.po:X are distinct keys. Hashable and ordered for stable, deterministic bucketing.
Report
The run’s data result. No timings, no formatting — rendering is the shell’s job.
Skip
A catalog that failed to parse. Recorded, never fatal.

Enums§

Cell
A key’s value in one locale.
Error
A failed scan: discovery, no input, or a pipeline error.
PipelineError
A run that could not produce a report at all (distinct from a skipped file).
PipelineEvent
A progress event emitted during a run. The vocabulary is here; the rendering is the sink’s.
PoError
WalkError

Traits§

ProgressSink
The one-method progress seam. Implement it to render, time, or record.

Functions§

scan
Scan a directory tree for duplicate translation keys across its .po catalogs — the one-call library entry point. Discovers files under root (overriding config.scan.roots), parses them, and runs the pipeline.
scan_with
Like scan, but drives a ProgressSink so callers can render progress.