Expand description
§LangWeave
Detect text languages. Translate between language pairs. Build internationalized Rust applications.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
§Status
Experimental — This library is under active development. API may change in future versions.
| Version | Status | Notes |
|---|---|---|
| 0.0.x | Experimental | API subject to change |
| 0.1.x | Beta (planned) | API stabilization |
| 1.0.x | Stable (planned) | Stable API, semver guarantees |
§Features
- Language Detection — Identify text languages across 15 supported languages including English, French, German, Spanish, Portuguese, Italian, Dutch, Russian, Arabic, Hebrew, Hindi, Japanese, Korean, Chinese, and Indonesian
- Translation Engine — Translate between supported language pairs
- Error Handling — Comprehensive error types for robust applications
- Async Support — Non-blocking language detection and translation
- Simple API — Easy-to-use functions for common tasks
- Safety — Built with
#![forbid(unsafe_code)]in library code
§Installation
Add to Cargo.toml:
[dependencies]
langweave = "0.0.2"§Requirements
- MSRV: Rust 1.87.0 or later
§Feature Flags
| Feature | Description | Default |
|---|---|---|
default | No optional features enabled | ✅ |
async | Enable async utilities for non-blocking operations | ❌ |
Enable features in Cargo.toml:
[dependencies]
langweave = { version = "0.0.2", features = ["async"] }§Quick Start
Detect language and translate text:
use langweave::{detect_language, translate};
use langweave::error::I18nError;
fn main() -> Result<(), I18nError> {
// Detect language using the high-level API
let lang = detect_language("Hello, world!")?;
println!("Detected: {}", lang);
// Translate text
let translated = translate("fr", "Hello")?;
println!("Translated: {}", translated);
Ok(())
}§Examples
Run examples:
cargo run --example <example_name>§Known Limitations
- Short text detection — Very short texts (< 10 characters) may not have enough signal for accurate language detection
- Mixed-language content — Text containing multiple languages may only detect the dominant language
- Romanized scripts — Languages written in non-native scripts (e.g., Japanese in romaji) may not be detected correctly
- Translation coverage — Not all phrases have translations; the library falls back to the original text for unknown keys
§Documentation
Browse complete API reference at docs.rs/langweave.
§Contributing
Read Contributing Guidelines before submitting changes.
§License
Choose either Apache 2.0 or MIT license.
🎨 Designed by Sebastien Rousseau — https://sebastienrousseau.com/ 🚀 Engineered with Euxis — Enterprise Unified eXecution Intelligence System — https://euxis.co/
Modules§
- async_
utils - Asynchronous utilities for language processing.
- error
- The
errormodule contains error types used by the library. - language_
detector - The
language_detectormodule contains a simple regex-based language detector. - language_
detector_ trait - The
language_detector_traitmodule contains theLanguageDetectorTraittrait for extensibility. - optimized
- The
optimizedmodule contains zero-cost abstraction performance optimizations. - prelude
- A module that re-exports commonly used items for convenience.
- translations
- The
translationsmodule contains translation functions for different languages. - translator
- The
translatormodule contains a simple translation service using a predefined dictionary.
Constants§
- VERSION
- The current version of the langweave library.
Functions§
- detect_
language - Detects the language of a given text synchronously.
- detect_
language_ async - Detects the language of a given text asynchronously.
- is_
language_ supported - Validates if a given language code is supported.
- supported_
languages - Returns a list of supported language codes.
- translate
- Translates a given text to a specified language.