A Flutter plugin to use Google's ML Kit On-Device Translation to dynamically translate text between more than 50 languages.
Before you get started read about the requirements and known issues of this plugin here.
In order to use Google's on-device Translation API in your application, you need to comply with the following guidelines. These guidelines may change from time to time, and without prior notice from Google. Your continued use of the on-device Translation API is contingent upon your adherence to these guidelines. If you're uncomfortable with any of these branding guidelines, discontinue your use of the API and contact Google with your concerns. See more about the usage guidelines here.
ML Kit can translate between the following languages.
final TranslateLanguage sourceLanguage;
final TranslateLanguage targetLanguage;
final onDeviceTranslator = OnDeviceTranslator(sourceLanguage: sourceLanguage, targetLanguage: targetLanguage);
final String response = await onDeviceTranslator.translateText(text);
Make sure you download both source and target language models before translating any text.
onDeviceTranslator.close();
final modelManager = OnDeviceTranslatorModelManager();
final bool response = await modelManager.isModelDownloaded(TranslateLanguage.english.bcpCode);
final bool response = await modelManager.downloadModel(TranslateLanguage.english.bcpCode);
final bool response = await modelManager.deleteModel(TranslateLanguage.english.bcpCode);
Find the example app here.
Contributions are welcome. In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non trivial fixes. In case of trivial fixes open a pull request directly.