Skip to main content

Crate langweave

Crate langweave 

Source
Expand description

§LangWeave

LangWeave logo

Detect text languages. Translate between language pairs. Build internationalized Rust applications.

Made With Love Crates.io lib.rs Docs.rs Codecov Build Status GitHub

WebsiteDocumentationReport BugRequest FeatureContributing Guidelines

§Status

Experimental — This library is under active development. API may change in future versions.

VersionStatusNotes
0.0.xExperimentalAPI subject to change
0.1.xBeta (planned)API stabilization
1.0.xStable (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

FeatureDescriptionDefault
defaultNo optional features enabled
asyncEnable 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 error module contains error types used by the library.
language_detector
The language_detector module contains a simple regex-based language detector.
language_detector_trait
The language_detector_trait module contains the LanguageDetectorTrait trait for extensibility.
optimized
The optimized module contains zero-cost abstraction performance optimizations.
prelude
A module that re-exports commonly used items for convenience.
translations
The translations module contains translation functions for different languages.
translator
The translator module 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.