compile method

String compile()

Implementation

String compile() {
  final blocks = <StringBuffer>[];

  if (table.translations[''] != null && table.translations['']![''] != null) {
    blocks.add(
      _drawBlock(
        table.translations['']![''] as Map<String, dynamic>,
        msgstr: [generateHeader(table.headers)],
      ),
    );
  }

  table.translations.forEach((msgctx, messages) {
    final messagesToDraw = msgctx == ''
        ? (Map.of(messages)..remove(''))
        : messages;

    blocks.addAll(
      messagesToDraw.values
          .whereType<Map<String, dynamic>>()
          .cast<Map<String, dynamic>>()
          .map(_drawBlock),
    );
  });

  return blocks.join('\n\n');
}