solmood_translator 1.0.1
solmood_translator: ^1.0.1 copied to clipboard
Free Google translation API for Dart.
Solmood Translator #
Free Google Translate API for Dart
See github https://github.com/KalybosPro/solmood_translator
Usage #
Run this command:
flutter pub add solmood_translator
Or, add the following to your pubspec.yaml file:
dependences:
solmood_translator: ^1.0.0
void main()async{
final engine = SolmoodTranslatorEngine();
const text = "Hello world";
// Using the future API
engine.translate(text, to: "fr").then((trans) => print("Source text: $text\nTranslated text: $trans"));
print(await "I like to code".translate(to: "fr"));
// prints J'aime coder
}
Using translate method passing the args from and to designates the language from text you're typing and the language to be translated
engine.translate("Prodia is revolutionizing the way AI is integrated into various software applications", from: 'en', to: 'pt').then((s) {
print(s);
});
// prints Prodia está revolucionando a maneira como a IA é integrada a vários aplicativos de software
or you can omit from language and it'll auto-detect the language of source text
engine.translate("Hello world", to: 'es').then(print);
// prints Hola Mundo
and also pass the value to a var using await
var translation = await translator.translate("Je suis un développeur Flutter.", from: 'fr', to: 'it');
print(translation);
// prints Sono uno sviluppatore Flutter.
API #
For full API docs take a look at https://pub.dev/documentation/solmood_translator/latest/
License #
MIT License
Copyright © 2021 Kalybos Prosper K. A.