Flutter i18n: One Codebase, Every Language, Every Platform
Flutter uses ARB (Application Resource Bundle) files and the intl package to handle localization across iOS, Android, web, and desktop from a single codebase. The gen-l10n tool generates type-safe Dart code from your ARB templates, giving you compile-time safety and IDE autocomplete for every translation key.
Get started in 4 steps
Enable generation
Add the generate flag to your pubspec.yaml to enable localization code generation.
# pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
flutter:
generate: trueConfigure l10n.yaml
Create l10n.yaml in your project root to configure the localization generator.
# l10n.yaml arb-dir: lib/l10n template-arb-file: app_en.arb output-localization-file: app_localizations.dart
Create ARB template
Add your source language ARB file with translation keys and metadata.
{
"@@locale": "en",
"welcome": "Welcome to {appName}",
"@welcome": {
"placeholders": {
"appName": { "type": "String" }
}
},
"itemCount": "{count, plural, =0{No items} =1{1 item} other{{count} items}}",
"@itemCount": {
"placeholders": {
"count": { "type": "int" }
}
}
}Use in your app
Wrap your app with localization delegates and use AppLocalizations.of(context) in widgets.
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Text(l10n.welcome('Flutter'));
}
}Flutter Localization Features
Flutter Localization in Practice
Use AppLocalizations.of(context) to access generated translation methods in your widgets, with full support for pluralization and date formatting.
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class ProductPage extends StatelessWidget {
final int itemCount;
const ProductPage({required this.itemCount});
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Column(
children: [
Text(l10n.welcome('My Store')),
Text(l10n.itemCount(itemCount)),
// Date formatting respects locale
Text(DateFormat.yMMMd(
Localizations.localeOf(context).toString()
).format(DateTime.now())),
],
);
}
}Related Guides
Android Localization
Compare Flutter localization with native Android strings.xml and resource qualifier patterns.
iOS Localization
See how iOS handles localization with String Catalogs and SwiftUI for platform-specific comparison.
TMS Comparisons
Compare translation management platforms to find the best fit for your Flutter project.
Simplify Flutter Localization Today
Manage your ARB translations with AI-powered workflows, CLI sync to your Flutter project, and CDN delivery under 50ms.