Skip to content

Drop the removed synthetic-package option from the flutter-setup-localization skill - #258

Open
ArefMozafari wants to merge 2 commits into
flutter:mainfrom
ArefMozafari:fix-localization-synthetic-package
Open

ArefMozafari wants to merge 2 commits into
flutter:mainfrom
ArefMozafari:fix-localization-synthetic-package

Conversation

@ArefMozafari

Copy link
Copy Markdown

Task summary

Fixes #239.

skills/flutter-setup-localization/SKILL.md tells the agent to write synthetic-package: true into l10n.yaml and to import package:flutter_gen/gen_l10n/app_localizations.dart. Synthetic packages have been removed from Flutter, so an agent following the skill on current stable fails at the first generation step:

$ flutter gen-l10n
l10n.yaml: Cannot enable "synthetic-package", this feature has been removed. See http://flutter.dev/to/flutter-gen-deprecation.

This change drops the option from both l10n.yaml snippets and points both imports at the file the tool actually generates, matching the current Flutter i18n docs and the flutter_gen deprecation guide.

The lines that carry the change:

 arb-dir: lib/l10n
 template-arb-file: app_en.arb
 output-localization-file: app_localizations.dart
-synthetic-package: true
-import 'package:flutter_gen/gen_l10n/app_localizations.dart'; // Adjust path if synthetic-package is false
+import 'l10n/app_localizations.dart'; // Generated into arb-dir; adjust if output-dir is set

Scope of work

  • Remove synthetic-package: true from the setup snippet and the complete l10n.yaml example.
  • Replace both package:flutter_gen/gen_l10n/app_localizations.dart imports with l10n/app_localizations.dart.
  • Say where the generated files land (arb-dir, or output-dir when set) and that synthetic-package must not be set.
  • Leave the generation step as flutter pub get; it still triggers generation when generate: true is set.

Testing instructions

On Flutter 3.47.7 stable, in a fresh flutter create --empty project, follow the skill as now written: add flutter_localizations and intl, set generate: true, create the three-line l10n.yaml, add app_en.arb and app_es.arb with the skill's helloWorld, hello, nWombats and pronoun messages, wire MaterialApp and the GreetingWidget example with the new import.

$ flutter pub get
$ ls lib/l10n
app_en.arb  app_es.arb  app_localizations.dart  app_localizations_en.dart  app_localizations_es.dart
$ flutter analyze
No issues found!

A widget test that pumps the app finds Hello World!, Hello Bob and 1 wombat, and finds ¡Hola Mundo! with the platform locale set to es.

dart analyze --fatal-infos and dart test in tool/generator pass (101 tests).

Screenshots

Not a UI change.

Breaking changes

No. The skill now produces a project that generates on current stable; it did not generate at all before.

Documentation / links

@google-cla

google-cla Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Flutter localization documentation in SKILL.md to remove references to synthetic-package, which has been removed from Flutter, and updates the configuration and import examples accordingly. Feedback suggests adding a comment to the widget import example to clarify that the relative path may need adjustment depending on the file's location.

```dart
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'l10n/app_localizations.dart';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since widgets like GreetingWidget are commonly placed in subdirectories (e.g., lib/widgets/greeting_widget.dart), a relative import of l10n/app_localizations.dart will fail to compile unless adjusted. Adding a comment similar to the one in main.dart helps clarify that the relative path may need to be adjusted depending on the file's location.

Suggested change
import 'l10n/app_localizations.dart';
import 'l10n/app_localizations.dart'; // Adjust path depending on the widget's file location

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, added the same note as the main.dart snippet so the widget example says the path depends on where the file lives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter-setup-localization: sets synthetic-package: true, which gen-l10n now rejects

1 participant