66/// This script uses the extract_messages.dart library to find the Intl.message
77/// calls in the target dart files and produces ARB format output. See
88/// https://code.google.com/p/arb/wiki/ApplicationResourceBundleSpecification
9- library extract_to_arb ;
9+ library ;
1010
1111import 'dart:convert' ;
1212import 'dart:io' ;
@@ -35,38 +35,58 @@ void main(List<String> args) {
3535 // If this is true, the @@last_modified entry is not output.
3636 var suppressLastModified = false ;
3737
38- parser.addFlag ('help' ,
39- abbr: 'h' , negatable: false , help: 'Print this usage information.' );
38+ parser.addFlag (
39+ 'help' ,
40+ abbr: 'h' ,
41+ negatable: false ,
42+ help: 'Print this usage information.' ,
43+ );
4044
4145 // If this is true, then treat all warnings as errors.
42- parser.addFlag ('suppress-last-modified' ,
43- callback: (x) => suppressLastModified = x,
44- help: 'Suppress @@last_modified entry.' );
45- parser.addFlag ('suppress-warnings' ,
46- defaultsTo: false ,
47- callback: (x) => extract.suppressWarnings = x,
48- help: 'Suppress printing of warnings.' );
49- parser.addFlag ('suppress-meta-data' ,
50- callback: (x) => suppressMetaData = x,
51- help: 'Suppress writing meta information' );
52- parser.addFlag ('warnings-are-errors' ,
53- callback: (x) => extract.warningsAreErrors = x,
54- help: 'Treat all warnings as errors, stop processing ' );
55- parser.addFlag ('embedded-plurals' ,
56- defaultsTo: true ,
57- callback: (x) => extract.allowEmbeddedPluralsAndGenders = x,
58- help: 'Allow plurals and genders to be embedded as part of a larger '
59- 'string, otherwise they must be at the top level.' );
46+ parser.addFlag (
47+ 'suppress-last-modified' ,
48+ callback: (x) => suppressLastModified = x,
49+ help: 'Suppress @@last_modified entry.' ,
50+ );
51+ parser.addFlag (
52+ 'suppress-warnings' ,
53+ defaultsTo: false ,
54+ callback: (x) => extract.suppressWarnings = x,
55+ help: 'Suppress printing of warnings.' ,
56+ );
57+ parser.addFlag (
58+ 'suppress-meta-data' ,
59+ callback: (x) => suppressMetaData = x,
60+ help: 'Suppress writing meta information' ,
61+ );
62+ parser.addFlag (
63+ 'warnings-are-errors' ,
64+ callback: (x) => extract.warningsAreErrors = x,
65+ help: 'Treat all warnings as errors, stop processing ' ,
66+ );
67+ parser.addFlag (
68+ 'embedded-plurals' ,
69+ defaultsTo: true ,
70+ callback: (x) => extract.allowEmbeddedPluralsAndGenders = x,
71+ help:
72+ 'Allow plurals and genders to be embedded as part of a larger '
73+ 'string, otherwise they must be at the top level.' ,
74+ );
6075 //TODO(mosuem): All references to the transformer can be removed, but this
6176 // should happen in a separate PR to help with testing.
62- parser.addFlag ('transformer' ,
63- callback: (x) => transformer = x,
64- help: 'Assume that the transformer is in use, so name and args '
65- "don't need to be specified for messages." );
66- parser.addOption ('locale' ,
67- defaultsTo: null ,
68- callback: (value) => locale = value,
69- help: 'Specify the locale set inside the arb file.' );
77+ parser.addFlag (
78+ 'transformer' ,
79+ callback: (x) => transformer = x,
80+ help:
81+ 'Assume that the transformer is in use, so name and args '
82+ "don't need to be specified for messages." ,
83+ );
84+ parser.addOption (
85+ 'locale' ,
86+ defaultsTo: null ,
87+ callback: (value) => locale = value,
88+ help: 'Specify the locale set inside the arb file.' ,
89+ );
7090 parser.addFlag (
7191 'with-source-text' ,
7292 callback: (x) => includeSourceText = x,
@@ -89,7 +109,8 @@ void main(List<String> args) {
89109 parser.addOption (
90110 'sources-list-file' ,
91111 callback: (value) => sourcesListFile = value,
92- help: 'A file that lists the Dart files to read, one per line.'
112+ help:
113+ 'A file that lists the Dart files to read, one per line.'
93114 'The paths in the file can be absolute or relative to the '
94115 'location of this file.' ,
95116 );
@@ -121,16 +142,18 @@ void main(List<String> args) {
121142
122143 var dartFiles = < String > [
123144 ...args.where ((x) => x.endsWith ('.dart' )),
124- ...linesFromFile (sourcesListFile)
145+ ...linesFromFile (sourcesListFile),
125146 ];
126147 dartFiles
127148 .map ((dartFile) => extract.parseFile (File (dartFile), transformer))
128149 .expand ((parsedFile) => parsedFile.entries)
129- .map ((nameToMessage) => toARB (
130- message: nameToMessage.value,
131- includeSourceText: includeSourceText,
132- suppressMetadata: suppressMetaData,
133- ))
150+ .map (
151+ (nameToMessage) => toARB (
152+ message: nameToMessage.value,
153+ includeSourceText: includeSourceText,
154+ suppressMetadata: suppressMetaData,
155+ ),
156+ )
134157 .forEach ((message) => allMessages.addAll (message));
135158 var file = File (path.join (targetDir, outputFilename));
136159 file.writeAsStringSync (JsonEncoder .withIndent (' ' ).convert (allMessages));
0 commit comments