expectMultiLingualFormatParsing function

void expectMultiLingualFormatParsing(
  1. String content,
  2. MultiLingualFormat format,
  3. {Map<String, List<MainMessage>> messages,
  4. String defaultLocale = 'en'}

Compares a file content with the messages that are expected after parsing the file with the indicated format

While expectFormatParsing works with monolingual files, expectMultiLingualFormatParsing allows to test formats that contains multiple languages


void expectMultiLingualFormatParsing(
  String content,
  MultiLingualFormat format, {
  Map<String, List<MainMessage>> messages,
  String defaultLocale = 'en',
}) {
  final result = format.parseFile(content, defaultLocale);
  for (final translatedForLocale in result) {
    final locale = translatedForLocale.locale;
    for (final translated in translatedForLocale.messages.values) {
      final mainMessage =
          messages[locale].firstWhere((e) => e.name == translated.id);
      final translatedMessage = translated.message..parent = mainMessage;
      expectMessage(translatedMessage, mainMessage);