Skip to content

Commit

Permalink
Create basic usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
Mintype committed Apr 6, 2024
1 parent d3ae58a commit 765b8af
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/basic_usage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use rust_translate::{translate, translate_to_english, translate_from_english};

#[tokio::main]
async fn main() {
// Translate text from any language to any other language
let translated_text = translate("Bonjour le monde!", "fr", "en").await.unwrap();
println!("Translated text: {}", translated_text);

// Translate text to English
let english_text = translate_to_english("Bonjour le monde!").await.unwrap();
println!("Translated to English: {}", english_text);

// Translate text from English to any other language
let spanish_text = translate_from_english("Hello, world!", "es").await.unwrap();
println!("Translated to Spanish: {}", spanish_text);
}

0 comments on commit 765b8af

Please sign in to comment.