Skip to content

gen-l10n should support Standalone UI packages #191072

Description

@Geoffrey-magic

Steps to reproduce

In an internationalized app with .arb files.

  1. Migrate to flutter 3.47 and standalone UI packages following those instructions: https://flutter.dev/blog/whats-new-in-flutter-3-47
  2. Execute:
flutter gen-l10n

Expected results

The localization file (app_localizations.dart with below configuration) compatible with standalone UI package according to migration guide: https://flutter.dev/blog/whats-new-in-flutter-3-47:

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:material_ui/material_ui.dart';
import 'package:intl/intl.dart' as intl;

...

  /// A list of this localizations delegate along with the default localizations
  /// delegates.
  ///
  /// Returns a list of localizations delegates containing this delegate along with
  /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  /// and GlobalWidgetsLocalizations.delegate.
  ///
  /// Additional delegates can be added by appending to this list in
  /// MaterialApp. This list does not have to be used at all if a custom list
  /// of delegates is preferred or required.
  static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
    delegate,
    ...GlobalMaterialLocalizations.delegates,
  ];

...

Actual results

Below is the generated localization file (app_localizations.dart with below configuration), depending on embedded UI packages.

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

...

  /// A list of this localizations delegate along with the default localizations
  /// delegates.
  ///
  /// Returns a list of localizations delegates containing this delegate along with
  /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  /// and GlobalWidgetsLocalizations.delegate.
  ///
  /// Additional delegates can be added by appending to this list in
  /// MaterialApp. This list does not have to be used at all if a custom list
  /// of delegates is preferred or required.
  static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
    delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ];

...

Flutter gen-l10n should have an option to generate code with either embedded or standalone UI packages. The result is a crash because of missing UI packages translation. The workaround is to add GlobalMaterialLocalizations.delegates to localizations definition in MaterialApp.

Code sample

Code sample

Content of my l10n.yaml:

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
header: "// dart format off\n// @formatter:off"

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
======== Exception caught by widgets library =======================================================
The following assertion was thrown building RawChip(dirty, dependencies: [_LocalizationsScope-[GlobalKey#414be]], state: _RawChipState#67182(tickers: tracking 4 tickers)):
No MaterialLocalizations found.

RawChip widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
The material library uses Localizations to generate messages, labels, and abbreviations.

To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to include them automatically, or add a Localization widget with a MaterialLocalizations delegate.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.47.0, on macOS 26.6.1 25G76 darwin-arm64, locale en-US) [460ms]
    • Flutter version 3.47.0 on channel stable at /Users/geoffrey/Develop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf2416426 (2 days ago), 2026-08-11 11:53:49 -0700
    • Engine revision 5f77625673
    • Dart version 3.13.0
    • DevTools version 2.60.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 37.0.0) [1,251ms]
    • Android SDK at /Users/geoffrey/Library/Android/sdk
    • Emulator version unknown
    • Platform android-37.0, build-tools 37.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 25.0.2+-15348964-b329.117)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.6) [1,118ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F113
    • CocoaPods version 1.17.0

[✓] Chrome - develop for the web [47ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (3 available) [6.2s]
    • Pixel 8a (mobile) • 48081JEKB02513 • android-arm64  • Android 17 (API 37)
    • macOS (desktop)   • macos          • darwin-arm64   • macOS 26.6.1 25G76 darwin-arm64
    • Chrome (web)      • chrome         • web-javascript • Google Chrome 151.0.7922.109

[✓] Network resources [114.0s]       
    • All expected network resources are available.

• No issues found!

Activity

  1. added
    c: new featureNothing broken; request for a new capability
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: internationalizationSupporting other languages or locales. (aka i18n)
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-toolOwned by Flutter Tool team
    on Aug 13, 2026
  2. mbcorona commented on Aug 13, 2026

    @mbcorona
    Member

    Confirmed from the source. The gen-l10n template hardcodes the flutter_localizations import and a fixed delegate list, with no option for the standalone material_ui/cupertino_ui packages, so the 3.47 migration path generates code that crashes with "No MaterialLocalizations found".

    Sending this to the tool team. Related to the localization decoupling in #188757.

  3. added
    P1High-priority issues at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Aug 19, 2026
  4. self-assigned this
    on Aug 19, 2026
  5. added a commit that references this issue on Sep 7, 2026
  6. amake commented on Nov 11, 2026

    @amake

    This is now more urgent in my view because Flutter 3.50 (now stable) flags the usages of Global{Material,Cupertino}Localizations as deprecated:

       info • 'GlobalMaterialLocalizations' is deprecated and shouldn't be used. Use GlobalMaterialLocalizations from
              package:material_ui/material_ui.dart instead. This feature was deprecated after v3.47.0-0.0.pre. Try replacing the use of
              the deprecated member with the replacement • lib/l10n/app_localizations.dart:93:9 • deprecated_member_use
       info • 'GlobalCupertinoLocalizations' is deprecated and shouldn't be used. Use GlobalCupertinoLocalizations from
              package:cupertino_ui/cupertino_ui.dart instead. This feature was deprecated after v3.47.0-0.0.pre. Try replacing the use of
              the deprecated member with the replacement • lib/l10n/app_localizations.dart:94:9 • deprecated_member_use
    

    So you can't have a clean flutter analyze result with the generated files as-is.

  7. JohnAtTimeless commented on Nov 12, 2026

    @JohnAtTimeless

    Since 3.50, this is affecting our CI build and I have to ignore the linting of app_localizations.dart to silent the warnings.

  8. runoob-coder commented on Nov 12, 2026

    @runoob-coder

    add to your l10n.yaml

    header: "// ignore_for_file: deprecated_member_use"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)c: new featureNothing broken; request for a new capabilityhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions