addTemplateMessages method

Future addTemplateMessages(
  1. List<ReadableFile> dartFiles,
  2. {ExtractConfig config}
)

Extract template messages from Intl classes inside dart files

Implementation

Future addTemplateMessages(
  List<ReadableFile> dartFiles, {
  ExtractConfig config,
}) async {
  final extraction = MessageExtraction();
  config?.setToMessageExtraction(extraction);

  for (final file in dartFiles) {
    final data = await file.readAsString();

    final result = extraction.parseContent(data, file.name, false);

    result.forEach((key, value) {
      originalMessage.putIfAbsent(key, () => <MainMessage>[]).add(value);
    });

    messages.addAll(result);
  }

  lastModified = DateTime.now();
}