charl1e7 / rust-translators

Free Google Translator, Deepl without API key and limits.
MIT License
4 stars 0 forks source link

translators Crates.io License

translators is an async/sync library for Google Translator with no API key and no limits. It also includes support for proxy.

Questions:

Features flags

Examples

1. Async example

use translators::{GoogleTranslator, Translator};

#[tokio::main]
async fn main() {
    let google_trans = GoogleTranslator::default();
    let res = google_trans
        .translate_async("Hello, world!", "", "es")
        .await
        .unwrap();
    println!("{res}");
}

Add to the dependency:

[dependencies]
translators = { version = "0.1.3", features = ["google", "tokio-async"] }
tokio = { version = "1.38.0", features = ["rt-multi-thread"] }

2. Sync example

use translators::{GoogleTranslator, Translator};

fn main() {
    let google_trans = GoogleTranslator::default();
    let res = google_trans
        .translate_sync("Hello, world!", "", "es")
        .unwrap();
    println!("{res}");
}

Add to the dependency:

[dependencies]
translators = { version = "0.1.3", features = ["google"] }

3. Proxy and custom config

let google_trans = GoogleTranslator::builder()
    .timeout(35 as u64) // How long to wait for a request in seconds
    .delay(120 as u64) //How long to wait for a request in milliseconds
    .proxy_address("http://user:password@0.0.0.0:80") // delete the line if you don't need proxy
    .build();

What's New in Version 0.1.3

Additional Information

For more details, guides, and advanced usage, please refer to the examples and official documentation.