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
google
- add support google-translatetokio-async
- add support asyncuse 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"] }
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"] }
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();
For more details, guides, and advanced usage, please refer to the examples and official documentation.