Move gen_l10n into flutter_tools#65025
Move gen_l10n into flutter_tools#65025HansMuller merged 28 commits intoflutter:masterfrom shihaohong:gen-l10n-flutter-tool
Conversation
|
This pull request is not suitable for automatic merging in its current state.
|
|
I'm requesting review on the existing parts of the PR for now because of the timezone differences. I'll address any code review comments and add the generate_localizations command tests on the next day. |
| GenerateLocalizationsCommand({ | ||
| FileSystem fileSystem, | ||
| }) { | ||
| _fileSystem = fileSystem; |
There was a problem hiding this comment.
do this in the initializer and it can be final
| import '../localizations/localizations_utils.dart'; | ||
| import '../runner/flutter_command.dart'; | ||
|
|
||
| class GenerateLocalizationsCommand extends FlutterCommand { |
There was a problem hiding this comment.
nit: add a brief doc comment and link to the correct documentation?
|
|
||
| precacheLanguageAndRegionTags(); | ||
|
|
||
| final String inputPathString = argResults['arb-dir'] as String; |
There was a problem hiding this comment.
there are some helpers like stringArg, stringsArg, et cetera that avoid the casting
| ..loadResources() | ||
| ..writeOutputFiles() | ||
| ..outputUnimplementedMessages(untranslatedMessagesFile, globals.logger); | ||
| } on FileSystemException catch (e) { |
There was a problem hiding this comment.
consider not catching all file system exceptions: some of these might be programming errors in the tool.
There was a problem hiding this comment.
I've converted any FileSystemExceptions I threw in the tool into L10nExceptions and then removed the code catching file system exceptions
| String get description => 'Generate localizations for the Flutter project.'; | ||
|
|
||
| @override | ||
| String get name => 'generate_localizations'; |
There was a problem hiding this comment.
consider an short name alias for typing - gen-l10n ?
There was a problem hiding this comment.
Note also: maybe we should use a hyphenated name for the long form as well.
jonahwilliams
left a comment
There was a problem hiding this comment.
Overall change LGTM with some nits
|
I manually set |
|
|
|
seems to be OK now? |
|
I re-ran the failing test and it appears to have healed itself. |
Description
flutter pub getorflutter update-packagesneeds to be run influtter/dev/toolsfor the localizations generator to work because the dependencies of the localizations script is not cached or updated correctly. This is an issue with CI that requires switching flutter versions, and usually becomes an issue when users upgrade their flutter SDK when they're already using the gen_l10n tool.This PR moves the
gen_l10nscript fromdev/toolstoflutter_toolsto ensure that its dependencies are regenerated every time a new flutter tool snapshot is generated.List of changes:
dev/toolstopackages/flutter_tools.gen_subtag_registry.dartso thatlanguage_subtag_registry.dartindev/toolsandpackages/flutter_toolsstay in sync and updated when the script is run.dev/tools/localization/bin/gen_l10n.dartthat callsflutter gen-l10n <options>so that this change is backwards compatible.flutter gen-l10n <options>command that works the same way as the previousdart ${FLUTTER}/dev/tools/localization/bin/gen_l10n.dart <option>did.build_systemandgen_l10nCLI workflows to account for the move toflutter_tools, such as wiring aLoggerintoLocalizationsGeneratorand updating the points in the code where separate dart process was called to generate localizations and instead invokingLocalizationsGeneratordirectly.Related Issues
Fixes #65023
Tests
I added the following tests:
gen_l10ntests fromdev/toolstopackages/flutter_toolsresident_runner_test.dartgen-l10ncommand.Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.