rust-i18n-autotranslate

Crates.iorust-i18n-autotranslate
lib.rsrust-i18n-autotranslate
version0.1.7
created_at2026-01-11 12:12:23.286048+00
updated_at2026-01-20 19:09:21.905231+00
descriptionAuto translate locales build time and runtime
homepagehttps://github.com/razein97/rust-i18n-autotranslate
repositoryhttps://github.com/razein97/rust-i18n-autotranslate
max_upload_size
id2035668
size101,627
Rohit Singh (razein97)

documentation

https://docs.rs/rust-i18n-autotranslate

README

rust-i18n-autotranslate Crates.io

Auto translate locales build time and runtime.

Features

  • Tracks the source language file and only translates when it has changed.
  • Set cache = true to reuse already translated words.
  • Normalizes languages to a supported language if supported.

Current support

  • Google Translate (Cloud Translate - Fallback to google translate web)
  • DeepL (Cloud Translate - Fallback to deeplx)
  • DeepLX (Needs installation Install DeepLX)
  • LibreTranslate (Fallback - Install Self Hosted))
  • Yandex (Planned)
  • aws ML (Planned)

Install

use cargo:

cargo add rust-i18n-autotranslate

Add dependencies in your cargo.toml

[dependencies]
rust-i18n-autotranslate = "0.1"

The crate uses env variables to set the api key:

  • GOOGLE_API_KEY = "xyz"
  • DEEPL_FREE_API_KEY = "xyz"
  • DEEPL_PRO_API_KEY = "xyz"
  • LIBRE_TRANSLATE_API_KEY="xyz"

How to generate google api key

Call the translate function directly to translate your locales

use rust_i18n_autotranslate::{
    TranslationAPI,
    config::{Config, TranslationProvider},
};

fn main() {
    env_logger::init();

    let cfg = Config::new()
        .locales_directory("./locales")
        .source_lang("en")
        .add_target_lang("fr")
        .use_cache(true)
        .translation_provider(TranslationProvider::GOOGLE)
        .build();

    TranslationAPI::translate(cfg).unwrap()
}
Commit count: 15

cargo fmt