OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /** | 6 /** |
7 * A main program that takes as input a source Dart file and a number | 7 * A main program that takes as input a source Dart file and a number |
8 * of ARB files representing translations of messages from the corresponding | 8 * of ARB files representing translations of messages from the corresponding |
9 * Dart file. See extract_to_arb.dart and make_hardcoded_translation.dart. | 9 * Dart file. See extract_to_arb.dart and make_hardcoded_translation.dart. |
10 * | 10 * |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 main(List<String> args) { | 34 main(List<String> args) { |
35 var targetDir; | 35 var targetDir; |
36 var parser = new ArgParser(); | 36 var parser = new ArgParser(); |
37 parser.addFlag("suppress-warnings", defaultsTo: false, | 37 parser.addFlag("suppress-warnings", defaultsTo: false, |
38 callback: (x) => suppressWarnings = x); | 38 callback: (x) => suppressWarnings = x); |
39 parser.addOption("output-dir", defaultsTo: '.', | 39 parser.addOption("output-dir", defaultsTo: '.', |
40 callback: (x) => targetDir = x); | 40 callback: (x) => targetDir = x); |
41 parser.addOption("generated-file-prefix", defaultsTo: '', | 41 parser.addOption("generated-file-prefix", defaultsTo: '', |
42 callback: (x) => generatedFilePrefix = x); | 42 callback: (x) => generatedFilePrefix = x); |
| 43 parser.addFlag("use-deferred-loading", defaultsTo: true, |
| 44 callback: (x) => useDeferredLoading = x); |
43 parser.parse(args); | 45 parser.parse(args); |
44 var dartFiles = args.where((x) => x.endsWith("dart")).toList(); | 46 var dartFiles = args.where((x) => x.endsWith("dart")).toList(); |
45 var jsonFiles = args.where((x) => x.endsWith(".arb")).toList(); | 47 var jsonFiles = args.where((x) => x.endsWith(".arb")).toList(); |
46 if (dartFiles.length == 0 || jsonFiles.length == 0) { | 48 if (dartFiles.length == 0 || jsonFiles.length == 0) { |
47 print('Usage: generate_from_arb [--output-dir=<dir>]' | 49 print('Usage: generate_from_arb [--output-dir=<dir>]' |
| 50 ' [--[no-]use-deferred-loading]' |
48 ' [--generated-file-prefix=<prefix>] file1.dart file2.dart ...' | 51 ' [--generated-file-prefix=<prefix>] file1.dart file2.dart ...' |
49 ' translation1_<languageTag>.arb translation2.arb ...'); | 52 ' translation1_<languageTag>.arb translation2.arb ...'); |
50 exit(0); | 53 exit(0); |
51 } | 54 } |
52 | 55 |
53 // We're re-parsing the original files to find the corresponding messages, | 56 // We're re-parsing the original files to find the corresponding messages, |
54 // so if there are warnings extracting the messages, suppress them. | 57 // so if there are warnings extracting the messages, suppress them. |
55 suppressWarnings = true; | 58 suppressWarnings = true; |
56 var allMessages = dartFiles.map((each) => parseFile(new File(each))); | 59 var allMessages = dartFiles.map((each) => parseFile(new File(each))); |
57 | 60 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 135 |
133 // We know that our [id] is the name of the message, which is used as the | 136 // We know that our [id] is the name of the message, which is used as the |
134 //key in [messages]. | 137 //key in [messages]. |
135 List<MainMessage> _findOriginals() => originalMessages = messages[id]; | 138 List<MainMessage> _findOriginals() => originalMessages = messages[id]; |
136 } | 139 } |
137 | 140 |
138 final pluralAndGenderParser = | 141 final pluralAndGenderParser = |
139 removeDuplicates(removeSetables(new ICUParser().message)); | 142 removeDuplicates(removeSetables(new ICUParser().message)); |
140 final plainParser = | 143 final plainParser = |
141 removeDuplicates(removeSetables(new ICUParser().nonIcuMessage)); | 144 removeDuplicates(removeSetables(new ICUParser().nonIcuMessage)); |
OLD | NEW |