Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: pkg/intl/test/message_extraction/extract_to_json.dart

Issue 17113002: Allow translated messages that have no matching original message (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a typo in help text Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * This script uses the extract_messages.dart library to find the Intl.message 7 * This script uses the extract_messages.dart library to find the Intl.message
8 * calls in the target dart files and produces intl_messages.json containing the 8 * calls in the target dart files and produces intl_messages.json containing the
9 * information on those messages. It uses the analyzer-experimental parser 9 * information on those messages. It uses the analyzer-experimental parser
10 * to find the information. 10 * to find the information.
(...skipping 16 matching lines...) Expand all
27 import 'package:intl/src/intl_message.dart'; 27 import 'package:intl/src/intl_message.dart';
28 import 'package:args/args.dart'; 28 import 'package:args/args.dart';
29 29
30 main() { 30 main() {
31 var args = new Options().arguments; 31 var args = new Options().arguments;
32 var targetDir; 32 var targetDir;
33 var parser = new ArgParser(); 33 var parser = new ArgParser();
34 parser.addFlag("suppress-warnings", defaultsTo: false, 34 parser.addFlag("suppress-warnings", defaultsTo: false,
35 callback: (x) => suppressWarnings = x); 35 callback: (x) => suppressWarnings = x);
36 36
37 void setTargetDir(value) => targetDir = value; 37 parser.addOption("output-dir", defaultsTo: '.',
38 38 callback: (value) => targetDir = value);
39 parser.addOption("output-dir", defaultsTo: '.', callback: setTargetDir);
40 parser.parse(args); 39 parser.parse(args);
41 if (args.length == 0) { 40 if (args.length == 0) {
42 print('Usage: extract_to_json [--output-dir=<dir>] [files.dart]'); 41 print('Usage: extract_to_json [--output-dir=<dir>] [files.dart]');
43 print('Accepts Dart files and produces intl_messages.json'); 42 print('Accepts Dart files and produces intl_messages.json');
44 exit(0); 43 exit(0);
45 } 44 }
46 var allMessages = []; 45 var allMessages = [];
47 for (var arg in args.where((x) => x.contains(".dart"))) { 46 for (var arg in args.where((x) => x.contains(".dart"))) {
48 var messages = parseFile(new File(arg)); 47 var messages = parseFile(new File(arg));
49 messages.forEach((k, v) => allMessages.add(toJson(v))); 48 messages.forEach((k, v) => allMessages.add(toJson(v)));
(...skipping 16 matching lines...) Expand all
66 */ 65 */
67 Map toJson(IntlMessage message) { 66 Map toJson(IntlMessage message) {
68 return { 67 return {
69 "name" : message.name, 68 "name" : message.name,
70 "description" : message.description, 69 "description" : message.description,
71 "message" : message.fullMessage(leaveTheInterpolationsInDartForm), 70 "message" : message.fullMessage(leaveTheInterpolationsInDartForm),
72 "examples" : message.examples, 71 "examples" : message.examples,
73 "arguments" : message.arguments 72 "arguments" : message.arguments
74 }; 73 };
75 } 74 }
OLDNEW
« no previous file with comments | « pkg/intl/lib/generate_localized.dart ('k') | pkg/intl/test/message_extraction/generate_from_json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698