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

Side by Side Diff: pkg/intl/lib/src/intl_message.dart

Issue 20072002: Allow Intl.plural/gender as the top-level, omitting the Intl.message wrapper and the first layer of… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes from review Created 7 years, 4 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 // 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 provides classes to represent the internal structure of the 6 * This provides classes to represent the internal structure of the
7 * arguments to `Intl.message`. It is used when parsing sources to extract 7 * arguments to `Intl.message`. It is used when parsing sources to extract
8 * messages or to generate code for message substitution. Normal programs 8 * messages or to generate code for message substitution. Normal programs
9 * using Intl would not import this library. 9 * using Intl would not import this library.
10 * 10 *
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 String mainArgument; 384 String mainArgument;
385 385
386 /** 386 /**
387 * Return the list of attribute names to use when generating code. This 387 * Return the list of attribute names to use when generating code. This
388 * may be different from [attributeNames] if there are multiple aliases 388 * may be different from [attributeNames] if there are multiple aliases
389 * that map to the same clause. 389 * that map to the same clause.
390 */ 390 */
391 List<String> get codeAttributeNames; 391 List<String> get codeAttributeNames;
392 392
393 String expanded([Function transform = _nullTransform]) { 393 String expanded([Function transform = _nullTransform]) {
394 fullMessageForClause(key) => key + '{' + transform(parent, this[key]) + '}'; 394 fullMessageForClause(key) => key + '{' +
395 transform(parent, this[key]).toString() + '}';
395 var clauses = attributeNames 396 var clauses = attributeNames
396 .where((key) => this[key] != null) 397 .where((key) => this[key] != null)
397 .map(fullMessageForClause); 398 .map(fullMessageForClause).toList();
398 return "{$mainArgument,$icuMessageName, ${clauses.join("")}}"; 399 return "{$mainArgument,$icuMessageName, ${clauses.join("")}}";
399 } 400 }
400 401
401 String toCode() { 402 String toCode() {
402 var out = new StringBuffer(); 403 var out = new StringBuffer();
403 out.write('\${'); 404 out.write('\${');
404 out.write(dartMessageName); 405 out.write(dartMessageName);
405 out.write('('); 406 out.write('(');
406 out.write(mainArgument); 407 out.write(mainArgument);
407 var args = codeAttributeNames.where( 408 var args = codeAttributeNames.where(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 case "two" : return two; 512 case "two" : return two;
512 case "=2" : return two; 513 case "=2" : return two;
513 case "few" : return few; 514 case "few" : return few;
514 case "many" : return many; 515 case "many" : return many;
515 case "other" : return other; 516 case "other" : return other;
516 default: return other; 517 default: return other;
517 } 518 }
518 } 519 }
519 } 520 }
520 521
OLDNEW
« no previous file with comments | « pkg/intl/lib/intl.dart ('k') | pkg/intl/test/message_extraction/make_hardcoded_translation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698