Crate langweave

Crate langweave 

Source
Expand description

LangWeave logo

§LangWeave

A powerful Rust library for seamless internationalization and localization.

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

WebsiteDocumentationReport BugRequest FeatureContributing Guidelines

§Overview

langweave is a robust Rust library that provides efficient internationalization and localization capabilities. Designed for applications requiring multi-language support, it offers fast language detection, fluid translations, and intuitive multilingual content management.

§Features

  • Instant Language Detection: Quickly identify the language of input text.
  • Efficient Translation: Translate text between multiple languages.
  • Flexible Content Management: Easily manage and retrieve localized content.
  • Performance Optimized: Utilizes efficient algorithms for fast processing.
  • Comprehensive Language Support: Handles a wide range of languages, including non-Latin scripts.
  • Error Handling: Robust error management for reliable operation.

§Installation

Add langweave to your Cargo.toml:

[dependencies]
langweave = "0.0.1"

§Usage

Here’s a basic example of how to use langweave:

use langweave::language_detector::LanguageDetector;
use langweave::error::I18nError;
use langweave::language_detector_trait::LanguageDetectorTrait;

#[tokio::main]
async fn main() -> Result<(), I18nError> {
    // Create a new language detector
    let detector = LanguageDetector::new();

    // Detect language
    let lang = detector.detect_async("Hello, world!").await?;
    println!("Detected language: {}", lang);

    // Use the detected language for further processing
    // (e.g., translation, localization)

    Ok(())
}

This example demonstrates how to use LangWeave to detect the language of a given text.

§Documentation

For full API documentation, please visit docs.rs/langweave.

§Examples

To explore more examples, clone the repository and run the following command:

cargo run --example example_name

§Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

§License

This project is licensed under either of

at your option.

§Acknowledgements

Special thanks to all contributors who have helped build the langweave library.

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.
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 using the composite language detector.
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.