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

Side by Side Diff: pkg/intl/lib/extract_messages.dart

Issue 182443003: Add 'meaning' to Intl.messages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | pkg/intl/lib/intl.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 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This is for use in extracting messages from a Dart program 6 * This is for use in extracting messages from a Dart program
7 * using the Intl.message() mechanism and writing them to a file for 7 * using the Intl.message() mechanism and writing them to a file for
8 * translation. This provides only the stub of a mechanism, because it 8 * translation. This provides only the stub of a mechanism, because it
9 * doesn't define how the file should be written. It provides an 9 * doesn't define how the file should be written. It provides an
10 * [IntlMessage] class that holds the extracted data and [parseString] 10 * [IntlMessage] class that holds the extracted data and [parseString]
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 MainMessage messageFromDirectPluralOrGenderCall(MethodInvocation node) { 273 MainMessage messageFromDirectPluralOrGenderCall(MethodInvocation node) {
274 var pluralOrGender; 274 var pluralOrGender;
275 275
276 void extractFromPluralOrGender(MainMessage message, _) { 276 void extractFromPluralOrGender(MainMessage message, _) {
277 var visitor = new PluralAndGenderVisitor(message.messagePieces, message); 277 var visitor = new PluralAndGenderVisitor(message.messagePieces, message);
278 node.accept(visitor); 278 node.accept(visitor);
279 pluralOrGender = message.messagePieces.last; 279 pluralOrGender = message.messagePieces.last;
280 } 280 }
281 281
282 void setAttribute(MainMessage msg, String fieldName, String fieldValue) { 282 void setAttribute(MainMessage msg, String fieldName, String fieldValue) {
283 if (["name", "desc", "examples", "args"].contains(fieldName)) { 283 if (msg.attributeNames.contains(fieldName)) {
284 msg[fieldName] = fieldValue; 284 msg[fieldName] = fieldValue;
285 } 285 }
286 } 286 }
287 return _messageFromNode(node, extractFromPluralOrGender, setAttribute); 287 return _messageFromNode(node, extractFromPluralOrGender, setAttribute);
288 } 288 }
289 } 289 }
290 290
291 /** 291 /**
292 * Given an interpolation, find all of its chunks, validate that they are only 292 * Given an interpolation, find all of its chunks, validate that they are only
293 * simple variable substitutions or else Intl.plural/gender calls, 293 * simple variable substitutions or else Intl.plural/gender calls,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 SimpleIdentifier target = node.target; 406 SimpleIdentifier target = node.target;
407 return target.token.toString() == "Intl"; 407 return target.token.toString() == "Intl";
408 } 408 }
409 409
410 /** 410 /**
411 * Returns a String describing why the node is invalid, or null if no 411 * Returns a String describing why the node is invalid, or null if no
412 * reason is found, so it's presumed valid. 412 * reason is found, so it's presumed valid.
413 */ 413 */
414 String checkValidity(MethodInvocation node) { 414 String checkValidity(MethodInvocation node) {
415 // TODO(alanknight): Add reasonable validity checks. 415 // TODO(alanknight): Add reasonable validity checks.
416 return null;
416 } 417 }
417 418
418 /** 419 /**
419 * Create a MainMessage from [node] using the name and 420 * Create a MainMessage from [node] using the name and
420 * parameters of the last function/method declaration we encountered e 421 * parameters of the last function/method declaration we encountered e
421 * and the parameters to the Intl.message call. 422 * and the parameters to the Intl.message call.
422 */ 423 */
423 Message messageFromMethodInvocation(MethodInvocation node) { 424 Message messageFromMethodInvocation(MethodInvocation node) {
424 var message; 425 var message;
425 switch(node.methodName.name) { 426 switch(node.methodName.name) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 */ 467 */
467 final String message; 468 final String message;
468 469
469 /** 470 /**
470 * Creates a new exception with an optional error [message]. 471 * Creates a new exception with an optional error [message].
471 */ 472 */
472 const IntlMessageExtractionException([this.message = ""]); 473 const IntlMessageExtractionException([this.message = ""]);
473 474
474 String toString() => "IntlMessageExtractionException: $message"; 475 String toString() => "IntlMessageExtractionException: $message";
475 } 476 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/lib/intl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698