Skip to main content

Crate globetrotter

Crate globetrotter 

Source
Expand description

Polyglot, type-safe internationalization.

This crate parses globetrotter configuration files, reads translation sources, validates them, and generates JSON output. The typescript and rust features add typed bindings; golang and python currently expose configuration targets without emitters.

Feature flags select language-specific generators: typescript, rust, golang, and python. The llm-judge feature adds optional semantic-drift review during linting. The optional tree-sitter feature adds syntax-aware source usage scanning. Without it, usage scanning uses less precise text matching.

The same builder API used by the CLI is available for build scripts and other programmatic integrations:

use globetrotter::{
    Executor, Language,
    config::v1::{Config, ConfigFile, Input, JsonOutputConfig, Outputs},
    diagnostics::Printer,
};

let config = Config::new("app")
    .with_languages([Language::En, Language::De])
    .with_input(Input::new("translations.toml"))
    .with_outputs(
        Outputs::new().with_json([JsonOutputConfig::new(
            "generated/translations_{{language}}.json",
        )]),
    );
let configs: Vec<ConfigFile<usize>> = vec![ConfigFile {
    file_id: None,
    config_dir: None,
    config,
}];
let executor = Executor::new(&configs, Printer::default());
executor.execute(configs).await?;

Re-exports§

pub use error::Error;
pub use executor::Executor;
pub use globetrotter_typescript as typescript;
pub use globetrotter_rust as rust;
pub use globetrotter_golang as golang;
pub use globetrotter_python as python;
pub use globetrotter_model as model;

Modules§

config
Configuration file discovery, parsing, and versioned schema types. Configuration discovery, version selection, and schema parsing.
dead_keys
Detection of translation keys unused in a source tree. Detects translation keys without references in their owning source roots.
diagnostics
Diagnostic rendering and source-file management. Concurrent diagnostic rendering backed by a shared source-file registry.
error
Error types surfaced while loading and generating outputs. Errors produced while loading, validating, and generating translations.
executor
Orchestration of translation loading, validation, and output generation. Translation loading, validation, linting, and output orchestration.
gzip
Gzip size estimation for generated JSON outputs. In-memory gzip size calculation for generated output reporting.
json
JSON translation output generation. Per-language JSON output generation and output-path templating.
llm_judge
LLM-judged translation-consistency review during linting. Adapter between globetrotter’s translation model and the globetrotter_llm_judge crate.
progress
Progress logging and output path formatting. Alignment and path display for human-readable progress output.
target
Code generation targets and their per-target output errors. Typed-language output generation selected by Cargo features.

Structs§

Translation
A single translation entry: its per-language strings and template arguments.
Translations
A collection of translations, keyed by their dotted key path.

Enums§

Language
A language identified by an ISO 639-1 two-letter code.