local_translation
On device translation and language detection for Flutter.
Platform support
iOS and macOS
Apple's Translation and NaturalLanguage frameworks.
isSupported()istrueon iOS 18+ physical devices and macOS 15+. It isfalseon older OS versions and the iOS Simulator.- Translation may prompt the user to download language models.
Android
Android's TranslationManager and TextClassifier APIs.
isSupported()istrueon Android 12+ when the device provides an on deviceTranslationService. This is mainly available on Pixel devices with Live Translate. Many emulators and OEM phones returnfalse.- Language detection works on API 29+ even when translation is unavailable.
- Language models are managed by the system. The first translation may trigger a download via the OEM translation service.
Call isSupported() before translate or translateBatch. Language detection can still run when translation is unavailable.
Supported languages
Pass BCP 47 language tags as sourceLanguage and targetLanguage.
Apple Translate languages
Translation uses the same languages as Apple's Translate app.
| Language | Tag |
|---|---|
| Arabic | ar |
| Dutch | nl |
| English (United Kingdom) | en-GB |
| English (United States) | en |
| French (France) | fr |
| German (Germany) | de |
| Hindi | hi |
| Indonesian | id |
| Italian (Italy) | it |
| Japanese | ja |
| Korean | ko |
| Mandarin Chinese (China mainland) | zh-Hans |
| Mandarin Chinese (Taiwan) | zh-Hant |
| Polish | pl |
| Portuguese (Brazil) | pt-BR |
| Russian | ru |
| Spanish (Spain) | es |
| Thai | th |
| Turkish | tr |
| Ukrainian | uk |
| Vietnamese | vi |
Not every source/target pair is supported. For example, translating between English variants or into the same language is rejected. Language models must be downloaded on the device before use (this is prompted when trying to translate a string for the first time). Apple may add languages in future iOS and macOS releases; see iOS feature availability and LanguageAvailability.
Android language pairs
Supported language pairs depend on the device's translation service. Use isSupported() to check availability. On Pixel devices, languages can be managed in Settings > System > Live Translate.
Usage
final translation = LocalTranslation();
if (!await translation.isSupported()) {
return;
}
final detection = await translation.detectLanguage('Hallo Welt');
final detections = await translation.detectLanguages([
'Hallo Welt',
'Guten Morgen',
]);
final one = await translation.translate(
'Hallo Welt',
targetLanguage: 'en',
);
final many = await translation.translateBatch(
['Hallo Welt', 'Wie geht es dir?'],
sourceLanguage: 'de',
targetLanguage: 'en',
);
sourceLanguage is optional. When omitted, the plugin auto detects.
Regenerating Pigeon
dart run pigeon --input pigeons/local_translation_api.dart