Expand description
Provides a lightweight wrapper for the DeepL Pro REST API.
If you are looking for the deepl commandline utility, please refer
to its documentation instead.
Requirements
You need to have a valid DeepL Pro Developer account with an associated API key. This key must be made available to the application, e. g. via environment variable:
export DEEPL_API_KEY=YOUR_KEYExample
use deepl_api::*;
// Create a DeepL instance for our account.
let deepl = DeepL::new(std::env::var("DEEPL_API_KEY").unwrap());
// Translate Text
let texts = TranslatableTextList {
source_language: Some("DE".to_string()),
target_language: "EN-US".to_string(),
texts: vec!("ja".to_string()),
};
let translated = deepl.translate(None, texts).unwrap();
assert_eq!(translated[0].text, "yes");
// Fetch Usage Information
let usage_information = deepl.usage_information().unwrap();
assert!(usage_information.character_limit > 0);See Also
The main API functions are documented in the DeepL struct.
Structs
The main API entry point representing a DeepL developer account with an associated API key.
The Error type.
Representation of a glossary.
Information about a single language.
Holds a list of strings to be translated.
Holds one unit of translated text.
Information about API usage & limits for this account.
Enums
The kind of an error.
Translation option that controls the desired translation formality.
Format of glossary entries when creating a glossary.
Translation option that controls the splitting of sentences before the translation.
Traits
Additional methods for
Result, for easy interaction with this crate.Type Definitions
Information about available languages.
Convenient wrapper around
std::Result.