Basic API request to DeepL

This commit is contained in:
Markus Scully 2024-12-04 19:44:20 +02:00
parent 3a9f283e99
commit d2892b1f82
12 changed files with 1401 additions and 70 deletions

View file

@ -1,25 +1,22 @@
# Autolingual
# Endolingual
Procedural macros in Rust can execute arbitrary code at compile time, even performing network requests. This has potentially terrifying security implications, but we'll use it to our advantage!
Autolingual is a Rust macro which automatically translates strings of natural language text into multiple foreign languages at once at compile time. The produced translations are `&'static str` values, so they are very lightweight.
Endolingual is a Rust macro which translates strings of natural language text into multiple foreign languages at once by making API requests at compile time. The produced translations are `&'static str` values, so they are very lightweight.
## Examples
```rs
use autolingual::{translate, TranslationSet};
use endolingual::{translate, TranslationSet};
// No context
let button_text_french: &str = translate!("Sign up").fr;
// With context (context will not show up in the final translation)
let button_text_french: &str = translate!("Sign up", "A button for creating a user account.").fr;
// Every supported language at once.
let translation_set: TranslationSet = translate!("Hello!");
let french = translation_set.fr;
let german = translation_set.de;
let portuguese = translation_set.pt;
// ...
```
## Usage
Set the environment variable `DEEPL_API_KEY` to your [DeepL API](https://developers.deepl.com/docs) key. Only DeepL is supported at the moment.
This library is still experimental and in the early stages of development.