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 JSON files representing translations of messages from the corresponding | 8 * of JSON files representing translations of messages from the corresponding |
9 * Dart file. See extract_to_json.dart and make_hardcoded_translation.dart. | 9 * Dart file. See extract_to_json.dart and make_hardcoded_translation.dart. |
10 * | 10 * |
(...skipping 12 matching lines...) Expand all Loading... |
23 import 'package:path/path.dart' as path; | 23 import 'package:path/path.dart' as path; |
24 import 'package:args/args.dart'; | 24 import 'package:args/args.dart'; |
25 import 'package:serialization/serialization.dart'; | 25 import 'package:serialization/serialization.dart'; |
26 | 26 |
27 /** | 27 /** |
28 * Keeps track of all the messages we have processed so far, keyed by message | 28 * Keeps track of all the messages we have processed so far, keyed by message |
29 * name. | 29 * name. |
30 */ | 30 */ |
31 Map<String, MainMessage> messages; | 31 Map<String, MainMessage> messages; |
32 | 32 |
33 main() { | 33 main(List<String> args) { |
34 var targetDir; | 34 var targetDir; |
35 var args = new Options().arguments; | |
36 var parser = new ArgParser(); | 35 var parser = new ArgParser(); |
37 parser.addFlag("suppress-warnings", defaultsTo: false, | 36 parser.addFlag("suppress-warnings", defaultsTo: false, |
38 callback: (x) => suppressWarnings = x); | 37 callback: (x) => suppressWarnings = x); |
39 parser.addOption("output-dir", defaultsTo: '.', | 38 parser.addOption("output-dir", defaultsTo: '.', |
40 callback: (x) => targetDir = x); | 39 callback: (x) => targetDir = x); |
41 parser.addOption("generated-file-prefix", defaultsTo: '', | 40 parser.addOption("generated-file-prefix", defaultsTo: '', |
42 callback: (x) => generatedFilePrefix = x); | 41 callback: (x) => generatedFilePrefix = x); |
43 parser.parse(args); | 42 parser.parse(args); |
44 var dartFiles = args.where((x) => x.endsWith("dart")).toList(); | 43 var dartFiles = args.where((x) => x.endsWith("dart")).toList(); |
45 var jsonFiles = args.where((x) => x.endsWith(".json")).toList(); | 44 var jsonFiles = args.where((x) => x.endsWith(".json")).toList(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 class BasicTranslatedMessage extends TranslatedMessage { | 111 class BasicTranslatedMessage extends TranslatedMessage { |
113 BasicTranslatedMessage(String name, translated) : | 112 BasicTranslatedMessage(String name, translated) : |
114 super(name, translated); | 113 super(name, translated); |
115 | 114 |
116 MainMessage get originalMessage => | 115 MainMessage get originalMessage => |
117 (super.originalMessage == null) ? _findOriginal() : super.originalMessage; | 116 (super.originalMessage == null) ? _findOriginal() : super.originalMessage; |
118 | 117 |
119 // We know that our [id] is the name of the message, which is used as the | 118 // We know that our [id] is the name of the message, which is used as the |
120 //key in [messages]. | 119 //key in [messages]. |
121 MainMessage _findOriginal() => originalMessage = messages[id]; | 120 MainMessage _findOriginal() => originalMessage = messages[id]; |
122 } | 121 } |
OLD | NEW |