auto_translate_plugin 1.1.0
auto_translate_plugin: ^1.1.0 copied to clipboard
A premium Flutter plugin for seamless on-device text translation using Google ML Kit. Offline, privacy-first, and easy to integrate.
Auto Translate Plugin #
A powerful, seamless, and premium Flutter plugin for on-device and cloud-based text translation. Combine the speed and privacy of Google ML Kit with the vast language support of Google Cloud Translation API.
- 🌍 130+ Languages: Support for almost every language on earth via Cloud API.
- 🇮🇳 Full Indian Language Support: Tamil, Hindi, Telugu, Malayalam, Kannada, Marathi, Gujarati, Bengali, Urdu, and more.
- 🚀 Hybrid Mode: Automatic fallback to Cloud if offline model is unavailable.
- 🔒 Privacy-First: Uses On-Device ML by default for supported languages.
🚀 Features #
- 🌍 On-Device Translation: Powered by Google ML Kit for offline processing and user privacy.
- ⚡ Seamless Integration: Replace standard
Textwidgets withAutoTranslateTexteffortlessly. - 🔄 Reactive State Management: Built-in
TranslatorProvider(usingprovider) automatically updates all text widgets when the language changes. - 📦 Smart Model Management: Automatically handles initialization and cleanup of translation models.
- 🛠️ Customizable: Full support for text styling, alignment, and standard
Textwidget properties.
📦 Getting Started #
1. Add dependency #
Add auto_translate_plugin and provider to your pubspec.yaml:
dependencies:
auto_translate_plugin: ^1.0.1
provider: ^6.1.5
2. Platform Setup #
Android
The plugin requires internet access only for downloading the language models initially. Ensure you have the following in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
iOS
ML Kit requires a minimum deployment target of 15.5 or higher. Update your Podfile:
platform :ios, '15.5'
🛠️ Usage #
1. Initialize the Provider #
Wrap your application with ChangeNotifierProvider to enable global language management.
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:auto_translate_plugin/auto_translate_plugin.dart';
void main() {
final provider = TranslatorProvider();
// Optional: Setup Google Cloud Translation for 130+ languages fallback
provider.setupCloud(
apiKey: 'YOUR_GOOGLE_CLOUD_API_KEY',
useCloudOnly: false, // Set to true to bypass ML Kit
);
runApp(
ChangeNotifierProvider.value(
value: provider,
child: const MyApp(),
),
);
}
2. Use AutoTranslateText #
Simply replace your Text widgets with AutoTranslateText. It will listen to the TranslatorProvider and update automatically.
AutoTranslateText(
'Hello, welcome to our world-class application!',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.normal),
textAlign: TextAlign.center,
)
3. Change Language Dynamically #
Switch the entire app's language from anywhere in your code using the TranslatorProvider.
// Switch to Tamil
context.read<TranslatorProvider>().changeLanguage('ta');
// Switch to Hindi
context.read<TranslatorProvider>().changeLanguage('hi');
// Switch back to English
context.read<TranslatorProvider>().changeLanguage('en');
🌐 Supported Languages #
📱 On-Device (Fast & Free) #
Specifically optimized for:
- 🇮🇳 Tamil (
ta), Hindi (hi), Telugu (te), Malayalam (ml), Kannada (kn), Marathi (mr), Gujarati (gu), Bengali (bn), Urdu (ur) - 🇺🇸 English (
en- default)
☁️ Cloud (Vast & Accurate) #
- Supports 130+ languages worldwide.
- Requires a Google Cloud API Key.
- Perfect for production-ready apps requiring maximum accuracy.
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.