Search packages, repositories and app categories

Package detailsv1.0.4+1

translator

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

AndroidiOSWebmacOSWindowsLinux
30-day downloads
3.9K
Likes
746
Pub points
150

Install package

flutter pub add translator

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The translator package provides a free and unlimited Google Translate API for Dart, enabling developers to translate strings and text across multiple languages. Designed for educational purposes, it integrates seamlessly into Flutter apps on Android, iOS, Web, macOS, Windows, and Linux. The package leverages the Google Translate web interface without requiring an API key, making it accessible and easy to use. It supports basic translation functionality with minimal setup, ideal for learning or prototyping multilingual applications.

Use cases

  • Translating app content in real-time
  • Educational language learning tools
  • Prototyping multilingual interfaces
  • Simple text translation in Flutter apps
  • Cross-language communication features

Key features

  • No API key required
  • Supports multiple platforms
  • Free and unlimited usage
  • Easy integration with Flutter
  • Built for educational use
  • Real-time text translation

Suitable for

  • Beginner Flutter developers
  • Educational projects
  • Non-commercial applications
  • Rapid prototyping
  • Apps needing basic translation

Considerations

  • Not suitable for production with high traffic
  • Relies on web scraping (may break with updates)
  • Limited to Google Translate's supported languages
  • No official API guarantees
  • Rate limits may apply indirectly through website behavior

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

translator

Free Google Translate API for Dart

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

ko-fi

Usage

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

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

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

  print(await "example".translate(to: 'pt'));
  // prints exemplo
}

 

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 auto-detect the language of source text

translator.translate("Hello", to: 'es').then(print);
// 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.

 

The returned value is a Translation object which holds the translation stuff

var translation = await translator.translate('Translation', from: 'en', to: 'es');
print('${translation.source} (${translation.sourceLanguage}) == ${translation.text} (${translation.targetLanguage})');

// prints Translation (English) == Traducción (Spanish)

 

You can use the extension method directly on the string too

print(await "example".translate(to: 'pt'));
// prints exemplo

 

There is translateAndPrint method that prints directly

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

 

TranslatedText Widget

Moved TranslatedText widget to https://github.com/gabrielpacheco23/translated_text

API

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

Support my work :)

ko-fi

License

MIT License

Copyright © 2021 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.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package