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

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

Issue 18543009: Plurals and Genders (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 7 years, 5 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
« no previous file with comments | « pkg/intl/pubspec.yaml ('k') | pkg/intl/test/message_extraction/generate_from_json.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 var file = new File(path.join(targetDir, 'intl_messages.json')); 50 var file = new File(path.join(targetDir, 'intl_messages.json'));
51 file.writeAsStringSync(json.stringify(allMessages)); 51 file.writeAsStringSync(json.stringify(allMessages));
52 } 52 }
53 53
54 /** 54 /**
55 * This is a placeholder for transforming a parameter substitution from 55 * This is a placeholder for transforming a parameter substitution from
56 * the translation file format into a Dart interpolation. In our case we 56 * the translation file format into a Dart interpolation. In our case we
57 * store it to the file in Dart interpolation syntax, so the transformation 57 * store it to the file in Dart interpolation syntax, so the transformation
58 * is trivial. 58 * is trivial.
59 */ 59 */
60 String leaveTheInterpolationsInDartForm(IntlMessage msg, chunk) => 60 String leaveTheInterpolationsInDartForm(MainMessage msg, chunk) {
61 (chunk is String) ? chunk : "\$${msg.arguments[chunk]}"; 61 if (chunk is String) return chunk;
62 if (chunk is int) return "\$${msg.arguments[chunk]}";
63 return chunk.toCode();
64 }
62 65
63 /** 66 /**
64 * Convert the [IntlMessage] to a trivial JSON format. 67 * Convert the [MainMessage] to a trivial JSON format.
65 */ 68 */
66 Map toJson(IntlMessage message) { 69 Map toJson(MainMessage message) {
67 return { 70 var result = new Map<String, Object>();
68 "name" : message.name, 71 for (var attribute in message.attributeNames) {
69 "description" : message.description, 72 result[attribute] = message[attribute];
70 "message" : message.fullMessage(leaveTheInterpolationsInDartForm), 73 }
71 "examples" : message.examples, 74 result["message"] = message.expanded(leaveTheInterpolationsInDartForm);
72 "arguments" : message.arguments 75 return result;
73 };
74 } 76 }
OLDNEW
« no previous file with comments | « pkg/intl/pubspec.yaml ('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