translator 0.1.0+7 copy "translator: ^0.1.0+7" to clipboard
translator: ^0.1.0+7 copied to clipboard

outdated

A free and unlimited Google Translate API for Dart. You can use it for translate strings and text for educational purpose.

translator #

Free Google Translate API for Dart

See it in pub: https://pub.dartlang.org/packages/translator
and GitHub: https://github.com/gabrielpacheco23/google-translator

Usage #

void main() async {
  GoogleTranslator translator = new GoogleTranslator();

  String input = "Здравствуйте. Ты в порядке?";

  translator.translate(input, from: 'ru', to: 'en').then((s) {
    print(s);
  });
  // prints Hello. Are you okay?
  
  var translation = await translator.translate("Dart is very cool!", to: 'pl');
  print(translation);
  // prints Dart jest bardzo fajny!
}

Using translate method passing the args from and to designates the language from text you're typing and the language to be translated

translator.translate("I love Brazil!", from: 'en', to: 'pt').then((s) {
    print(s);
  }); 
  // prints Eu amo o Brasil!

or you can omit from language and it'll use auto key that auto-detect the language of source text

translator.translate("Hello", to: 'es').then((s) => print(s));
// prints Hola

and also pass the value to a var using await

var translation = await translator.translate("I would buy a car, if I had money.", from: 'en', to: 'it');
  print(translation);
// prints Vorrei comprare una macchina, se avessi i soldi.

There is translateAndPrint method that prints directly

translator.translateAndPrint("This means 'testing' in chinese", to: 'zh-cn');
// prints 这意味着用中文'测试'

API #

For full API docs take a look at https://pub.dartlang.org/documentation/translator/latest/

License #

MIT License

Copyright © 2018 Gabriel Pacheco

Disclaimer #

This package is developed for educational purposes only. Do not depend on this package as it may break anytime as it is based on crawling the Google Translate website. Consider buying Official Google Translate API for other types of usage.

666
likes
0
pub points
98%
popularity

Publisher

unverified uploader

A free and unlimited Google Translate API for Dart. You can use it for translate strings and text for educational purpose.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http

More

Packages that depend on translator