No description
Find a file
2024-11-14 22:53:41 +00:00
autolingual Init commit 2024-11-14 22:53:41 +00:00
autolingual-macro Init commit 2024-11-14 22:53:41 +00:00
.envrc Init commit 2024-11-14 22:53:41 +00:00
.gitignore Init commit 2024-11-14 22:53:41 +00:00
Cargo.lock Init commit 2024-11-14 22:53:41 +00:00
Cargo.toml Init commit 2024-11-14 22:53:41 +00:00
devenv.lock Init commit 2024-11-14 22:53:41 +00:00
devenv.nix Init commit 2024-11-14 22:53:41 +00:00
devenv.yaml Init commit 2024-11-14 22:53:41 +00:00
LICENSE Init commit 2024-11-14 22:53:41 +00:00
README.md Init commit 2024-11-14 22:53:41 +00:00

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

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;
// ...