Git Product home page Git Product logo

aiotranslator's Introduction

Rust Text Translation Library

This Rust library provides a simple and easy-to-use interface for translating text. It can be used to chain translations, translate with different translators, and use a special translator based on the detected language. The library currently supports translation methods that involve making API requests to sites like Bing Translate, Google Translate, and other online translators.

Features

  • whatlang-detector
  • lingua-detector
  • all-detectors

  • retries

  • deepl
  • mymemory
  • chatgpt
  • libre
  • api

  • papago-scrape
  • google-scrape
  • youdao-scrape
  • edge-gpt-scrape
  • baidu-scrape
  • bing-scrape
  • scraper

  • online

Usage

Heres an example how to translate text from unkown language to english. When the detec.ted language is chinese it uses the papago translator. When the language isnt defined it uses the default translator which is google in this case

fn main() {
    dotenv().ok();
    let mut hashmap = HashMap::new();
    hashmap.insert(Language::Chinese, Translator::Papago);
    let selector = TranslatorSelectorInfo::Selective(
        hashmap,
        TranslatorInfo {
            translator: Translator::Google,
            to: Language::English,
        },
    );
    let v = Translators::new(
        Some(Tokens::get_env().unwrap()),
        selector,
        None,
        Some(3),
        Detectors::Whatlang,
    )
        .await
        .unwrap();
    let chatgpt_context = Context::ChatGPT("This is a text about ...".to_string());
    let translation = v.translate("Hello world".to_string(), None, &[chatgpt_context]).await.unwrap();
    let translations = v.translate_vec(vec!["Hello world".to_string(), "This is a test".to_string()], None, &[]).await.unwrap();
    println!("{:?}, {:?}", translation, translations);
}

The detector could be used seperatly like this: Online detectors will be implemented oin the future

let text = "Hallo Welt";
let lang = detector::detect_language(text, & Detectors::Whatlang).unwrap();
println!("{:?}", lang);

Supported Translators

๐Ÿ”ด = Offline, ๐ŸŒ๏ธ = Online, โœ”๏ธ = Supported, โฑ๏ธ = not implemented yet, โŒ = does not exist, โ“ = WIP

Translator Kind Scraped API Note
Baidu Translate ๐ŸŒ๏ธ โœ”๏ธ โ“๏ธ
Bing Translate ๐ŸŒ๏ธ โœ”๏ธ โฑ๏ธ
ChatGPT ๐ŸŒ๏ธ โœ”๏ธ โœ”๏ธ
Google Translate ๐ŸŒ๏ธ โœ”๏ธ โ“
Papago ๐ŸŒ๏ธ โœ”๏ธ โ“
Youdao ๐ŸŒ๏ธ โœ”๏ธ โ“
Libretranslate ๐ŸŒ๏ธ โŒ โœ”๏ธ
Mymemory ๐ŸŒ๏ธ โŒ โœ”๏ธ
Deepl ๐ŸŒ๏ธ โฑ๏ธ โœ”๏ธ
M2M100 ๐Ÿ”ด๏ธ โŒ๏ธ ๏ธ โŒ Converted 05/13/23
JParaCrawl ๐Ÿ”ด๏ธ ๏ธ โŒ ๏ธโŒ V3
Sugoi [online] ๐Ÿ”ด๏ธ โฑ๏ธ๏ธ โŒ๏ธ V4 / Support the creator
Nllb ๐Ÿ”ด๏ธ ๏ธ โŒ ๏ธโŒ Converted 05/13/23

Supported Languages

The supported languages can be found in languages.csv. This file is used to generate languages.rs. missing contains the languages that are missing in languages.csv(languages i didn't find a name for)

Contributing

If you find a bug or have an idea for a new feature, feel free to open an issue or submit a pull request. We welcome contributions from the community!

aiotranslator's People

Contributors

dependabot[bot] avatar justfrederik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.