@@ -223,7 +223,8 @@ class GenerateLocalizationsCommand extends FlutterCommand {
223
223
224
224
@override
225
225
Future <FlutterCommandResult > runCommand () async {
226
- List <String > outputFileList;
226
+ final List <String > outputFileList;
227
+ File ? untranslatedMessagesFile;
227
228
228
229
bool format = boolArg ('format' ) ?? false ;
229
230
@@ -238,19 +239,21 @@ class GenerateLocalizationsCommand extends FlutterCommand {
238
239
'To use the command line arguments, delete the l10n.yaml file in the '
239
240
'Flutter project.\n\n '
240
241
);
241
- outputFileList = generateLocalizations (
242
+ final LocalizationsGenerator generator = generateLocalizations (
242
243
logger: _logger,
243
244
options: options,
244
245
projectDir: _fileSystem.currentDirectory,
245
246
fileSystem: _fileSystem,
246
- ).outputFileList;
247
+ );
248
+ outputFileList = generator.outputFileList;
249
+ untranslatedMessagesFile = generator.untranslatedMessagesFile;
247
250
format = format || options.format;
248
251
} else {
249
252
final String inputPathString = stringArgDeprecated ('arb-dir' )! ; // Has default value, cannot be null.
250
253
final String ? outputPathString = stringArgDeprecated ('output-dir' );
251
254
final String outputFileString = stringArgDeprecated ('output-localization-file' )! ; // Has default value, cannot be null.
252
255
final String templateArbFileName = stringArgDeprecated ('template-arb-file' )! ; // Has default value, cannot be null.
253
- final String ? untranslatedMessagesFile = stringArgDeprecated ('untranslated-messages-file' );
256
+ final String ? untranslatedMessagesFilePath = stringArgDeprecated ('untranslated-messages-file' );
254
257
final String classNameString = stringArgDeprecated ('output-class' )! ; // Has default value, cannot be null.
255
258
final List <String > preferredSupportedLocales = stringsArg ('preferred-supported-locales' );
256
259
final String ? headerString = stringArgDeprecated ('header' );
@@ -267,7 +270,7 @@ class GenerateLocalizationsCommand extends FlutterCommand {
267
270
precacheLanguageAndRegionTags ();
268
271
269
272
try {
270
- outputFileList = ( LocalizationsGenerator (
273
+ final LocalizationsGenerator generator = LocalizationsGenerator (
271
274
fileSystem: _fileSystem,
272
275
inputPathString: inputPathString,
273
276
outputPathString: outputPathString,
@@ -282,15 +285,16 @@ class GenerateLocalizationsCommand extends FlutterCommand {
282
285
useSyntheticPackage: useSyntheticPackage,
283
286
projectPathString: projectPathString,
284
287
areResourceAttributesRequired: areResourceAttributesRequired,
285
- untranslatedMessagesFile: untranslatedMessagesFile ,
288
+ untranslatedMessagesFile: untranslatedMessagesFilePath ,
286
289
usesNullableGetter: usesNullableGetter,
287
290
useEscaping: useEscaping,
288
291
logger: _logger,
289
292
suppressWarnings: suppressWarnings,
290
293
)
291
294
..loadResources ()
292
- ..writeOutputFiles ())
293
- .outputFileList;
295
+ ..writeOutputFiles ();
296
+ outputFileList = generator.outputFileList;
297
+ untranslatedMessagesFile = generator.untranslatedMessagesFile;
294
298
} on L10nException catch (e) {
295
299
throwToolExit (e.message);
296
300
}
@@ -301,8 +305,16 @@ class GenerateLocalizationsCommand extends FlutterCommand {
301
305
if (outputFileList.isEmpty) {
302
306
return FlutterCommandResult .success ();
303
307
}
308
+ final List <String > formatFileList = outputFileList.toList ();
309
+ if (untranslatedMessagesFile != null ) {
310
+ // Don't format the messages file using `dart format`.
311
+ formatFileList.remove (untranslatedMessagesFile.absolute.path);
312
+ }
313
+ if (formatFileList.isEmpty) {
314
+ return FlutterCommandResult .success ();
315
+ }
304
316
final String dartBinary = _artifacts.getArtifactPath (Artifact .engineDartBinary);
305
- final List <String > command = < String > [dartBinary, 'format' , ...outputFileList ];
317
+ final List <String > command = < String > [dartBinary, 'format' , ...formatFileList ];
306
318
final ProcessResult result = await _processManager.run (command);
307
319
if (result.exitCode != 0 ) {
308
320
throwToolExit ('Formatting failed: $result ' , exitCode: result.exitCode);
0 commit comments