parseFiles method

  1. @override
Future parseFiles(
  1. List<ReadableFile> files,
  2. {TranslationCatalog catalog}
)
override

Implementation

@override
Future parseFiles(
  List<ReadableFile> files, {
  TranslationCatalog catalog,
}) async {
  var messagesByLocale = <String, Map<String, BasicTranslatedMessage>>{};

  // In order to group these by locale, to support multiple input files,
  // we're reading all the data eagerly, which could be a memory
  // issue for very large projects.
  for (final file in files) {
    final data = await file.readDataOfExactType<StringFileData>();
    final messages = parseFile(data.contents);
    final locale = messages.locale ??
        localeFromName(data.nameWithoutExtension, catalog.projectName);

    messagesByLocale.putIfAbsent(locale, () => {}).addAll(messages.messages);
  }

  messagesByLocale.forEach((locale, messages) {
    catalog.translatedMessages
        .putIfAbsent(locale, () => [])
        .addAll(messages.values);
  });
}