flutter_translate_kit π
The only Flutter localization package you'll ever need.
β No API keys | β Works offline | β 50+ languages | β CLI auto-wraps your entire app | β RTL auto-support
Why flutter_translate_kit?
| Feature | Other packages | flutter_translate_kit |
|---|---|---|
| No API key needed | β Requires key | β Never needed |
| Works offline | β | β On-device ML |
| CLI auto-wrap | β | β One command |
| RTL auto-detect | β | β Built-in |
| Smart caching | β | β Hive-powered |
No .arb files |
β Required | β Never needed |
Quick Start
1. Install
# pubspec.yaml
dependencies:
flutter_translate_kit: ^0.0.1
2. Initialize in main.dart
import 'package:flutter_translate_kit/flutter_translate_kit.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await TranslationService().init(
targetLanguage: TranslateLanguage.hindi, // π Set your language
);
runApp(const MyApp());
}
3. Wrap your MaterialApp and add the language-change overlay
Use KitLanguageChangeOverlay so users see a loading screen until all text has updated after switching language (avoids half-translated UI):
import 'package:flutter_translate_kit/flutter_translate_kit.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return KitScope(
builder: (locale, delegates) => MaterialApp(
locale: locale,
localizationsDelegates: delegates,
supportedLocales: KitScope.supportedLocales,
home: KitLanguageChangeOverlay(
child: HomeScreen(),
),
),
);
}
}
4. Use KitText instead of Text
// Before
Text('Welcome to the app')
// After
KitText('Welcome to the app') // auto-translates to Hindi β
CLI β Auto-wrap your entire project
For large existing apps, use the CLI to automatically replace every Text() with KitText():
# Install globally (after publishing to pub.dev)
dart pub global activate flutter_translate_kit
# Or activate locally during development
dart pub global activate --source path .
# Preview what will change (no files touched)
ftk wrap --dry-run
# Apply to all files
ftk wrap
# Check your coverage
ftk stats
# Undo if needed
ftk restore
Before:
Text('Welcome')
Text('Settings', style: TextStyle(fontSize: 16))
Text(myVariable)
After (auto-generated):
KitText('Welcome')
KitText('Settings', style: TextStyle(fontSize: 16))
KitText(myVariable)
Features
Switch Language at Runtime
// Switch to any of 50+ languages instantly
await TranslationService().setLanguage(TranslateLanguage.arabic);
await TranslationService().setLanguage(TranslateLanguage.french);
await TranslationService().setLanguageByCode('de'); // by BCP-47 code
Language preference is persisted β survives app restarts automatically.
Loading overlay when changing language
Wrap your app content with KitLanguageChangeOverlay (see Quick Start step 3). When the user switches language, a full-screen loading overlay is shown until all visible KitText widgets have finished translating (or a max wait), so the app never shows a mix of old and new language. You can tune timing:
TranslationService.languageChangeSettleDuration = Duration(milliseconds: 400); // time for widgets to request translations (default: 350)
TranslationService.languageChangeMaxWait = Duration(seconds: 15); // max wait for all translations (default: 10)
Built-in Language Switcher UI
KitLanguageSwitcher(
languages: [
TranslateLanguage.english,
TranslateLanguage.hindi,
TranslateLanguage.arabic,
TranslateLanguage.french,
],
onChanged: (lang) => print('Changed to ${lang.displayName}'),
)
Model Download with Progress
KitModelDownloadButton(
language: TranslateLanguage.hindi,
onDownloaded: () => print('Hindi model ready!'),
)
String Extension
final translated = await 'Hello World'.kit;
RTL Auto-Detection
When you switch to Arabic, Urdu, Hebrew, or Persian β the entire app layout flips to RTL automatically. No extra code needed.
Smart Translation Cache
Translated strings are cached in Hive. The same string is never translated twice, making subsequent launches near-instant.
print(TranslationService().cacheSize); // number of cached strings
await TranslationService().clearCache(); // reset if needed
Opt out of translation
KitText('API_KEY_abc123', translate: false) // never translated
Supported Languages (50+)
flutter_translate_kit is built on Google ML Kit on-device translation, so you get a wide range of languages out of the box:
- South Asian: Hindi, Urdu, Bengali, Punjabi, Gujarati, Marathi, Tamil, Telugu, Kannada, Malayalam
- MiddleβEast & RTL: Arabic, Persian (Farsi), Hebrew
- European: English, French, Spanish, German, Italian, Portuguese, Dutch, Polish, Turkish, Ukrainian, Russian, Greek, Czech, Slovak, Romanian, Hungarian, Swedish, Norwegian, Danish, Finnish
- East Asian: Chinese (Simplified & Traditional), Japanese, Korean
- SouthβEast Asian: Thai, Vietnamese, Indonesian, Malay, Filipino
- African & others: Afrikaans, Swahili, and more supported by ML Kit
You can set any of these via TranslateLanguage:
await TranslationService().setLanguage(TranslateLanguage.hindi);
await TranslationService().setLanguage(TranslateLanguage.urdu);
await TranslationService().setLanguage(TranslateLanguage.bengali);
await TranslationService().setLanguage(TranslateLanguage.punjabi);
await TranslationService().setLanguage(TranslateLanguage.tamil);
// ...and many more
Platform Requirements
| Platform | Supported |
|---|---|
| Android | β (API 21+) |
| iOS | β (iOS 15.5+) |
| Web | β (ML Kit is mobile-only) |
| Desktop | β |
Android setup
No additional setup required.
iOS setup
In ios/Podfile:
platform :ios, '15.5'
Simulator note (Xcode 26+): Google ML Kit's native iOS frameworks don't yet include
arm64-simulatorslices, so building for the iOS Simulator is not supported. Test on a real device or use an Android emulator. Alternatively, use a Rosetta simulator destination in Xcode.
License
MIT Β© 2026 β Built with β€οΈ using Google ML Kit
Libraries
- flutter_translate_kit
- flutter_translate_kit