| OLD | NEW |
| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 new UnsupportedError("MainMessage.toCode requires a locale"); | 343 new UnsupportedError("MainMessage.toCode requires a locale"); |
| 344 | 344 |
| 345 /** | 345 /** |
| 346 * Generate code for this message, expecting it to be part of a map | 346 * Generate code for this message, expecting it to be part of a map |
| 347 * keyed by name with values the function that calls Intl.message. | 347 * keyed by name with values the function that calls Intl.message. |
| 348 */ | 348 */ |
| 349 String toCodeForLocale(String locale) { | 349 String toCodeForLocale(String locale) { |
| 350 var out = new StringBuffer() | 350 var out = new StringBuffer() |
| 351 ..write('static $name(') | 351 ..write('static $name(') |
| 352 ..write(arguments.join(", ")) | 352 ..write(arguments.join(", ")) |
| 353 ..write(') => Intl.$dartMessageName("') | 353 ..write(') => "') |
| 354 ..write(translations[locale]) | 354 ..write(translations[locale]) |
| 355 ..write('");'); | 355 ..write('";'); |
| 356 return out.toString(); | 356 return out.toString(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 /** | 359 /** |
| 360 * The AST node will have the attribute names as strings, so we translate | 360 * The AST node will have the attribute names as strings, so we translate |
| 361 * between those and the fields of the class. | 361 * between those and the fields of the class. |
| 362 */ | 362 */ |
| 363 void operator []=(attributeName, value) { | 363 void operator []=(attributeName, value) { |
| 364 switch (attributeName) { | 364 switch (attributeName) { |
| 365 case "desc" : description = value; return; | 365 case "desc" : description = value; return; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 out.write('('); | 634 out.write('('); |
| 635 out.write(mainArgument); | 635 out.write(mainArgument); |
| 636 var args = codeAttributeNames; | 636 var args = codeAttributeNames; |
| 637 out.write(", {"); | 637 out.write(", {"); |
| 638 args.fold(out, (buffer, arg) => buffer..write( | 638 args.fold(out, (buffer, arg) => buffer..write( |
| 639 "'$arg': '${this[arg].toCode()}', ")); | 639 "'$arg': '${this[arg].toCode()}', ")); |
| 640 out.write("})}"); | 640 out.write("})}"); |
| 641 return out.toString(); | 641 return out.toString(); |
| 642 } | 642 } |
| 643 } | 643 } |
| OLD | NEW |