Init commit
This commit is contained in:
commit
3a9f283e99
13 changed files with 418 additions and 0 deletions
25
README.md
Normal file
25
README.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Autolingual
|
||||
|
||||
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.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```rs
|
||||
use autolingual::{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;
|
||||
// ...
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue