[flutter_tools] Generate localizations on flutter pub get#132172
[flutter_tools] Generate localizations on flutter pub get#132172auto-submit[bot] merged 4 commits intoflutter:masterfrom
Conversation
| generateDartPluginRegistry: true, | ||
| ); | ||
| final BuildResult result = await globals.buildSystem.build( | ||
| const GenerateLocalizationsTarget(), |
There was a problem hiding this comment.
A few questions:
- what's the difference between building the
GenerateLocalizationsTarget()and callinggenerateLocalizationsSyntheticPackage()? From looking at the code it seems like the latter just runs a few extra validations, then calls the former. - Maybe I don't understand this synthetic package, but why would you want to opt out of the synthetic package and yet still have localizations generated?
There was a problem hiding this comment.
Synthetic package creates a "fake dart package" in .dart_tool/flutter_gen by adding the package to .dart_tool/package_config.json. But because of the way this is set up, it prevents users from exporting anything from the synthetic package (see #109606).
There was a problem hiding this comment.
So is the idea that I have:
- flutter_app_a
- flutter_app_b
- localization_shared_package_c
The localizations all live in C, which A and B both depend on. So apps A and B both have synthetic-package: false, since they will be depending on real package C. But this PR will ensure running flutter pub get from A or B will still re-generate the localization files in C.
Is this right?
There was a problem hiding this comment.
I think that is the case, but why the synthetic-package flag is necessary (necessary because it prevents developers from exporting localization files) is separate from the purpose of this PR, which is to make sure that gen_l10n gets run in flutter pub get whether the synthetic-package flag is on or not.
There was a problem hiding this comment.
Right, but to understand the need for this change, I'm trying to understand why we even allow opting out of synthetic-package, since my understanding was that we relied on the synthetic package for localizations to work.
There was a problem hiding this comment.
Opting out of synthetic-package puts the generated files in the same project under /lib/l10n.
|
Output-dir still not working in the package |
Currently, flutter pub get generates localizations if there exists an l10n.yaml file where synthetic-package is not false. However, for any user who needs to turn off synthetic-package, their localizations are not generated. This PR should make the behavior more consistent. (Also it seems good to make it so that running flutter pub get once resolves all the dependencies so that people can get to work without running flutter gen-l10n manually.)
Fixes #84979.