Git Product home page Git Product logo

translate's Introduction

translate

A simple to use Dart package, for detecting & translating text and html pages using Yandex.Translate API

Show some ❤️, by putting ⭐

This package is readily avaiable for use.

what does it do ?

  • Fetches list of languages along with language codes, supported by Yandex.Translate API
  • Detects which language given text belongs to
  • Translates text or html page to certain language, denoted by language code

How to use ?

First get yourself a Yandex.Translate API Key, which can be found here.

Fetch list of supported language :

Languages('api_key')
      .fetch()
      .then(
        (data) => print(data),
        onError: (e) => print(e),
      ).then((val) => exit(0));

supported_languages

Response in case of success,

{
    ru: 'Russian',
    en: 'English',
}

Response in case of error,

{
    error: ' ... '
}

Detect language of text :

DetectIt('api_key')
      .detect('Hello World', hint: [
        'en',
        'de',
        'ru',
        'hi',
      ]) // hints are to be prioritized by platform while detecting language, if provided
      .then(
        (data) => print(data),
        onError: (e) => print(e),
      )
      .then((val) => exit(0));

detect_language

Response in case of success,

{
    lang: 'en'
}

Response in case of error,

{
    error: ' ... '
}

Translate Text :

TranslateIt('api_key')
      .translate(
          '<!DOCTYPE html><html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>',
          'en-ru', // only `ru` will also do same job
          type: 'html') // type is `html`, cause this text is markedup
      .then(
        (data) => print(data),
        onError: (e) => print(e),
      )
      .then((val) => exit(0));
English Russian
html_page_in_english html_page_in_russian

Response in case of success,

{
    text: ' ... '
}

Response in case of error,

{
    error: ' ... '
}

Courtesy :

Translation API is powered by Yandex.Translate, so all thanks goes to them.

If you're interested in learning more about T&C, take a look here.

You can also go for priced version.

Hoping, it was helpful 😉

translate's People

Contributors

itzmeanjan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cjh0613

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.