| 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 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] |
| 11 * and [parseFile] methods which | 11 * and [parseFile] methods which |
| 12 * can extract messages that conform to the expected pattern: | 12 * can extract messages that conform to the expected pattern: |
| 13 * (parameters) => Intl.message("Message $parameters", desc: ...); | 13 * (parameters) => Intl.message("Message $parameters", desc: ...); |
| 14 * It uses the analyzer_experimental package to do the parsing, so may | 14 * It uses the analyzer package to do the parsing, so may |
| 15 * break if there are changes to the API that it provides. | 15 * break if there are changes to the API that it provides. |
| 16 * An example can be found in test/message_extraction/extract_to_json.dart | 16 * An example can be found in test/message_extraction/extract_to_json.dart |
| 17 * | 17 * |
| 18 * Note that this does not understand how to follow part directives, so it | 18 * Note that this does not understand how to follow part directives, so it |
| 19 * has to explicitly be given all the files that it needs. A typical use case | 19 * has to explicitly be given all the files that it needs. A typical use case |
| 20 * is to run it on all .dart files in a directory. | 20 * is to run it on all .dart files in a directory. |
| 21 */ | 21 */ |
| 22 library extract_messages; | 22 library extract_messages; |
| 23 | 23 |
| 24 import 'dart:io'; | 24 import 'dart:io'; |
| 25 | 25 |
| 26 import 'package:analyzer_experimental/analyzer.dart'; | 26 import 'package:analyzer/analyzer.dart'; |
| 27 import 'package:intl/src/intl_message.dart'; | 27 import 'package:intl/src/intl_message.dart'; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * If this is true, print warnings for skipped messages. Otherwise, warnings | 30 * If this is true, print warnings for skipped messages. Otherwise, warnings |
| 31 * are suppressed. | 31 * are suppressed. |
| 32 */ | 32 */ |
| 33 bool suppressWarnings = false; | 33 bool suppressWarnings = false; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * If this is true, then treat all warnings as errors. | 36 * If this is true, then treat all warnings as errors. |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 */ | 466 */ |
| 467 final String message; | 467 final String message; |
| 468 | 468 |
| 469 /** | 469 /** |
| 470 * Creates a new exception with an optional error [message]. | 470 * Creates a new exception with an optional error [message]. |
| 471 */ | 471 */ |
| 472 const IntlMessageExtractionException([this.message = ""]); | 472 const IntlMessageExtractionException([this.message = ""]); |
| 473 | 473 |
| 474 String toString() => "IntlMessageExtractionException: $message"; | 474 String toString() => "IntlMessageExtractionException: $message"; |
| 475 } | 475 } |
| OLD | NEW |