Skip to content

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

License

Notifications You must be signed in to change notification settings

itzmeanjan/translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 😉

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages