Skip to main content

subx_cli/core/translation/
mod.rs

1//! Core subtitle translation engine.
2//!
3//! The translation engine sits above the existing [`crate::core::formats`]
4//! pipeline. It parses subtitle files into the shared
5//! [`crate::core::formats::Subtitle`] data model, builds AI translation
6//! requests with stable `UUIDv7` cue IDs, validates AI responses, and
7//! reapplies translated text back to the parsed entries while preserving
8//! timing, cue ordering, cue counts, and metadata supported by the format
9//! parser/writer pipeline.
10//!
11//! # Why UUIDv7 cue IDs?
12//!
13//! UUIDv7 IDs encode their generation order via the `unix_time_ts` field,
14//! which makes batch logs, retries, and post-mortem auditing easier than
15//! UUIDv4. The engine intentionally spaces adjacent cue ID generations by at
16//! least 1 millisecond so each ID's `unix_time_ts` is strictly greater than
17//! the previous cue ID timestamp, preventing same-millisecond ambiguity.
18//!
19//! # Module layout
20//!
21//! - [`request`] - request/response data structures.
22//! - [`engine`] - high-level [`engine::TranslationEngine`].
23//!
24//! The UUIDv7 cue ID generator lives in [`crate::core::uuidv7`] and is
25//! re-exported below for backward compatibility with the original
26//! `core::translation::uuidv7` public path.
27
28pub mod engine;
29pub mod request;
30
31/// Backward-compatibility shim for the original
32/// `subx_cli::core::translation::uuidv7` module path.
33///
34/// The UUIDv7 generator was relocated to [`crate::core::uuidv7`] when it
35/// became a shared dependency of the matcher and parallel layers; this
36/// shim preserves the old import path for downstream code that still
37/// references `subx_cli::core::translation::uuidv7::CueIdGenerator`.
38pub mod uuidv7 {
39    pub use crate::core::uuidv7::{
40        Uuidv7Generator, Uuidv7Generator as CueIdGenerator, generate_ids,
41        generate_ids as generate_cue_ids, unix_time_ms,
42    };
43}
44
45pub use crate::core::uuidv7::{
46    Uuidv7Generator as CueIdGenerator, generate_ids as generate_cue_ids, unix_time_ms,
47};
48pub use engine::{TranslationEngine, parse_glossary_text};
49pub use request::{
50    GlossaryEntry, TerminologyEntry, TerminologyMap, TranslationBatch, TranslationCue,
51    TranslationOutcome, TranslationRequest, TranslationResult,
52};