flutter-localization
Configure Flutter apps to support multiple languages and locales with proper i18n setup.
- Manages dependency injection (
flutter_localizations,intl), code generation configuration (l10n.yaml), and.arbtranslation file creation with support for placeholders, plurals, and regional variants - Configures root widget delegates (
MaterialApp,CupertinoApp, orWidgetsApp) and handles isolated widgets likeTextFieldandCupertinoTabBarthat require explicitLocalizationswrapping - Supports complex locales using
Locale.fromSubtagsfor multi-script languages (e.g., Chinesezh_Hans_CN) and includes iOS Xcode project configuration for App Store locale exposure - Prevents common assertion errors by ensuring proper localization delegate hierarchy and validates generated code with
flutter gen-l10n
Flutter Localization Setup
Goal
Configures and implements internationalization (i18n) and localization (l10n) in a Flutter application. This skill manages dependency injection (flutter_localizations, intl), code generation configuration (l10n.yaml), root widget setup (MaterialApp, CupertinoApp, or WidgetsApp), .arb translation file management, and platform-specific configurations (iOS Xcode project updates). It ensures proper locale resolution and prevents common assertion errors related to missing localization delegates in specific widgets like TextField and CupertinoTabBar.
Decision Logic
- Determine App Root: Identify if the application uses
MaterialApp,CupertinoApp, orWidgetsAppto inject the correct global delegates. - Identify Target Platforms: If iOS is a target platform, Xcode project files (
Info.plist/project.pbxproj) must be updated to expose supported locales to the App Store. - Analyze Widget Tree: Check for isolated
TextFieldorCupertinoTabBarwidgets that might exist outside the root app's localization scope. If found, wrap them in explicitLocalizationswidgets. - Determine Locale Complexity: If supporting languages with multiple scripts/regions (e.g., Chinese
zh_Hans_CN), useLocale.fromSubtagsinstead of the defaultLocaleconstructor.
Instructions
- Configure Dependencies
Update
pubspec.yamlto include required packages and enable code generation.dependencies: flutter: sdk: flutter flutter_localizations:
More from flutter/skills
flutter-building-layouts
Builds Flutter layouts using the constraint system and layout widgets. Use when creating or refining the UI structure of a Flutter application.
10.6Kflutter-architecting-apps
Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.
10.4Kflutter-animating-apps
Implements animated effects, transitions, and motion in a Flutter app. Use when adding visual feedback, shared element transitions, or physics-based animations.
9.6Kflutter-managing-state
Manages application and ephemeral state in a Flutter app. Use when sharing data between widgets or handling complex UI state transitions.
9.6Kflutter-theming-apps
Customizes the visual appearance of a Flutter app using the theming system. Use when defining global styles, colors, or typography for an application.
9.5Kflutter-implementing-navigation-and-routing
Handles routing, navigation, and deep linking in a Flutter application. Use when moving between screens or setting up URL-based navigation.
9.3K