Instantly see how your translations fit on a real device while you type
On a phone screen, a translation that is a few characters too long can overflow, wrap awkwardly, or push a layout out of shape. Finding those problems by rebuilding the app after every change is slow. In-Context Editing removes that loop for Flutter apps: you type a translation in Localizely and see it rendered on your device or in a browser as you type.
Seeing each string where it actually appears also gives translators the context they need to choose the right wording, so quality improves alongside layout.
In-Context Editing complements your translation workflow rather than replacing it. It is meant for development and testing: the changes you make this way are visible only while the app is connected to Localizely. To ship them, you still upload, translate, and download as usual.
Most Flutter apps are localized with the intl package and a tool that generates the localization code. The sections below show how to add In-Context Editing to such a project. Pick the tab that matches your setup.
The gen_l10n tool is the standard way of localizing Flutter applications. It ships with the Flutter SDK and generates the localization code as part of the build. This guide assumes your app is already localized with it. If not, start with our guide to setting up localization with the gen_l10n tool, then come back here to enable In-Context Editing.
A complete sample app with In-Context Editing is available on GitHub.
Add the localizely_sdk dependency to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
localizely_sdk: ^2.7.7Save the file and fetch the package:
flutter pub getRecent Flutter versions no longer generate localization code as a synthetic package, so make sure your l10n.yaml file writes the generated code into your lib directory. The sample app uses the following configuration:
arb-dir: lib/l10n
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
output-dir: lib/l10n/generatedThen generate the localization file the SDK needs:
dart run localizely_sdk:generateNote: In Flutter 3.22.0, running the command dart run localizely_sdk:generate may produce false analyzer errors. This issue has been resolved in Flutter 3.22.1. If you need to use 3.22.0 and encounter these errors, running flutter pub get again should fix the problem.
To regenerate the code automatically whenever your .arb files change, add build_runner to your dev_dependencies and run it in watch mode:
flutter pub add build_runner -d
dart run build_runner watchOnce the localization file is generated, point the localizationsDelegates and supportedLocales properties of your MaterialApp widget at it.
...
import 'l10n/generated/localizely_localizations.dart';
class MyApp extends StatelessWidget {
...
@override
Widget build(BuildContext context) {
return MaterialApp(
...
localizationsDelegates: LocalizelyLocalizations.localizationsDelegates,
supportedLocales: LocalizelyLocalizations.supportedLocales,
...
);
}
}Wrap the root of your app in the LocalizelyInContextEditing widget in main.dart:
...
import 'package:localizely_sdk/localizely_sdk.dart';
void main() {
runApp(
LocalizelyInContextEditing(
enabled: true, // set to false to disable In-Context Editing for production app builds
child: MyApp(),
),
);
}
...Run your app. On launch it opens a connection screen that asks for a token from Localizely.
To get the token, open the Translations page of your project in Localizely and click the button. The dialog that opens shows everything you need, including the token.
Enter the token in the app to connect.
A confirmation message tells you the app is now connected to Localizely.
Note: The localizely_sdk >=2.4.0 <2.5.0 requires an update of min platform versions:
- Android: Required Android SDK 21 or newer (update minSdkVersion to 21 in the android/app/build.gradle file).
- iOS: Required iOS 11 or newer and an update of the Info.plist file with the NSCameraUsageDescription.
As of version 2.5.0, these updates are no longer required due to changes in implementation.
Note: The localizely_sdk >=2.4.0 <2.5.0 uses the QR code scanner on mobile apps to connect. This way of connecting is abandoned. In case you are prompted to scan the QR code, please update the localizely_sdk to the latest available version.
Start translating in Localizely. Each change appears on the connected device as you type, so you can see immediately whether the text fits.
The Flutter Intl is an IDE plugin that generates the boilerplate code for the intl package. This guide assumes your app is already localized with it. If not, start with our guide to setting up localization with the Flutter Intl plugin, then come back here to enable In-Context Editing.
A complete sample app with In-Context Editing is available on GitHub.
Add the localizely_sdk dependency to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
localizely_sdk: ^2.7.7Save the file and fetch the package:
flutter pub getThen enable ota_enabled in the flutter_intl section of the same file, so the Flutter Intl plugin generates the metadata the SDK needs:
flutter_intl:
enabled: true
localizely:
ota_enabled: trueWrap the root of your app in the LocalizelyInContextEditing widget in main.dart:
...
import 'package:localizely_sdk/localizely_sdk.dart';
void main() {
runApp(
LocalizelyInContextEditing(
enabled: true, // set to false to disable In-Context Editing for production app builds
child: MyApp(),
),
);
}
...Run your app. On launch it opens a connection screen that asks for a token from Localizely.
To get the token, open the Translations page of your project in Localizely and click the button. The dialog that opens shows everything you need, including the token.
Enter the token in the app to connect.
A confirmation message tells you the app is now connected to Localizely.
Note: The localizely_sdk >=2.4.0 <2.5.0 requires an update of min platform versions:
- Android: Required Android SDK 21 or newer (update minSdkVersion to 21 in the android/app/build.gradle file).
- iOS: Required iOS 11 or newer and an update of the Info.plist file with the NSCameraUsageDescription.
As of version 2.5.0, these updates are no longer required due to changes in implementation.
Note: The localizely_sdk >=2.4.0 <2.5.0 uses the QR code scanner on mobile apps to connect. This way of connecting is abandoned. In case you are prompted to scan the QR code, please update the localizely_sdk to the latest available version.
Start translating in Localizely. Each change appears on the connected device as you type, so you can see immediately whether the text fits.
Previous: Flutter Over-the-air updates
Read next: Project branching
Tired of manually editing translation files?
Our platform streamlines software localization for you.